Swerve Module class that encapsulates a swerve module powered by CTR Electronics devices.
More...
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::SwerveModule< DriveMotorT, SteerMotorT, EncoderT, typename, typename, typename >
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.
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> >>>
Contains everything the swerve module needs to apply a request.
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 DriveReq , typename SteerReq >
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
-
driveRequest | The control request to apply to the drive motor |
steerRequest | The control request to apply to the steer motor |
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> >>>
Applies the desired ModuleRequest to this module.
- Parameters
-
moduleRequest | The request to apply to this module |
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> >>>
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
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> >>>
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
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> >>>
Gets the closed-loop output type to use for the drive motor.
- Returns
- Drive motor closed-loop output type
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> >>>
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.
- Returns
- This module's Drive Motor reference
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> >>>
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.
- Returns
- This module's azimuth encoder reference
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> >>>
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
-
refresh | True if the signals should be refreshed |
- Returns
- SwerveModulePosition containing this module's state.
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> >>>
Gets the closed-loop output type to use for the steer motor.
- Returns
- Steer motor closed-loop output type
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> >>>
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.
- Returns
- This module's Steer Motor reference
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> >>>
Get the target state of the module.
This is typically used for telemetry.
- Returns
- Target state of the module
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> >>>
Resets this module's drive motor position to 0 rotations.
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> >>>
The underlying swerve module instance.
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> >>>
Number of times to attempt config applies.