Skip to content

[wpimath] Add Twist3d.toTwist2d() - #9281

Open
Brainiac11 wants to merge 1 commit into
wpilibsuite:mainfrom
Brainiac11:patch-3
Open

[wpimath] Add Twist3d.toTwist2d()#9281
Brainiac11 wants to merge 1 commit into
wpilibsuite:mainfrom
Brainiac11:patch-3

Conversation

@Brainiac11

Copy link
Copy Markdown
Contributor

Added method to convert Twist3d to Twist2d representation.

Added method to convert Twist3d to Twist2d representation.
@Brainiac11
Brainiac11 requested a review from a team as a code owner August 14, 2026 22:14
@github-actions github-actions Bot added the component: wpimath Math library label Aug 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is correct. Please replace rx with rz.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡

@calcmogul calcmogul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a C++ port. Furthermore, wpimath/src/main/python/semiwrap/Twist3d.yml needs ToTwist2d: added before Exp:.

Comment on lines +62 to +63
* Returns a Twist2d representation with the X Rotation
* @return The Twist2d of the robot

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the docs phrasing from Pose3d.toPose2d(), Translation3d.toTranslation2d(), and Rotation3d.toRotation2d().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫡

* @return The Twist2d of the robot
*/
public Twist2d toTwist2d(){
return new Twist2d(dx, dy, rx);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is correct. Please replace rx with rz.

@calcmogul calcmogul changed the title Implement toTwist2d method in Twist3d class [wpimath] Add Twist3d.toTwist2d() Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants