Class SwerveModule.ModuleRequest

java.lang.Object
com.ctre.phoenix6.swerve.SwerveModule.ModuleRequest
Enclosing class:
SwerveModule<DriveMotorT extends CommonTalon,SteerMotorT extends CommonTalon,EncoderT extends ParentDevice>

public static class SwerveModule.ModuleRequest extends Object
Contains everything the swerve module needs to apply a request.
  • Field Details

    • State

      Unoptimized speed and direction the module should target.
    • WheelForceFeedforwardX

      public double WheelForceFeedforwardX
      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.

    • WheelForceFeedforwardY

      public double WheelForceFeedforwardY
      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.

    • DriveRequest

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

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

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

      public boolean EnableFOC
      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.

  • Constructor Details

  • Method Details

    • withState

      Modifies the State parameter and returns itself.

      Unoptimized speed and direction the module should target.

      Parameters:
      newState - Parameter to modify
      Returns:
      Itself
    • withWheelForceFeedforwardX

      public SwerveModule.ModuleRequest withWheelForceFeedforwardX(double newWheelForceFeedforwardX)
      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 applied to the ground.

      Parameters:
      newWheelForceFeedforwardX - Parameter to modify
      Returns:
      Itself
    • withWheelForceFeedforwardX

      public SwerveModule.ModuleRequest withWheelForceFeedforwardX(Force newWheelForceFeedforwardX)
      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 applied to the ground.

      Parameters:
      newWheelForceFeedforwardX - Parameter to modify
      Returns:
      Itself
    • getWheelForceFeedforwardXMeasure

      Helper method to get the WheelForceFeedforwardX parameter as a unit type. If not using the Java units library, WheelForceFeedforwardX can be accessed directly instead.

      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.

      Returns:
      WheelForceFeedforwardX
    • withWheelForceFeedforwardY

      public SwerveModule.ModuleRequest withWheelForceFeedforwardY(double newWheelForceFeedforwardY)
      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 applied to the ground.

      Parameters:
      newWheelForceFeedforwardY - Parameter to modify
      Returns:
      Itself
    • withWheelForceFeedforwardY

      public SwerveModule.ModuleRequest withWheelForceFeedforwardY(Force newWheelForceFeedforwardY)
      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 applied to the ground.

      Parameters:
      newWheelForceFeedforwardY - Parameter to modify
      Returns:
      Itself
    • getWheelForceFeedforwardYMeasure

      Helper method to get the WheelForceFeedforwardY parameter as a unit type. If not using the Java units library, WheelForceFeedforwardY can be accessed directly instead.

      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.

      Returns:
      WheelForceFeedforwardY
    • withDriveRequest

      Modifies the DriveRequest parameter and returns itself.

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

      Parameters:
      newDriveRequest - Parameter to modify
      Returns:
      Itself
    • withSteerRequest

      Modifies the SteerRequest parameter and returns itself.

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

      Parameters:
      newSteerRequest - Parameter to modify
      Returns:
      Itself
    • withUpdatePeriod

      public SwerveModule.ModuleRequest withUpdatePeriod(double newUpdatePeriod)
      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:
      newUpdatePeriod - Parameter to modify
      Returns:
      Itself
    • withEnableFOC

      public SwerveModule.ModuleRequest withEnableFOC(boolean newEnableFOC)
      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:
      newEnableFOC - Parameter to modify
      Returns:
      Itself