|
CTRE Phoenix 6 C++ 26.0.0-beta-1
|
Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices. More...
#include <ctre/phoenix6/swerve/SwerveModule.hpp>
Public Types | |
| using | ModuleRequest = impl::SwerveModuleImpl::ModuleRequest |
| Contains everything the swerve module needs to apply a request. | |
Public Member Functions | |
| SwerveModule (SwerveModuleConstants< typename DriveMotorT::Configuration, typename SteerMotorT::Configuration, typename EncoderT::Configuration > const &constants, CANBus canbus, impl::SwerveModuleImpl &module) | |
| Construct a SwerveModule with the specified constants. | |
| virtual | ~SwerveModule ()=default |
| virtual void | Apply (ModuleRequest const &moduleRequest) |
| Applies the desired ModuleRequest to this module. | |
| template<std::derived_from< controls::ControlRequest > DriveReq, std::derived_from< controls::ControlRequest > SteerReq> | |
| void | Apply (DriveReq &&driveRequest, SteerReq &&steerRequest) |
| Controls this module using the specified drive and steer control requests. | |
| 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. | |
| virtual 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. | |
| DriveMotorT & | GetDriveMotor () |
| Gets this module's Drive Motor reference. | |
| DriveMotorT const & | GetDriveMotor () const |
| Gets this module's Drive Motor reference. | |
| SteerMotorT & | GetSteerMotor () |
| Gets this module's Steer Motor reference. | |
| SteerMotorT const & | GetSteerMotor () const |
| Gets this module's Steer Motor reference. | |
| EncoderT & | GetEncoder () |
| Gets this module's azimuth encoder reference. | |
| EncoderT const & | GetEncoder () const |
| Gets this module's azimuth encoder reference. | |
Protected Attributes | |
| impl::SwerveModuleImpl * | _module |
| The underlying swerve module instance. | |
Static Protected Attributes | |
| static constexpr int | kNumConfigAttempts = 2 |
| Number of times to attempt config applies. | |
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< DriveMotorT, SteerMotorT, EncoderT >::ModuleRequest = impl::SwerveModuleImpl::ModuleRequest |
Contains everything the swerve module needs to apply a request.
|
inline |
Construct a SwerveModule with the specified constants.
| constants | Constants used to construct the module |
| canbus | 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 |
|
inlinevirtual |
Applies the desired ModuleRequest to this module.
| moduleRequest | The request to apply to this module |
|
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 |
Get the current state of the module.
This is typically used for telemetry, as the SwerveModulePosition is used for odometry.
|
inline |
Gets the closed-loop output type to use for the drive motor.
|
inline |
Gets this module's Drive Motor reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Gets this module's Drive Motor reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Gets this module's azimuth encoder reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Gets this module's azimuth encoder 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.
This function is blocking when it performs a refresh.
| refresh | True if the signals should be refreshed |
|
inline |
Gets the closed-loop output type to use for the steer motor.
|
inline |
Gets this module's Steer Motor reference.
This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself.
|
inline |
Gets this module's Steer Motor 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.
|
inlinevirtual |
Resets this module's drive motor position to 0 rotations.
|
protected |
The underlying swerve module instance.
|
staticconstexprprotected |
Number of times to attempt config applies.