CTRE Phoenix 6 C++ 25.3.1
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::impl::SwerveModuleImpl Class Reference

Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices. More...

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

Classes

struct  ModuleRequest
 Contains everything the swerve module needs to apply a request. More...
 

Public Member Functions

template<typename DriveMotorConfigsT , typename SteerMotorConfigsT , typename EncoderConfigsT >
 SwerveModuleImpl (SwerveModuleConstants< DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT > const &constants, CANBus canbus)
 Construct a SwerveModuleImpl with the specified constants.
 
 ~SwerveModuleImpl ()
 
void Apply (ModuleRequest const &moduleRequest)
 Applies the desired ModuleRequest to this module.
 
template<typename DriveReq , typename SteerReq >
void Apply (DriveReq &&driveRequest, SteerReq &&steerRequest)
 Controls this module using the specified drive and steer control requests.
 
ctre::phoenix::StatusCode ConfigNeutralMode (signals::NeutralModeValue neutralMode, units::second_t timeoutSeconds=0.100_s)
 Configures the neutral mode to use for the module's drive motor.
 
SwerveModulePosition GetPosition (bool refresh)
 Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values.
 
SwerveModulePosition GetCachedPosition () const
 Gets the last cached swerve module position.
 
SwerveModuleState GetCurrentState () const
 Get the current state of the module.
 
SwerveModuleState GetTargetState () const
 Get the target state of the module.
 
void ResetPosition ()
 Resets this module's drive motor position to 0 rotations.
 
ClosedLoopOutputType GetDriveClosedLoopOutputType () const
 Gets the closed-loop output type to use for the drive motor.
 
ClosedLoopOutputType GetSteerClosedLoopOutputType () const
 Gets the closed-loop output type to use for the steer motor.
 

Friends

class SwerveDrivetrainImpl
 

Detailed Description

Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices.

This class handles the hardware devices but does not configure them for swerve module operation using the Phoenix 6 API. Users should create a high-level SwerveModule instead of using this directly.

Constructor & Destructor Documentation

◆ SwerveModuleImpl()

template<typename DriveMotorConfigsT , typename SteerMotorConfigsT , typename EncoderConfigsT >
ctre::phoenix6::swerve::impl::SwerveModuleImpl::SwerveModuleImpl ( SwerveModuleConstants< DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT > const & constants,
CANBus canbus )

Construct a SwerveModuleImpl with the specified constants.

Parameters
constantsConstants used to construct the module
canbusThe CAN bus this module is on

◆ ~SwerveModuleImpl()

ctre::phoenix6::swerve::impl::SwerveModuleImpl::~SwerveModuleImpl ( )

Member Function Documentation

◆ Apply() [1/2]

template<typename DriveReq , typename SteerReq >
void ctre::phoenix6::swerve::impl::SwerveModuleImpl::Apply ( DriveReq && driveRequest,
SteerReq && steerRequest )
inline

Controls this module using the specified drive and steer control requests.

This is intended only to be used for characterization of the robot; do not use this for normal use.

Parameters
driveRequestThe control request to apply to the drive motor
steerRequestThe control request to apply to the steer motor

◆ Apply() [2/2]

void ctre::phoenix6::swerve::impl::SwerveModuleImpl::Apply ( ModuleRequest const & moduleRequest)

Applies the desired ModuleRequest to this module.

Parameters
moduleRequestThe request to apply to this module

◆ ConfigNeutralMode()

ctre::phoenix::StatusCode ctre::phoenix6::swerve::impl::SwerveModuleImpl::ConfigNeutralMode ( signals::NeutralModeValue neutralMode,
units::second_t timeoutSeconds = 0.100_s )

Configures the neutral mode to use for the module's drive motor.

Parameters
neutralModeThe drive motor neutral mode
timeoutSecondsMaximum amount of time to wait when performing configuration
Returns
Status code response of the request

◆ GetCachedPosition()

SwerveModulePosition ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetCachedPosition ( ) const
inline

Gets the last cached swerve module position.

This differs from GetPosition in that it will not perform any latency compensation or refresh the signals.

Returns
Last cached SwerveModulePosition

◆ GetCurrentState()

SwerveModuleState ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetCurrentState ( ) const
inline

Get the current state of the module.

This is typically used for telemetry, as the SwerveModulePosition is used for odometry.

Returns
Current state of the module

◆ GetDriveClosedLoopOutputType()

ClosedLoopOutputType ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetDriveClosedLoopOutputType ( ) const
inline

Gets the closed-loop output type to use for the drive motor.

Returns
Drive motor closed-loop output type

◆ GetPosition()

SwerveModulePosition ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetPosition ( bool refresh)

Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values.

This function is blocking when it performs a refresh.

Parameters
refreshTrue if the signals should be refreshed
Returns
SwerveModulePosition containing this module's state.

◆ GetSteerClosedLoopOutputType()

ClosedLoopOutputType ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetSteerClosedLoopOutputType ( ) const
inline

Gets the closed-loop output type to use for the steer motor.

Returns
Steer motor closed-loop output type

◆ GetTargetState()

SwerveModuleState ctre::phoenix6::swerve::impl::SwerveModuleImpl::GetTargetState ( ) const
inline

Get the target state of the module.

This is typically used for telemetry.

Returns
Target state of the module

◆ ResetPosition()

void ctre::phoenix6::swerve::impl::SwerveModuleImpl::ResetPosition ( )
inline

Resets this module's drive motor position to 0 rotations.

Friends And Related Symbol Documentation

◆ SwerveDrivetrainImpl

friend class SwerveDrivetrainImpl
friend

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