Hi, I’m implementing a command that takes the current robot position and rotates it to face the speaker or another field element. I’m wondering if there’s a builtin method to find the angle we need to rotate.
Not in Pose2D, but Translation2D has some common vector operations that will help: Transformations — FIRST Robotics Competition documentation
Thanks!
For anybody else who stumbles upon this thread in the future, here’s the code:
Translation2d pointToFace = /* whatever */;
Rotation2d rotationNeeded = pointToFace.minus(currentPose.getTranslation()).getAngle();
return driveToRotation(rotationNeeded.getRadians());
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.