Transfert, Rotation et Pose

Transfert

Translation in 2 dimensions is represented by WPILib’s Translation2d class (Java, C++, Python). This class has an x and y component, representing the point $$(x, y)$$ or the vector $$\begin{bmatrix}x \\ y \end{bmatrix}$$ on a 2-dimensional coordinate system.

Vous pouvez obtenir la distance à l’autre objet Translation2d en utilisant le getDistance(Translation2d other), qui calcule la distance vectorielle entre les deux Translation2d en utilisant le théorème de Pythagore

Note

Translation2d uses the C++ Units library. If you’re planning on using other WPILib classes that use Translation2d in Java/Python, such as the trajectory generator, make sure to use meters.

Rotation

Rotation in 2 dimensions is represented by WPILib’s Rotation2d class (Java, C++, Python). This class has an angle component, which represents the robot’s rotation relative to an axis on a 2-dimensional coordinate system. Positive rotations are counterclockwise.

Note

Rotation2d uses the C++ Units library. The constructor in Java/Python accepts either the angle in radians, or the sine and cosine of the angle, but the fromDegrees method will construct a Rotation2d object from degrees.

Note

Rotation2d n’enveloppe (wrap) pas la valeur de l’angle, donc si une valeur de 400 degrés est passée au constructeur, alors 400 degrés seront renvoyés dans les appels de valeur suivants.

Pose

Pose is a combination of both translation and rotation and is represented by the Pose2d class (Java, C++, Python). It can be used to describe the pose of your robot in the field coordinate system, or the pose of objects, such as vision targets, relative to your robot in the robot coordinate system. Pose2d can also represent the vector $$\begin{bmatrix}x \\ y \\ \theta\end{bmatrix}$$.