Brick
Loading...
Searching...
No Matches
Pose2d Class Reference

#include <pose2d.h>

Description

Class representing a pose in 2d space with x, y, and rotational components

Assumes conventional cartesian coordinate system: Looking down at the coordinate plane, +X is right +Y is up +Theta is counterclockwise

Public Member Functions

constexpr Pose2d ()
 Default Constructor for Pose2d.
constexpr Pose2d (Translation2d translation, Rotation2d rotation)
constexpr Pose2d (units::Length x, units::Length y, Rotation2d rotation)
constexpr Pose2d (units::Length x, units::Length y, double radians)
constexpr Pose2d (const Eigen::Vector3d &pose_vector, units::Length length_unit, units::Angle angle_unit=units::radians)
constexpr units::Length x () const
 Gets the x value of the translation.
constexpr double x (units::Length unit) const
 Gets x in the supplied length unit.
constexpr void set_x (units::Length val)
 Sets the x value of the translation.
constexpr units::Length y () const
 Gets the y value of the translation.
constexpr double y (units::Length unit) const
 Gets y in the supplied length unit.
constexpr void set_y (units::Length val)
 Sets the y value of the translation.
constexpr Translation2d translation () const
 Gets the translation.
constexpr void set_translation (Translation2d val)
 Sets the translation.
constexpr Rotation2d rotation () const
 Gets the rotation.
constexpr void set_rotation (Rotation2d val)
 Sets the rotation.
constexpr units::Angle angle () const
 Gets the heading as an angle.
constexpr double angle (units::Angle unit) const
 Gets the angle in the supplied unit.
constexpr void set_angle (units::Angle val)
 Sets the rotation as an angle.
EVec< 3 > as_vector (units::Length length_unit, units::Angle angle_unit=units::radians) const
 Gets [x, y, theta] in the supplied units. Angles default to radians.
constexpr units::Length distance (Translation2d point) const
 Calculates the distance from the pose to another point.
constexpr units::Length distance (const Pose2d &other) const
 Calculates the distance from this to another pose, ignoring rotation.
constexpr Rotation2d bearing_to (Translation2d point) const
 Calculates the bearing from this to another point in the world frame.
constexpr units::Angle angle_to (Translation2d point) const
 Calculates the smallest angle to another point in the local frame.
constexpr Translation2d local_to_world (Translation2d point) const
 Converts a point from this pose's local frame to the world frame.
constexpr Translation2d world_to_local (Translation2d point) const
 Converts a point from the world frame to this pose's local frame.
constexpr Pose2d relative_to (const Pose2d &other) const
constexpr Pose2d transform_by (const Transform2d &transform) const
constexpr Pose2d interpolate (const Pose2d &end, double fraction) const
constexpr Pose2d exp (const Twist2d &twist) const
constexpr Twist2d log (const Transform2d &transform) const
constexpr Pose2d operator+ (const Transform2d &transform) const
 Adds a transform to this pose by rotating it into the pose frame then adding.
constexpr Pose2d & operator+= (const Transform2d &transform)
 Adds a transform to this pose by rotating it into the pose frame then adding.
constexpr Transform2d operator- (const Pose2d &other) const
 Subtracts another pose from this to find the transform between them.
constexpr bool operator== (const Pose2d &other) const
 Checks exact equality between this and another pose.
constexpr bool is_near (const Pose2d &other, units::Length distance_tolerance=units::Length(1e-6), units::Angle angle_tolerance=units::Angle(1e-6)) const

Static Public Member Functions

static Pose2d wrapped_mean (const std::vector< Pose2d > &list)

Constructor & Destructor Documentation

◆ Pose2d() [1/4]

Pose2d::Pose2d ( Translation2d translation,
Rotation2d rotation )
inlineconstexpr

Constructs a pose with given translation and rotation components.

Parameters
translationtranslational component.
rotationrotational component.

◆ Pose2d() [2/4]

Pose2d::Pose2d ( units::Length x,
units::Length y,
Rotation2d rotation )
inlineconstexpr

Constructs a pose with given translation and rotation components.

Parameters
xx component.
yy component.
rotationrotational component.

◆ Pose2d() [3/4]

Pose2d::Pose2d ( units::Length x,
units::Length y,
double radians )
inlineconstexpr

Constructs a pose with given translation and rotation components.

Parameters
xx component.
yy component.
radiansrotational component in radians.

◆ Pose2d() [4/4]

Pose2d::Pose2d ( const Eigen::Vector3d & pose_vector,
units::Length length_unit,
units::Angle angle_unit = units::radians )
inlineconstexpr

Constructs a pose with given translation and rotation components in a vector, using the supplied units.

Parameters
pose_vectorvector of the form [x, y, theta].
length_unitunit of length to use.
angle_unitunit of angle to use, defaults to radians.

Member Function Documentation

◆ exp()

Pose2d Pose2d::exp ( const Twist2d & twist) const
inlineconstexpr

Applies a twist (pose delta) to a pose by integrating constant velocity and angular velocity in the robot's frame of motion.

When applying a twist, imagine a constant angular velocity, the translational components must be rotated into the global frame at every point along the twist, simply adding the deltas does not do this, and using euler integration results in some error. This is the analytic solution for integrating along an arc.

Can also be thought of more simply as following an arc rather than a straight line.

See this document for more information on the pose exponential and its derivation. https://file.tavsys.net/control/controls-engineering-in-frc.pdf#section.10.2

Parameters
twistThe twist, represents a pose delta.
Returns
new pose that has been moved forward according to the twist.

◆ interpolate()

Pose2d Pose2d::interpolate ( const Pose2d & end,
double fraction ) const
inlineconstexpr

Interpolates position along a straight line and heading along the shortest turn. Fractions outside [0, 1] return the nearest endpoint.

Does NOT move along an arc like a Twist, it's a straight line.

◆ is_near()

bool Pose2d::is_near ( const Pose2d & other,
units::Length distance_tolerance = units::Length(1e-6),
units::Angle angle_tolerance = units::Angle(1e-6) ) const
inlineconstexpr

Checks translation distance and the smallest angle against tolerances. Defaults to 1um and 1e-6 radians.

◆ log()

Twist2d Pose2d::log ( const Transform2d & transform) const
inlineconstexpr

The inverse of the pose exponential.

Determines the twist required to go from this pose to the given end pose.

Parameters
end_posethe end pose to find the mapping to.
Returns
the twist required to go from this pose to the given end

◆ relative_to()

Pose2d Pose2d::relative_to ( const Pose2d & other) const
inlineconstexpr

Finds this pose in the frame of another pose rather than the origin.

Parameters
othernew origin.
Returns
this pose relative to other.

◆ transform_by()

Pose2d Pose2d::transform_by ( const Transform2d & transform) const
inlineconstexpr

Adds a transform to this pose. Rotates the transform's translation into the pose's frame, then adds the translation and rotation.

Parameters
transformthe change in pose.
Returns
the pose after being transformed.

◆ wrapped_mean()

Pose2d Pose2d::wrapped_mean ( const std::vector< Pose2d > & list)
inlinestatic

Calculates the mean of a list of poses.

Parameters
liststd::vector containing a list of poses.
Returns
the single pose mean of the list of poses.

The documentation for this class was generated from the following file: