ChassisVelocities

data class ChassisVelocities(val linearVel: Vector2d<PerUnit<DistanceUnit, TimeUnit>>, val angVel: AngularVelocity)(source)

Represents the velocity of a robot chassis in its local (body) frame.

ChassisVelocities vs PoseVelocity2d

ChassisVelocities represents velocities in the robot's local frame (body frame):

  • The x-axis points forward from the robot

  • The y-axis points left from the robot

  • Linear velocities are relative to the robot's orientation

  • This is the natural frame for robot control commands

PoseVelocity2d represents velocities in the global (field) frame:

  • The x and y axes are fixed to the field

  • Linear velocities are relative to the field coordinate system

  • This is the natural frame for trajectory planning and pose tracking

Conversion Between Frames

To convert from chassis (local) to global velocities:

val globalVel = currentPose.heading * chassisVel.linearVel

To convert from global to chassis (local) velocities:

val chassisVel = currentPose.heading.inverse() * globalVel

Example Usage

// Robot moving forward at 10 in/s, turning at 0.5 rad/s
val chassisVel = ChassisVelocities(
linearVel = Vector2d(10.0.inchesPerSecond, 0.0.inchesPerSecond),
angVel = 0.5.radiansPerSecond
)

// Convert to field frame
val fieldVel = PoseVelocity2d(
linearVel = pose.heading * chassisVel.linearVel,
angVel = chassisVel.angVel // Angular velocity is frame-invariant
)

See also

for velocities in the global frame

Constructors

Link copied to clipboard
constructor(linearVel: Vector2d<PerUnit<DistanceUnit, TimeUnit>>, angVel: AngularVelocity)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

angular velocity (frame-invariant)

Link copied to clipboard

linear velocity in the robot's local frame (forward/left)

Functions

Link copied to clipboard
operator fun div(scalar: Double): ChassisVelocities

Divides the chassis velocity by a scalar.

Link copied to clipboard

Linear interpolation (lerp) toward another chassis velocity.

Link copied to clipboard

Computes the difference between two chassis velocities.

Link copied to clipboard

Adds two chassis velocities component-wise.

Link copied to clipboard
operator fun times(scalar: Double): ChassisVelocities

Multiplies the chassis velocity by a scalar.

Link copied to clipboard

Converts this chassis velocity (local frame) to a pose velocity (global frame).

Link copied to clipboard

Negates the chassis velocity.