Geometry
package com.arcrobotics.ftclib.geometry
Last updated
package com.arcrobotics.ftclib.geometry
Last updated
FTCLib provides access to geometry classes taken from WPILib. Since we like copy-pasting straight from WPILib instead of linking to the original material, that's what we're gonna do.
Translation in 2 dimensions is represented by FTCLib'sTranslation2d
class. This class has an x and y component, representing the point or the vector on a 2-dimensional coordinate system.
You can get the distance to another Translation2d
object by using the getDistance(Translation2d other)
, which returns the distance to another Translation2d
by using the Pythagorean theorem.
Rotation in 2 dimensions is represented by FTCLib’s Rotation2d
class. 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.
Pose is a combination of both translation and rotation and is represented by the Pose2d
class. 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 .
A vector in 2 dimensions is represented by the Vector2d
class. It holds an and a value similarly to a Translation2d
. These components representing the point or as the matrix.
Unlike a Translation2d
, there are a few different methods and features.
Both classes can be used to estimate robot location. Twist2d
is used in some of the FTCLib odometry classes to update the robot’s pose based on movement, while Transform2d
can be used to estimate the robot’s global position from vision data.
FTCLib provides 2 classes, Transform2d
, which represents a transformation to a pose, and Twist2d
which represents a movement along an arc. Transform2d
and Twist2d
all have , and components.
Transform2d
represents a relative transformation. It has an translation and a rotation component. Transforming a Pose2d
by a Transform2d
rotates the translation component of the transform by the rotation of the pose, and then adds the rotated translation component and the rotation component to the pose. In other words, Pose2d.plus(Transform2d)
returns .
Twist2d
represents a change in distance along an arc. For a given arc traveled, is the distance traveled forward as measured from the robot's perspective throughout the movement (for a differential drive, this is the arc length), is the distance traveled sideways from the robot's perspective (for a differential drive, this is 0), and is the change in heading.