CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::SimSwerveDrivetrain Class Reference

Simplified swerve drive simulation class. More...

#include <ctre/phoenix6/swerve/SimSwerveDrivetrain.hpp>

Classes

class  SimSwerveModule
 

Public Member Functions

template<typename... ModuleConstants, typename = std::enable_if_t< std::conjunction_v<std::is_same<ModuleConstants, SwerveModuleConstants>...> >>
 SimSwerveDrivetrain (std::vector< Translation2d > wheelLocations, sim::Pigeon2SimState &pigeonSim, ModuleConstants const &... moduleConstants)
 
void Update (units::second_t dt, units::volt_t supplyVoltage, std::vector< std::unique_ptr< SwerveModule > > const &modulesToApply)
 

Static Protected Member Functions

static units::volt_t AddFriction (units::volt_t motorVoltage, units::volt_t frictionVoltage)
 Applies the effects of friction to dampen the motor voltage.
 

Protected Attributes

sim::Pigeon2SimState_pigeonSim
 
std::vector< SimSwerveModule_modules
 
impl::SwerveDriveKinematics _kinem
 
Rotation2d _lastAngle {}
 

Detailed Description

Simplified swerve drive simulation class.

This class assumes that the swerve drive is perfect, meaning that there is no scrub and the wheels do not slip.

In addition, it assumes the inertia of the robot is governed only by the inertia of the steer module and the individual drive wheels. Robot-wide inertia is not accounted for, and neither is translational vs rotational inertia of the robot.

These assumptions provide a simplified example that can demonstrate the behavior of a swerve drive in simulation. Users are encouraged to expand this model for their own use.

Constructor & Destructor Documentation

◆ SimSwerveDrivetrain()

template<typename... ModuleConstants, typename = std::enable_if_t< std::conjunction_v<std::is_same<ModuleConstants, SwerveModuleConstants>...> >>
ctre::phoenix6::swerve::SimSwerveDrivetrain::SimSwerveDrivetrain ( std::vector< Translation2d > wheelLocations,
sim::Pigeon2SimState & pigeonSim,
ModuleConstants const &... moduleConstants )
inline

Member Function Documentation

◆ AddFriction()

static units::volt_t ctre::phoenix6::swerve::SimSwerveDrivetrain::AddFriction ( units::volt_t motorVoltage,
units::volt_t frictionVoltage )
inlinestaticprotected

Applies the effects of friction to dampen the motor voltage.

Parameters
motorVoltageVoltage output by the motor
frictionVoltageVoltage required to overcome friction
Returns
Friction-dampened motor voltage

◆ Update()

void ctre::phoenix6::swerve::SimSwerveDrivetrain::Update ( units::second_t dt,
units::volt_t supplyVoltage,
std::vector< std::unique_ptr< SwerveModule > > const & modulesToApply )
inline

Member Data Documentation

◆ _kinem

impl::SwerveDriveKinematics ctre::phoenix6::swerve::SimSwerveDrivetrain::_kinem
protected

◆ _lastAngle

Rotation2d ctre::phoenix6::swerve::SimSwerveDrivetrain::_lastAngle {}
protected

◆ _modules

std::vector<SimSwerveModule> ctre::phoenix6::swerve::SimSwerveDrivetrain::_modules
protected

◆ _pigeonSim

sim::Pigeon2SimState& ctre::phoenix6::swerve::SimSwerveDrivetrain::_pigeonSim
protected

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