CTRE Phoenix 6 C++ 24.50.0-alpha-2
|
Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices. More...
#include <ctre/phoenix6/swerve/impl/SwerveModuleImpl.hpp>
Public Types | |
enum class | SteerRequestType { MotionMagicExpo = 0 , Position = 1 } |
All possible control requests for the module steer motor. More... | |
enum class | DriveRequestType { OpenLoopVoltage = 0 , Velocity = 1 } |
All possible control requests for the module drive motor. More... | |
Public Member Functions | |
SwerveModuleImpl (SwerveModuleConstants const &constants, CANBus canbus) | |
Construct a SwerveModuleImpl with the specified constants. More... | |
void | Apply (SwerveModuleState const &state, DriveRequestType driveRequestType, SteerRequestType steerRequestType=SteerRequestType::MotionMagicExpo) |
Applies the desired SwerveModuleState to this module. More... | |
template<typename DriveReq , typename SteerReq > | |
void | Apply (DriveReq &&driveRequest, SteerReq &&steerRequest) |
Controls this module using the specified drive and steer control requests. More... | |
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. More... | |
SwerveModulePosition | GetPosition (bool refresh) |
Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values. More... | |
SwerveModulePosition | GetCachedPosition () const |
Gets the last cached swerve module position. More... | |
SwerveModuleState | GetCurrentState () const |
Get the current state of the module. More... | |
SwerveModuleState | GetTargetState () const |
Get the target state of the module. More... | |
void | ResetPosition () |
Resets this module's drive motor position to 0 rotations. More... | |
hardware::core::CoreTalonFX & | GetDriveMotor () |
Gets this module's Drive Motor TalonFX reference. More... | |
hardware::core::CoreTalonFX & | GetSteerMotor () |
Gets this module's Steer Motor TalonFX reference. More... | |
hardware::core::CoreCANcoder & | GetCANcoder () |
Gets this module's CANcoder reference. More... | |
Friends | |
class | SwerveDrivetrainImpl |
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.
|
strong |
All possible control requests for the module drive motor.
Enumerator | |
---|---|
OpenLoopVoltage | Control the drive motor using an open-loop voltage request. |
Velocity | Control the drive motor using a velocity closed-loop request. The control output type is determined by SwerveModuleConstants::DriveMotorClosedLoopOutput. |
|
strong |
All possible control requests for the module steer motor.
Enumerator | |
---|---|
MotionMagicExpo | Control the drive motor using a Motion MagicĀ® Expo request. The control output type is determined by SwerveModuleConstants::SteerMotorClosedLoopOutput. |
Position | Control the drive motor using an unprofiled position request. The control output type is determined by SwerveModuleConstants::SteerMotorClosedLoopOutput. |
ctre::phoenix6::swerve::impl::SwerveModuleImpl::SwerveModuleImpl | ( | SwerveModuleConstants const & | constants, |
CANBus | canbus | ||
) |
Construct a SwerveModuleImpl with the specified constants.
constants | Constants used to construct the module |
canbus | The CAN bus this module is on |
|
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.
driveRequest | The control request to apply to the drive motor |
steerRequest | The control request to apply to the steer motor |
void ctre::phoenix6::swerve::impl::SwerveModuleImpl::Apply | ( | SwerveModuleState const & | state, |
DriveRequestType | driveRequestType, | ||
SteerRequestType | steerRequestType = SteerRequestType::MotionMagicExpo |
||
) |
Applies the desired SwerveModuleState to this module.
state | Speed and direction the module should target |
driveRequestType | The DriveRequestType to apply |
steerRequestType | The SteerRequestType to apply; defaults to SteerRequestType::MotionMagicExpo |
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.
neutralMode | The drive motor neutral mode |
timeoutSeconds | Maximum amount of time to wait when performing configuration |
|
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.
|
inline |
Gets this module's CANcoder reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Get the current state of the module.
This is typically used for telemetry, as the SwerveModulePosition is used for odometry.
|
inline |
Gets this module's Drive Motor TalonFX reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
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.
refresh | True if the signals should be refreshed |
|
inline |
Gets this module's Steer Motor TalonFX reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Get the target state of the module.
This is typically used for telemetry.
|
inline |
Resets this module's drive motor position to 0 rotations.
|
friend |