[wpimath] Add CoordinateSystem conversion for Transform3d (#4443)

I also refactored Pose3d's conversion implementation to use the
Translation3d and Rotation3d conversions, thereby giving Translation3d
and Rotation3d test coverage. No changes were made to the expected
values of the Pose3d conversion tests.

The expected values of the Transform3d conversion tests were copied from
the Pose3d conversion tests without modification.
This commit is contained in:
Tyler Veness
2022-10-01 21:09:04 -07:00
committed by GitHub
parent 38bb23eb18
commit b53b3526a2
5 changed files with 287 additions and 43 deletions

View File

@@ -61,6 +61,13 @@ Rotation3d CoordinateSystem::Convert(const Rotation3d& rotation,
Pose3d CoordinateSystem::Convert(const Pose3d& pose,
const CoordinateSystem& from,
const CoordinateSystem& to) {
return pose.RelativeTo(
Pose3d{Translation3d{}, to.m_rotation - from.m_rotation});
return Pose3d{Convert(pose.Translation(), from, to),
Convert(pose.Rotation(), from, to)};
}
Transform3d CoordinateSystem::Convert(const Transform3d& transform,
const CoordinateSystem& from,
const CoordinateSystem& to) {
return Transform3d{Convert(transform.Translation(), from, to),
Convert(transform.Rotation(), from, to)};
}