CTRE Phoenix 6 C++ 25.3.0
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename > Class Template 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<typename DriveMotorT::Configuration, typename SteerMotorT::Configuration, typename EncoderT::Configuration> >... >>>
 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< DriveMotorT, SteerMotorT, EncoderT > > > 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

template<typename DriveMotorT, typename SteerMotorT, typename EncoderT, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
class ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >

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 DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
template<typename... ModuleConstants, typename = std::enable_if_t<std::conjunction_v< std::is_same< ModuleConstants, SwerveModuleConstants<typename DriveMotorT::Configuration, typename SteerMotorT::Configuration, typename EncoderT::Configuration> >... >>>
ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::SimSwerveDrivetrain ( std::vector< Translation2d > wheelLocations,
sim::Pigeon2SimState & pigeonSim,
ModuleConstants const &... moduleConstants )
inline

Member Function Documentation

◆ AddFriction()

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
static units::volt_t ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::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()

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
void ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::Update ( units::second_t dt,
units::volt_t supplyVoltage,
std::vector< std::unique_ptr< SwerveModule< DriveMotorT, SteerMotorT, EncoderT > > > const & modulesToApply )
inline

Member Data Documentation

◆ _kinem

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
impl::SwerveDriveKinematics ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::_kinem
protected

◆ _lastAngle

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
Rotation2d ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::_lastAngle {}
protected

◆ _modules

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
std::vector<SimSwerveModule> ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::_modules
protected

◆ _pigeonSim

template<typename DriveMotorT , typename SteerMotorT , typename EncoderT , typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, DriveMotorT>>, typename = std::enable_if_t<std::is_base_of_v<hardware::traits::CommonTalon, SteerMotorT>>, typename = std::enable_if_t<std::disjunction_v< std::is_same<hardware::CANcoder, EncoderT>, std::is_same<hardware::CANdi, EncoderT>, std::is_same<hardware::TalonFXS, EncoderT> >>>
sim::Pigeon2SimState& ctre::phoenix6::swerve::SimSwerveDrivetrain< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >::_pigeonSim
protected

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