32template <
typename WheelSpeeds,
typename WheelPositions>
45 const WheelPositions& wheelPositions,
47 : m_kinematics(kinematics),
49 m_previousWheelPositions(wheelPositions) {
50 m_previousAngle = m_pose.Rotation();
51 m_gyroOffset = m_pose.Rotation() - gyroAngle;
65 const WheelPositions& wheelPositions,
const Pose3d& pose) {
68 m_gyroOffset = m_pose.Rotation() - gyroAngle;
69 m_previousWheelPositions = wheelPositions;
78 m_gyroOffset = m_gyroOffset + (pose.
Rotation() - m_pose.Rotation());
89 m_pose =
Pose3d{translation, m_pose.Rotation()};
98 m_gyroOffset = m_gyroOffset + (rotation - m_pose.Rotation());
99 m_pose =
Pose3d{m_pose.Translation(), rotation};
100 m_previousAngle = rotation;
121 const WheelPositions& wheelPositions) {
122 auto angle = gyroAngle + m_gyroOffset;
123 auto angle_difference = (angle - m_previousAngle).ToVector();
126 m_kinematics.ToTwist2d(m_previousWheelPositions, wheelPositions);
130 units::radian_t{angle_difference(0)},
131 units::radian_t{angle_difference(1)},
132 units::radian_t{angle_difference(2)}};
134 auto newPose = m_pose.Exp(twist);
136 m_previousWheelPositions = wheelPositions;
137 m_previousAngle = angle;
138 m_pose = {newPose.Translation(), angle};
147 WheelPositions m_previousWheelPositions;
#define WPILIB_DLLEXPORT
Definition SymbolExports.h:36
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual wheel s...
Definition Kinematics.h:25
Class for odometry.
Definition Odometry3d.h:33
void ResetRotation(const Rotation3d &rotation)
Resets the rotation of the pose.
Definition Odometry3d.h:97
void ResetPose(const Pose3d &pose)
Resets the pose.
Definition Odometry3d.h:77
Odometry3d(const Kinematics< WheelSpeeds, WheelPositions > &kinematics, const Rotation3d &gyroAngle, const WheelPositions &wheelPositions, const Pose3d &initialPose=Pose3d{})
Constructs an Odometry3d object.
Definition Odometry3d.h:43
void ResetTranslation(const Translation3d &translation)
Resets the translation of the pose.
Definition Odometry3d.h:88
void ResetPosition(const Rotation3d &gyroAngle, const WheelPositions &wheelPositions, const Pose3d &pose)
Resets the robot's position on the field.
Definition Odometry3d.h:64
const Pose3d & GetPose() const
Returns the position of the robot on the field.
Definition Odometry3d.h:107
const Pose3d & Update(const Rotation3d &gyroAngle, const WheelPositions &wheelPositions)
Updates the robot's position on the field using forward kinematics and integration of the pose over t...
Definition Odometry3d.h:120
Represents a 3D pose containing translational and rotational elements.
Definition Pose3d.h:28
constexpr const Rotation3d & Rotation() const
Returns the underlying rotation.
Definition Pose3d.h:148
A rotation in a 3D coordinate frame represented by a quaternion.
Definition Rotation3d.h:29
Represents a translation in 3D space.
Definition Translation3d.h:26
A change in distance along a 3D arc since the last pose update.
Definition Twist3d.h:22