29template <
typename WheelPositions,
typename WheelVelocities,
30 typename WheelAccelerations>
42 WheelAccelerations>& kinematics,
44 const WheelPositions& wheelPositions,
46 : m_kinematics(kinematics),
48 m_previousWheelPositions(wheelPositions) {
49 m_previousAngle = m_pose.Rotation();
52 m_gyroOffset = gyroAngle.
Inverse().RotateBy(m_pose.Rotation());
66 const WheelPositions& wheelPositions,
const Pose3d& pose) {
72 m_previousWheelPositions = wheelPositions;
82 m_gyroOffset = m_gyroOffset.RotateBy(m_pose.Rotation().Inverse())
94 m_pose =
Pose3d{translation, m_pose.Rotation()};
105 m_gyroOffset.RotateBy(m_pose.Rotation().Inverse()).RotateBy(rotation);
106 m_pose =
Pose3d{m_pose.Translation(), rotation};
107 m_previousAngle = rotation;
128 const WheelPositions& wheelPositions) {
129 auto angle = gyroAngle.
RotateBy(m_gyroOffset);
133 m_kinematics.ToTwist2d(m_previousWheelPositions, wheelPositions);
137 wpi::units::radian_t{angle_difference(0)},
138 wpi::units::radian_t{angle_difference(1)},
139 wpi::units::radian_t{angle_difference(2)}};
141 auto newPose = m_pose + twist.
Exp();
143 m_previousWheelPositions = wheelPositions;
144 m_previousAngle = angle;
145 m_pose = {newPose.Translation(), angle};
155 WheelPositions m_previousWheelPositions;
#define WPILIB_DLLEXPORT
Definition SymbolExports.hpp:36
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual wheel v...
Definition Kinematics.hpp:26
void ResetTranslation(const Translation3d &translation)
Resets the translation of the pose.
Definition Odometry3d.hpp:93
Odometry3d(const Kinematics< WheelPositions, WheelVelocities, WheelAccelerations > &kinematics, const Rotation3d &gyroAngle, const WheelPositions &wheelPositions, const Pose3d &initialPose=Pose3d{})
Constructs an Odometry3d object.
Definition Odometry3d.hpp:41
void ResetRotation(const Rotation3d &rotation)
Resets the rotation of the pose.
Definition Odometry3d.hpp:102
void ResetPose(const Pose3d &pose)
Resets the pose.
Definition Odometry3d.hpp:80
const Pose3d & GetPose() const
Returns the position of the robot on the field.
Definition Odometry3d.hpp:114
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.hpp:127
void ResetPosition(const Rotation3d &gyroAngle, const WheelPositions &wheelPositions, const Pose3d &pose)
Resets the robot's position on the field.
Definition Odometry3d.hpp:65
Represents a 3D pose containing translational and rotational elements.
Definition Pose3d.hpp:28
constexpr const Rotation3d & Rotation() const
Returns the underlying rotation.
Definition Pose3d.hpp:148
A rotation in a 3D coordinate frame, represented by a quaternion.
Definition Rotation3d.hpp:69
constexpr Eigen::Vector3d ToVector() const
Returns rotation vector representation of this rotation.
Definition Rotation3d.hpp:489
constexpr Rotation3d Inverse() const
Takes the inverse of the current rotation.
Definition Rotation3d.hpp:290
constexpr Rotation3d RelativeTo(const Rotation3d &other) const
Returns the current rotation relative to the given rotation.
Definition Rotation3d.hpp:349
constexpr Rotation3d RotateBy(const Rotation3d &other) const
Adds the new rotation to the current rotation.
Definition Rotation3d.hpp:333
Represents a translation in 3D space.
Definition Translation3d.hpp:31
Definition LinearSystem.hpp:20
A change in distance along a 3D arc since the last pose update.
Definition Twist3d.hpp:23
constexpr Transform3d Exp() const
Obtain a new Transform3d from a (constant curvature) velocity.
Definition Twist3d.hpp:106