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/SwerveModule.hpp>
Public Types | |
using | SteerRequestType = impl::SwerveModuleImpl::SteerRequestType |
All possible control requests for the module steer motor. More... | |
using | DriveRequestType = impl::SwerveModuleImpl::DriveRequestType |
All possible control requests for the module drive motor. More... | |
Public Member Functions | |
SwerveModule (SwerveModuleConstants const &constants, std::string_view canbusName, impl::SwerveModuleImpl &module) | |
Construct a SwerveModule with the specified constants. More... | |
virtual | ~SwerveModule ()=default |
void | Apply (impl::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... | |
impl::SwerveModulePosition | GetPosition (bool refresh) |
Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values. More... | |
impl::SwerveModulePosition | GetCachedPosition () const |
Gets the last cached swerve module position. More... | |
impl::SwerveModuleState | GetCurrentState () const |
Get the current state of the module. More... | |
impl::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::TalonFX & | GetDriveMotor () |
Gets this module's Drive Motor TalonFX reference. More... | |
hardware::TalonFX & | GetSteerMotor () |
Gets this module's Steer Motor TalonFX reference. More... | |
hardware::CANcoder & | GetCANcoder () |
Gets this module's CANcoder reference. More... | |
Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices.
This class handles the hardware devices and configures them for swerve module operation using the Phoenix 6 API.
This class constructs hardware devices internally, so the user only specifies the constants (IDs, PID gains, gear ratios, etc). Getters for these hardware devices are available.
using ctre::phoenix6::swerve::SwerveModule::DriveRequestType = impl::SwerveModuleImpl::DriveRequestType |
All possible control requests for the module drive motor.
using ctre::phoenix6::swerve::SwerveModule::SteerRequestType = impl::SwerveModuleImpl::SteerRequestType |
All possible control requests for the module steer motor.
ctre::phoenix6::swerve::SwerveModule::SwerveModule | ( | SwerveModuleConstants const & | constants, |
std::string_view | canbusName, | ||
impl::SwerveModuleImpl & | module | ||
) |
Construct a SwerveModule with the specified constants.
constants | Constants used to construct the module |
canbusName | The name of the CAN bus this module is on |
module | The impl::SwerveModuleImpl to use |
|
virtualdefault |
|
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 |
|
inline |
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 |
|
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.
|
inline |
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.