1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <wpi/MathExtras.h>
#include <wpi/SymbolExports.h>
#include "frc/geometry/Rotation2d.h"
#include "units/length.h"
#include "units/math.h"
namespace frc {
/**
* Represents the position of one swerve module.
*/
struct WPILIB_DLLEXPORT SwerveModulePosition {
/**
* Distance the wheel of a module has traveled
*/
units::meter_t distance = 0_m;
/**
* Angle of the module.
*/
Rotation2d angle;
/**
* Checks equality between this SwerveModulePosition and another object.
*
* @param other The other object.
* @return Whether the two objects are equal.
*/
constexpr bool operator==(const SwerveModulePosition& other) const {
return units::math::abs(distance - other.distance) < 1E-9_m &&
angle == other.angle;
}
constexpr SwerveModulePosition Interpolate(
const SwerveModulePosition& endValue, double t) const {
return {wpi::Lerp(distance, endValue.distance, t),
wpi::Lerp(angle, endValue.angle, t)};
}
};
} // namespace frc
#include "frc/kinematics/proto/SwerveModulePositionProto.h"
#include "frc/kinematics/struct/SwerveModulePositionStruct.h"