ChoreoLib
Choreo support library.
Loading...
Searching...
No Matches
choreo::SwerveSample Class Reference

#include <choreo/trajectory/SwerveSample.h>

Public Member Functions

constexpr SwerveSample ()=default
 
constexpr SwerveSample (units::second_t timestamp, units::meter_t x, units::meter_t y, units::radian_t heading, units::meters_per_second_t vx, units::meters_per_second_t vy, units::radians_per_second_t omega, units::meters_per_second_squared_t ax, units::meters_per_second_squared_t ay, units::radians_per_second_squared_t alpha, std::array< units::newton_t, 4 > moduleForcesX, std::array< units::newton_t, 4 > moduleForcesY)
 
constexpr units::second_t GetTimestamp () const
 
constexpr frc::Pose2d GetPose () const
 
constexpr frc::ChassisSpeeds GetChassisSpeeds () const
 
template<int Year = util::kDefaultYear>
constexpr SwerveSample Flipped () const
 
constexpr SwerveSample OffsetBy (units::second_t timeStampOffset) const
 
constexpr SwerveSample Interpolate (const SwerveSample &endValue, units::second_t t) const
 
constexpr bool operator== (const SwerveSample &other) const
 

Public Attributes

units::second_t timestamp = 0_s
 The timestamp of this sample relative to the beginning of the trajectory.
 
units::meter_t x = 0_m
 The X position of the sample relative to the blue alliance wall origin.
 
units::meter_t y = 0_m
 The Y position of the sample relative to the blue alliance wall origin.
 
units::radian_t heading = 0_rad
 The heading of the sample, with 0 being in the +X direction.
 
units::meters_per_second_t vx = 0_mps
 The velocity of the sample in the X direction.
 
units::meters_per_second_t vy = 0_mps
 The velocity of the sample in the Y direction.
 
units::radians_per_second_t omega = 0_rad_per_s
 The angular velocity of the sample.
 
units::meters_per_second_squared_t ax = 0_mps_sq
 The acceleration of the in the X direction.
 
units::meters_per_second_squared_t ay = 0_mps_sq
 The acceleration of the in the Y direction.
 
units::radians_per_second_squared_t alpha = 0_rad_per_s_sq
 The angular acceleration of the sample.
 
std::array< units::newton_t, 4 > moduleForcesX {0_N, 0_N, 0_N, 0_N}
 
std::array< units::newton_t, 4 > moduleForcesY {0_N, 0_N, 0_N, 0_N}
 

Detailed Description

A single swerve robot sample in a Trajectory.

Constructor & Destructor Documentation

◆ SwerveSample() [1/2]

constexpr choreo::SwerveSample::SwerveSample ( )
constexprdefault

Constructs a SwerveSample that is defaulted.

◆ SwerveSample() [2/2]

constexpr choreo::SwerveSample::SwerveSample ( units::second_t  timestamp,
units::meter_t  x,
units::meter_t  y,
units::radian_t  heading,
units::meters_per_second_t  vx,
units::meters_per_second_t  vy,
units::radians_per_second_t  omega,
units::meters_per_second_squared_t  ax,
units::meters_per_second_squared_t  ay,
units::radians_per_second_squared_t  alpha,
std::array< units::newton_t, 4 >  moduleForcesX,
std::array< units::newton_t, 4 >  moduleForcesY 
)
inlineconstexpr

Constructs a SwerveSample with the specified parameters.

Parameters
timestampThe timestamp of this sample, relative to the beginning of the trajectory.
xThe X position of the sample
yThe Y position of the sample
headingThe heading of the sample, with 0 being in the +X direction.
vxThe velocity of the sample in the X direction.
vyThe velocity of the sample in the Y direction.
omegaThe angular velocity of the sample.
axThe acceleration of the sample in the X direction.
ayThe acceleration of the sample in the Y direction.
alphaThe angular acceleration of the sample.
moduleForcesXThe force on each swerve module in the X direction. Module forces appear in the following order: [FL, FR, BL, BR].
moduleForcesYThe force on each swerve module in the Y direction. Module forces appear in the following order: [FL, FR, BL, BR].

Member Function Documentation

◆ Flipped()

template<int Year = util::kDefaultYear>
constexpr SwerveSample choreo::SwerveSample::Flipped ( ) const
inlineconstexpr

Returns the current sample flipped based on the field year.

Template Parameters
YearThe field year.
Returns
SwerveSample that is flipped based on the field layout.

◆ GetChassisSpeeds()

constexpr frc::ChassisSpeeds choreo::SwerveSample::GetChassisSpeeds ( ) const
inlineconstexpr

Gets the field-relative chassis speeds of the SwerveSample.

Returns
The field-relative chassis speeds.

◆ GetPose()

constexpr frc::Pose2d choreo::SwerveSample::GetPose ( ) const
inlineconstexpr

Gets the Pose2d of the SwerveSample.

Returns
The pose.

◆ GetTimestamp()

constexpr units::second_t choreo::SwerveSample::GetTimestamp ( ) const
inlineconstexpr

Gets the timestamp of the SwerveSample.

Returns
The timestamp.

◆ Interpolate()

constexpr SwerveSample choreo::SwerveSample::Interpolate ( const SwerveSample endValue,
units::second_t  t 
) const
inlineconstexpr

Interpolates between endValue and this by t

Parameters
endValuethe end interpolated value
ttime to move sample by
Returns
the interpolated sample

◆ OffsetBy()

constexpr SwerveSample choreo::SwerveSample::OffsetBy ( units::second_t  timeStampOffset) const
inlineconstexpr

Returns the current sample offset by a the time offset passed in.

Parameters
timeStampOffsettime to move sample by
Returns
SwerveSample that is moved forward by the offset

◆ operator==()

constexpr bool choreo::SwerveSample::operator== ( const SwerveSample other) const
inlineconstexpr

SwerveSample equality operator.

Parameters
otherThe other SwerveSample.
Returns
True for equality.

Member Data Documentation

◆ moduleForcesX

std::array<units::newton_t, 4> choreo::SwerveSample::moduleForcesX {0_N, 0_N, 0_N, 0_N}

The force on each swerve module in the X direction. Module forces appear in the following order: [FL, FR, BL, BR].

◆ moduleForcesY

std::array<units::newton_t, 4> choreo::SwerveSample::moduleForcesY {0_N, 0_N, 0_N, 0_N}

The force on each swerve module in the Y direction. Module forces appear in the following order: [FL, FR, BL, BR].


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