ChassisVelocities
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.linearVelTo convert from global to chassis (local) velocities:
val chassisVel = currentPose.heading.inverse() * globalVelExample 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
Properties
Functions
Divides the chassis velocity by a scalar.
Linear interpolation (lerp) toward another chassis velocity.
Computes the difference between two chassis velocities.
Adds two chassis velocities component-wise.
Multiplies the chassis velocity by a scalar.
Converts this chassis velocity (local frame) to a pose velocity (global frame).
Negates the chassis velocity.