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

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

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

Public Member Functions

ModuleRequestWithState (SwerveModuleState newState)
 Modifies the State parameter and returns itself.
 
ModuleRequestWithWheelForceFeedforwardX (units::newton_t newWheelForceFeedforwardX)
 Modifies the WheelForceFeedforwardX parameter and returns itself.
 
ModuleRequestWithWheelForceFeedforwardY (units::newton_t newWheelForceFeedforwardY)
 Modifies the WheelForceFeedforwardY parameter and returns itself.
 
ModuleRequestWithDriveRequest (DriveRequestType newDriveRequest)
 Modifies the DriveRequest parameter and returns itself.
 
ModuleRequestWithSteerRequest (SteerRequestType newSteerRequest)
 Modifies the SteerRequest parameter and returns itself.
 
ModuleRequestWithUpdatePeriod (units::second_t newUpdatePeriod)
 Modifies the UpdatePeriod parameter and returns itself.
 
ModuleRequestWithEnableFOC (bool newEnableFOC)
 Modifies the EnableFOC parameter and returns itself.
 

Public Attributes

SwerveModuleState State {}
 Unoptimized speed and direction the module should target.
 
units::newton_t WheelForceFeedforwardX = 0_N
 Robot-centric wheel force feedforward to apply in the X direction.
 
units::newton_t WheelForceFeedforwardY = 0_N
 Robot-centric wheel force feedforward to apply in the Y direction.
 
DriveRequestType DriveRequest = DriveRequestType::OpenLoopVoltage
 The type of control request to use for the drive motor.
 
SteerRequestType SteerRequest = SteerRequestType::Position
 The type of control request to use for the steer motor.
 
units::second_t UpdatePeriod = 0_s
 The update period of the module request.
 
bool EnableFOC = true
 When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
 

Detailed Description

Contains everything the swerve module needs to apply a request.

Member Function Documentation

◆ WithDriveRequest()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithDriveRequest ( DriveRequestType newDriveRequest)
inline

Modifies the DriveRequest parameter and returns itself.

The type of control request to use for the drive motor.

Parameters
newDriveRequestParameter to modify
Returns
Itself

◆ WithEnableFOC()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithEnableFOC ( bool newEnableFOC)
inline

Modifies the EnableFOC parameter and returns itself.

When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%. Set to false to use trapezoidal commutation. This is ignored when using Torque-based control, which always uses FOC.

FOC improves motor performance by leveraging torque (current) control. However, this may be inconvenient for applications that require specifying duty cycle or voltage. CTR-Electronics has developed a hybrid method that combines the performances gains of FOC while still allowing applications to provide duty cycle or voltage demand. This not to be confused with simple sinusoidal control or phase voltage control which lacks the performance gains.

Parameters
newEnableFOCParameter to modify
Returns
Itself

◆ WithState()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithState ( SwerveModuleState newState)
inline

Modifies the State parameter and returns itself.

Unoptimized speed and direction the module should target.

Parameters
newStateParameter to modify
Returns
Itself

◆ WithSteerRequest()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithSteerRequest ( SteerRequestType newSteerRequest)
inline

Modifies the SteerRequest parameter and returns itself.

The type of control request to use for the steer motor.

Parameters
newSteerRequestParameter to modify
Returns
Itself

◆ WithUpdatePeriod()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithUpdatePeriod ( units::second_t newUpdatePeriod)
inline

Modifies the UpdatePeriod parameter and returns itself.

The update period of the module request. Setting this to a non-zero value adds a velocity feedforward to the steer motor.

Parameters
newUpdatePeriodParameter to modify
Returns
Itself

◆ WithWheelForceFeedforwardX()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithWheelForceFeedforwardX ( units::newton_t newWheelForceFeedforwardX)
inline

Modifies the WheelForceFeedforwardX parameter and returns itself.

Robot-centric wheel force feedforward to apply in the X direction. X is defined as forward according to WPILib convention, so this determines the forward force to apply.

This force should include friction.

Parameters
newWheelForceFeedforwardXParameter to modify
Returns
Itself

◆ WithWheelForceFeedforwardY()

ModuleRequest & ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WithWheelForceFeedforwardY ( units::newton_t newWheelForceFeedforwardY)
inline

Modifies the WheelForceFeedforwardY parameter and returns itself.

Robot-centric wheel force feedforward to apply in the Y direction. Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.

This force should include friction.

Parameters
newWheelForceFeedforwardYParameter to modify
Returns
Itself

Member Data Documentation

◆ DriveRequest

DriveRequestType ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::DriveRequest = DriveRequestType::OpenLoopVoltage

The type of control request to use for the drive motor.

◆ EnableFOC

bool ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::EnableFOC = true

When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.

Set to false to use trapezoidal commutation. This is ignored when using Torque-based control, which always uses FOC.

FOC improves motor performance by leveraging torque (current) control. However, this may be inconvenient for applications that require specifying duty cycle or voltage. CTR-Electronics has developed a hybrid method that combines the performances gains of FOC while still allowing applications to provide duty cycle or voltage demand. This not to be confused with simple sinusoidal control or phase voltage control which lacks the performance gains.

◆ State

SwerveModuleState ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::State {}

Unoptimized speed and direction the module should target.

◆ SteerRequest

SteerRequestType ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::SteerRequest = SteerRequestType::Position

The type of control request to use for the steer motor.

◆ UpdatePeriod

units::second_t ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::UpdatePeriod = 0_s

The update period of the module request.

Setting this to a non-zero value adds a velocity feedforward to the steer motor.

◆ WheelForceFeedforwardX

units::newton_t ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WheelForceFeedforwardX = 0_N

Robot-centric wheel force feedforward to apply in the X direction.

X is defined as forward according to WPILib convention, so this determines the forward force to apply.

This force should include friction applied to the ground.

◆ WheelForceFeedforwardY

units::newton_t ctre::phoenix6::swerve::impl::SwerveModuleImpl::ModuleRequest::WheelForceFeedforwardY = 0_N

Robot-centric wheel force feedforward to apply in the Y direction.

Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.

This force should include friction applied to the ground.


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