[wpimath] Add Twist3d.toTwist2d() - #9281
Conversation
Added method to convert Twist3d to Twist2d representation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 933d372507
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * @return The Twist2d of the robot | ||
| */ | ||
| public Twist2d toTwist2d(){ | ||
| return new Twist2d(dx, dy, rx); |
There was a problem hiding this comment.
Use the Z-axis rotation for planar dtheta
When converting the usual planar motion—where yaw is stored in rz and rx is zero—this returns a Twist2d with zero angular displacement, so applying the result loses every turn; conversely, roll is incorrectly interpreted as planar rotation. Twist2d.dtheta is rotation in the X-Y plane, consistent with Rotation3d.toRotation2d() projecting via the Z component, so the third argument must be rz.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This comment is correct. Please replace rx with rz.
calcmogul
left a comment
There was a problem hiding this comment.
This needs a C++ port. Furthermore, wpimath/src/main/python/semiwrap/Twist3d.yml needs ToTwist2d: added before Exp:.
| * Returns a Twist2d representation with the X Rotation | ||
| * @return The Twist2d of the robot |
There was a problem hiding this comment.
Please follow the docs phrasing from Pose3d.toPose2d(), Translation3d.toTranslation2d(), and Rotation3d.toRotation2d().
| * @return The Twist2d of the robot | ||
| */ | ||
| public Twist2d toTwist2d(){ | ||
| return new Twist2d(dx, dy, rx); |
There was a problem hiding this comment.
This comment is correct. Please replace rx with rz.
Added method to convert Twist3d to Twist2d representation.