Pose2d

data class Pose2d(val position: Vector2d<DistanceUnit>, val heading: Rotation2d)(source)

Represents a 2D pose (position and orientation) in the Special Euclidean group SE(2).

A pose combines:

  • A position vector \(\mathbf{p} = (x, y)\) in 2D space

  • A heading (orientation) \(R \in SO(2)\)

SE(2) - The Special Euclidean Group

SE(2) is the group of rigid body transformations in 2D, consisting of rotations and translations. A pose can be represented as a transformation matrix:

\(g = \begin{bmatrix} R & \mathbf{p} \\ 0 & 1 \end{bmatrix} \in SE(2)\)

where \(R\) is a 2×2 rotation matrix and \(\mathbf{p}\) is a 2D translation vector.

Operations

Composition: Combining two poses gives a new pose: \(g_1 \circ g_2 = (R_1 R_2, R_1 \mathbf{p}_2 + \mathbf{p}_1)\)

Inverse: The inverse pose: \(g^{-1} = (R^T, -R^T \mathbf{p})\)

Exponential map: Converts a twist (velocity) to a pose: \(\exp: \mathfrak{se}(2) \to SE(2)\)

Logarithm map: Converts a pose to a twist: \(\log: SE(2) \to \mathfrak{se}(2)\)

Example Usage

// Create a pose at (10, 5) with 45-degree heading
val pose = Pose2d(Vector2d(10.0.inches, 5.0.inches), Math.PI / 4)

// Compose poses
val pose2 = Pose2d(Vector2d(1.0.inches, 0.0.inches), 0.0)
val composed = pose * pose2

// Transform a vector
val localPoint = Vector2d(1.0.inches, 0.0.inches)
val globalPoint = pose * localPoint

// Get relative pose
val relativePose = pose2 - pose

Constructors

Link copied to clipboard
constructor(position: Vector2d<DistanceUnit>, heading: Rotation2d)
constructor(position: Vector2d<DistanceUnit>, heading: Double)

Constructs a Pose2d from a position vector and a heading angle.

constructor(x: Distance, y: Distance, heading: Rotation2d)

Constructs a Pose2d from x and y distance measurements and a heading rotation.

constructor(x: Distance, y: Distance, heading: Angle)

Constructs a Pose2d from x and y distance measurements and a heading angle.

constructor(x: Double, y: Double, heading: Rotation2d)

Constructs a Pose2d from x and y coordinates (in inches) and a heading rotation.

constructor(x: Double, y: Double, heading: Double)

Constructs a Pose2d from x and y coordinates (in inches) and a heading angle (in radians).

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

the orientation as a Rotation2d

Link copied to clipboard

the position vector in 2D space

Functions

Link copied to clipboard

Finds the closest pose on a line segment between two poses.

Link copied to clipboard

Finds the parameter t where the distance between two poses is minimized.

Link copied to clipboard
fun distanceTo(other: Pose2d): Double

Computes the linear distance to another pose.

Link copied to clipboard

Computes the inverse of this pose.

Link copied to clipboard
fun lerp(other: Pose2d, t: Double): Pose2d

Linear interpolation (lerp) toward another pose.

Link copied to clipboard
fun log(): Twist2d

Computes the twist (logarithm map) of this pose.

Link copied to clipboard
operator fun minus(t: Pose2d): Twist2d

Computes the twist (logarithm map) from another pose to this pose.

Link copied to clipboard

Computes the relative pose from another pose to this pose.

Link copied to clipboard
operator fun plus(transform: Transform2d): Pose2d

Applies a transform to this pose.

operator fun plus(t: Twist2d): Pose2d

Adds a twist to this pose using the exponential map.

Link copied to clipboard

Computes the transform from this pose to another pose.

Link copied to clipboard
operator fun times(p: Pose2d): Pose2d

Composes this pose with another pose.

Transforms a pose velocity by this pose's rotation.

Transforms a vector by this pose.