转变

Translation2d

在Translation2d上的操作对由Translation2d表示的向量执行操作。

  • 加法:可以使用Java中的plus或C ++中的+运算符在两个Translation2d a和b之间进行加法。加法将两个向量相加。

  • 减法:两个“ Translation2d”之间的减法可以在Java中使用减号或在C ++中使用二进制“-”运算符来执行。减法减去两个向量。

  • 乘法:可以使用Java中的“时间”或C ++中的“ *”运算符来执行“ Translation2d”和标量的乘法。 该乘法是将向量乘以标量。

  • 除法:可以使用Java中的div或C ++中的/运算符来执行Translation2d和标量的除法。该除法是用矢量除以标量。

  • 旋转:通过使用“ rotateBy”,可以绕着原点逆时针旋转``Translation2d”。这相当于将向量乘以矩阵:math:begin{bmatrix} costheta & -sintheta \ sintheta & costheta end{bmatrix}

  • 另外,您可以通过在Java中使用“ unaryMinus”或在C ++中使用一元“-”运算符将“ Translation2d”旋转180度。

Rotation2d

``Rotation2d’’的转换只是对由``Rotation2d``表示的角度度量的算术运算。

  • ``plus``(Java)或``+``(C ++):将``other``的旋转分量添加到此``Rotation2d’’的旋转分量

  • 减号(Java)或二进制-‘’(C ++):将``other’’的旋转分量减去到此``Rotation2d’’的旋转分量

  • unaryMinus''(Java)或一元-‘’(C ++):将旋转分量乘以标量-1。

  • ``times``(Java)或``*``(C ++):将旋转分量乘以标量。

Transform2d and Twist2d

WPILib provides 2 classes, Transform2d (Java, C++), which represents a transformation to a pose, and Twist2d (Java, C++) which represents a movement along an arc. Transform2d and Twist2d all have x, y and \(\theta\) components.

Transform2d''代表一个``相对''转换。它具有平移和旋转组件。通过“ Transform2d”变换“ Pose2d”,将通过姿势的旋转来旋转变换的平移分量,然后将旋转的平移分量和旋转分量添加到该位姿。换句话说,``Pose2d.plus(Transform2d) 返回 \(\begin{bmatrix} x_p \\ y_p \\ \theta_p \end{bmatrix}+\begin{bmatrix} cos\theta_p & -sin\theta_p & 0 \\ sin\theta_p & cos\theta_p & 0 \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix}x_t \\ y_t \\ \theta_t \end{bmatrix}\)

“Twist2d”表示沿弧线的距离变化。通常,这个类用于表示传动系统的运动,其中x组件是向前行驶的距离,y组件是向侧面行驶的距离(左正),而:math: ‘ theta ‘组件是航向的变化。我们可以在第10章,`此处 <https://file.tavsys.net/control/controls-engineering-in-frc.pdf>`找到寻找指数型位姿(沿扭转的曲率向前移动后的新位姿)背后的基本数学原理。

备注

对于非完整的传动系统,``Twist2d’’的y分量应始终为0。

这两个类别均可用于估计机器人位置。 WPILib的里程表类中使用Twist2d根据运动来更新机器人的姿势,而Transform2d可用于根据视觉数据估计机器人的全局位置。