[wpimath] Add Rotation3d rotation vector getter (#7564)

The code churn in Java is just making the function order consistent
between languages.
This commit is contained in:
Tyler Veness
2024-12-22 13:34:51 -08:00
committed by GitHub
parent 0c99073b94
commit 02a0adc653
5 changed files with 40 additions and 25 deletions

View File

@@ -404,7 +404,7 @@ constexpr Twist3d Pose3d::Log(const Pose3d& end) const {
Vector3d u{
{transform.X().value(), transform.Y().value(), transform.Z().value()}};
Vector3d rvec = transform.Rotation().GetQuaternion().ToRotationVector();
Vector3d rvec = transform.Rotation().ToVector();
Matrix3d omega = detail::RotationVectorToMatrix(rvec);
Matrix3d omegaSq = omega * omega;
double theta = rvec.norm();

View File

@@ -421,6 +421,13 @@ class WPILIB_DLLEXPORT Rotation3d {
1.0 - 2.0 * (x * x + y * y)}};
}
/**
* Returns rotation vector representation of this rotation.
*
* @return Rotation vector representation of this rotation.
*/
constexpr Eigen::Vector3d ToVector() const { return m_q.ToRotationVector(); }
/**
* Returns a Rotation2d representing this Rotation3d projected into the X-Y
* plane.

View File

@@ -120,8 +120,7 @@ class WPILIB_DLLEXPORT Odometry3d {
const Pose3d& Update(const Rotation3d& gyroAngle,
const WheelPositions& wheelPositions) {
auto angle = gyroAngle + m_gyroOffset;
auto angle_difference =
(angle - m_previousAngle).GetQuaternion().ToRotationVector();
auto angle_difference = (angle - m_previousAngle).ToVector();
auto twist2d =
m_kinematics.ToTwist2d(m_previousWheelPositions, wheelPositions);