Valkyrie 2026
Loading...
Searching...
No Matches
valor::swerve::Swerve Class Reference
Inheritance diagram for valor::swerve::Swerve:
valor::BaseSubsystem valor::Loggable

Public Member Functions

 Swerve (std::string name, std::vector< SwerveModule::Config > moduleConfigs, std::shared_ptr< gyro::Gyro > gyro, units::meter_t wheelDiameter, frc2::sysid::Config=frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt, nullptr})
void AnalyzeDashboard () override
 Synchronize dashboard data (both read and write).
void LoggablePeriodic () override
 Periodic callback for logging updates.
void Reset () override
 Reset all subsystem state.
void StartOdomThread (units::hertz_t freq)
void SimulationPeriodic () override
void ResetGyro ()
void ApplyRequest (requests::TrackAngularPosition)
void ApplyRequest (requests::ApplyChassisSpeeds)
void ApplyRequest (requests::ApplyStates)
frc2::CommandPtr SysIdQuasistatic (frc2::sysid::Direction d)
frc2::CommandPtr SysIdDynamic (frc2::sysid::Direction d)
void ResetOdometry (FrameWrapper< FieldFrame, frc::Pose2d > pose)
void ResetEncoders ()
double GetSkiddingRatio ()
bool IsRobotSkidding ()
constexpr std::vector< std::unique_ptr< SwerveModule > > & GetModules ()
void UpdateAngularAcceleration ()
 Updates the calculated angular acceleration of the robot. This function uses the current and previous yaw rates from the gyroscope to compute the angular acceleration.
units::angular_acceleration::radians_per_second_squared_t GetSmoothedAngularAcceleration ()
double RotationLerping (double)
constexpr const auto & GetState () const
constexpr auto & GetState ()
Public Member Functions inherited from valor::BaseSubsystem
 BaseSubsystem (std::string name)
 Construct a new Valor Subsystem object.
virtual void AssessInputs ()
 Read controller logic and set subsystem state.
virtual void AssignOutputs ()
 Read subsystem state and send motor commands.
void SetGamepads (valor::Gamepad *_operatorGamepad, valor::Gamepad *_driverGamepad)
Public Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 Loggable (std::shared_ptr< nt::NetworkTable > table)
 Construct a Loggable that uses an existing NetworkTable.
 Loggable ()=default
 Default construct an uninitialized Loggable.
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
bool WriteLog (std::string_view field, bool data)
double WriteLog (std::string_view field, double data)
void WriteLog (std::string_view field, const std::vector< double > &data)
template<typename U>
requires units::traits::is_unit_t_v<U>
U WriteLog (std::string_view field, U data)
void WriteLog (std::string_view field, std::string_view data)
template<typename E>
requires std::is_enum_v<E>
void WriteLog (std::string_view field, E data)
template<typename T>
requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>)
void WriteLog (std::string_view field, const T &data)
template<typename T>
requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>)
void WriteLog (std::string_view field, const std::vector< T > &data)
bool ReadLog (std::string_view field, bool defaultValue)
double ReadLog (std::string_view field, double defaultValue)
template<typename U>
requires units::traits::is_unit_t_v<U>
U ReadLog (std::string_view field, U defaultValue)

Protected Member Functions

void EnableCarpetGrain (double grainMultiplier, bool roughTowardsRed)
FrameWrapper< FieldFrame, frc::ChassisSpeeds > VectorLockedSpeeds (FrameWrapper< FieldFrame, frc::ChassisSpeeds > speeds, FrameWrapper< FieldFrame, frc::Rotation2d > heading)
void UpdateOdometry ()
void SetRotationalLerpMap (wpi::interpolating_map< double, double > _interpolationMap)
ConvexPolygon GetPolygon () const
Protected Member Functions inherited from valor::Loggable
virtual void OnLoggingStart ()
 Hook invoked when logging is started for this object.

Static Protected Member Functions

static FrameWrapper< FieldFrame, frc::ChassisSpeeds > ReflectDriveSpeeds (FrameWrapper< FieldFrame, frc::ChassisSpeeds > unreflectedSpeeds)

Protected Attributes

FrameWrapper< FieldFrame, frc::ChassisSpeeds > commandedSpeeds
units::meters_per_second_t maxDriveSpeed
units::radians_per_second_t maxRotationSpeed
std::shared_ptr< gyro::Gyro > gyro
ctre::phoenix6::swerve::impl::SwerveDriveKinematics kinematics
util::Locked< ctre::phoenix6::swerve::impl::SwerveDrivePoseEstimator > rawEstimator
util::Locked< ctre::phoenix6::swerve::impl::SwerveDrivePoseEstimator > calcEstimator
std::vector< std::unique_ptr< SwerveModule > > swerveModules
frc::Timer resetOdom
valor::ProfiledPIDController< units::radian, units::radians_per_second > rotationController {{}}
 Used for requests::TrackAngularPosition.
Protected Attributes inherited from valor::BaseSubsystem
valor::Gamepad * operatorGamepad = nullptr
valor::Gamepad * driverGamepad = nullptr

Additional Inherited Members

Static Public Member Functions inherited from valor::Loggable
static constexpr Loggable & GetRoot ()

Member Function Documentation

◆ AnalyzeDashboard()

void valor::swerve::Swerve::AnalyzeDashboard ( )
overridevirtual

Synchronize dashboard data (both read and write).

The analyzeDashboard function runs at all times (disabled, auto, and teleop). The intent of the function is to send sensor and state information from the robot to the Driver Station for debugging. Additionally, driver commands and data can be sent from the Driver Station to the robot and collected in this function.

ALL network table and sensor logic should be in this function as both network table and sensor information should be read at all times, not just during teleop since auto will never get that information.

This function is a virtual function and should be implemented by the subsystem.

Reimplemented from valor::BaseSubsystem.

◆ LoggablePeriodic()

void valor::swerve::Swerve::LoggablePeriodic ( )
overridevirtual

Periodic callback for logging updates.

If a derived class needs to perform periodic updates to published values, override this method. It is intended to be called by the logging framework; this base class provides an empty implementation.

Reimplemented from valor::Loggable.

◆ Reset()

void valor::swerve::Swerve::Reset ( )
overridevirtual

Reset all subsystem state.

Use this function to set the subsystem state to default values, as well as set the motor outputs to 0 so the robot doesn't "lurch" when booting up due to phantom state (aka. state that was previously set but hasn't been reset yet).

This function is a virtual function and should be implemented by the subsystem.

Reimplemented from valor::BaseSubsystem.

◆ ResetOdometry()

void valor::swerve::Swerve::ResetOdometry ( FrameWrapper< FieldFrame, frc::Pose2d > pose)

Reset the robot's position on the field. Any accumulted gyro drift will be noted and accounted for in subsequent calls to getPoseMeters()

Parameters
poseThe robot's actual position on the field

Member Data Documentation

◆ calcEstimator

util::Locked<ctre::phoenix6::swerve::impl::SwerveDrivePoseEstimator> valor::swerve::Swerve::calcEstimator
protected
Initial value:
{
kinematics, frc::Rotation2d{}, std::vector<frc::SwerveModulePosition>{}, frc::Pose2d{}}

◆ rawEstimator

util::Locked<ctre::phoenix6::swerve::impl::SwerveDrivePoseEstimator> valor::swerve::Swerve::rawEstimator
protected
Initial value:
{
kinematics, frc::Rotation2d{}, std::vector<frc::SwerveModulePosition>{}, frc::Pose2d{}}

The documentation for this class was generated from the following file:
  • src/main/include/valkyrie/drivetrain/swerve/Swerve.h