CTRE Phoenix 6 C++ 24.50.0-alpha-2
ctre::phoenix6::swerve::impl::ChassisSpeeds Struct Reference

Represents the speed of a robot chassis. More...

#include <ctre/phoenix6/swerve/impl/SwerveDriveKinematics.hpp>

Public Member Functions

constexpr Twist2d ToTwist2d (units::second_t dt) const
 Creates a Twist2d from ChassisSpeeds. More...
 
constexpr ChassisSpeeds operator- () const
 
constexpr ChassisSpeeds operator+ (ChassisSpeeds const &other) const
 
constexpr ChassisSpeeds operator- (ChassisSpeeds const &other) const
 
constexpr ChassisSpeeds operator* (double scalar) const
 
constexpr ChassisSpeeds operator/ (double scalar) const
 
bool operator== (ChassisSpeeds const &other) const
 
bool operator!= (ChassisSpeeds const &other) const
 

Static Public Member Functions

static ChassisSpeeds Discretize (ChassisSpeeds const &continuousSpeeds, units::second_t dt)
 Disretizes a continuous-time chassis speed. More...
 
static ChassisSpeeds FromFieldRelativeSpeeds (ChassisSpeeds const &fieldRelativeSpeeds, Rotation2d const &robotAngle)
 Converts a user provided field-relative ChassisSpeeds object into a robot-relative ChassisSpeeds object. More...
 
static ChassisSpeeds FromRobotRelativeSpeeds (ChassisSpeeds const &fieldRelativeSpeeds, Rotation2d const &robotAngle)
 Converts a user provided robot-relative ChassisSpeeds object into a field-relative ChassisSpeeds object. More...
 

Public Attributes

units::meters_per_second_t vx = 0_mps
 Velocity along the x-axis. More...
 
units::meters_per_second_t vy = 0_mps
 Velocity along the y-axis. More...
 
units::radians_per_second_t omega = 0_rad_per_s
 Represents the angular velocity of the robot frame. More...
 

Detailed Description

Represents the speed of a robot chassis.

Although this struct contains similar members compared to a Twist2d, they do NOT represent the same thing. Whereas a Twist2d represents a change in pose w.r.t to the robot frame of reference, a ChassisSpeeds struct represents a robot's velocity.

A strictly non-holonomic drivetrain, such as a differential drive, should never have a dy component because it can never move sideways. Holonomic drivetrains such as swerve and mecanum will often have all three components.

Member Function Documentation

◆ Discretize()

static ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::Discretize ( ChassisSpeeds const &  continuousSpeeds,
units::second_t  dt 
)
inlinestatic

Disretizes a continuous-time chassis speed.

This function converts a continuous-time chassis speed into a discrete-time one such that when the discrete-time chassis speed is applied for one timestep, the robot moves as if the velocity components are independent (i.e., the robot moves v_x * dt along the x-axis, v_y * dt along the y-axis, and omega * dt around the z-axis).

This is useful for compensating for translational skew when translating and rotating a swerve drivetrain.

Parameters
continuousSpeedsThe continuous speeds.
dtThe duration of the timestep the speeds should be applied for.
Returns
Discretized ChassisSpeeds.

◆ FromFieldRelativeSpeeds()

static ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::FromFieldRelativeSpeeds ( ChassisSpeeds const &  fieldRelativeSpeeds,
Rotation2d const &  robotAngle 
)
inlinestatic

Converts a user provided field-relative ChassisSpeeds object into a robot-relative ChassisSpeeds object.

Parameters
fieldRelativeSpeedsThe ChassisSpeeds object representing the speeds in the field frame of reference. Positive x is away from your alliance wall. Positive y is to your left when standing behind the alliance wall.
robotAngleThe angle of the robot as measured by a gyroscope. The robot's angle is considered to be zero when it is facing directly away from your alliance station wall. Remember that this should be CCW positive.
Returns
ChassisSpeeds object representing the speeds in the robot's frame of reference.

◆ FromRobotRelativeSpeeds()

static ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::FromRobotRelativeSpeeds ( ChassisSpeeds const &  fieldRelativeSpeeds,
Rotation2d const &  robotAngle 
)
inlinestatic

Converts a user provided robot-relative ChassisSpeeds object into a field-relative ChassisSpeeds object.

Parameters
robotRelativeSpeedsThe ChassisSpeeds object representing the speeds in the robot frame of reference. Positive x is the towards robot's front. Positive y is towards the robot's left.
robotAngleThe angle of the robot as measured by a gyroscope. The robot's angle is considered to be zero when it is facing directly away from your alliance station wall. Remember that this should be CCW positive.
Returns
ChassisSpeeds object representing the speeds in the field's frame of reference.

◆ operator!=()

bool ctre::phoenix6::swerve::impl::ChassisSpeeds::operator!= ( ChassisSpeeds const &  other) const
inline

◆ operator*()

constexpr ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::operator* ( double  scalar) const
inlineconstexpr

◆ operator+()

constexpr ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::operator+ ( ChassisSpeeds const &  other) const
inlineconstexpr

◆ operator-() [1/2]

constexpr ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::operator- ( ) const
inlineconstexpr

◆ operator-() [2/2]

constexpr ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::operator- ( ChassisSpeeds const &  other) const
inlineconstexpr

◆ operator/()

constexpr ChassisSpeeds ctre::phoenix6::swerve::impl::ChassisSpeeds::operator/ ( double  scalar) const
inlineconstexpr

◆ operator==()

bool ctre::phoenix6::swerve::impl::ChassisSpeeds::operator== ( ChassisSpeeds const &  other) const
inline

◆ ToTwist2d()

constexpr Twist2d ctre::phoenix6::swerve::impl::ChassisSpeeds::ToTwist2d ( units::second_t  dt) const
inlineconstexpr

Creates a Twist2d from ChassisSpeeds.

Parameters
dtThe duration of the timestep.
Returns
Twist2d.

Member Data Documentation

◆ omega

units::radians_per_second_t ctre::phoenix6::swerve::impl::ChassisSpeeds::omega = 0_rad_per_s

Represents the angular velocity of the robot frame.

(CCW is +)

◆ vx

units::meters_per_second_t ctre::phoenix6::swerve::impl::ChassisSpeeds::vx = 0_mps

Velocity along the x-axis.

(Fwd is +)

◆ vy

units::meters_per_second_t ctre::phoenix6::swerve::impl::ChassisSpeeds::vy = 0_mps

Velocity along the y-axis.

(Left is +)


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