:py:mod:`phoenix6.swerve` ========================= .. py:module:: phoenix6.swerve Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 utility/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 requests/index.rst sim_swerve_drivetrain/index.rst swerve_drivetrain/index.rst swerve_drivetrain_constants/index.rst swerve_module/index.rst swerve_module_constants/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: phoenix6.swerve.lerp .. py:function:: lerp(startValue, endValue, t: phoenix6.units.second) .. py:class:: Rotation2d Rotation2d(value: phoenix6.units.radian) Rotation2d(x: float, y: float) .. py:method:: fromDegrees(value: phoenix6.units.degree) -> Rotation2d :staticmethod: .. py:method:: fromRotations(value: phoenix6.units.rotation) -> Rotation2d :staticmethod: .. py:method:: radians() -> phoenix6.units.radian .. py:method:: degrees() -> phoenix6.units.degree .. py:method:: rotations() -> phoenix6.units.rotation .. py:method:: cos() -> float .. py:method:: sin() -> float .. py:method:: tan() -> float .. py:method:: rotateBy(other: Rotation2d) -> Rotation2d .. py:class:: SwerveModuleState(speed: phoenix6.units.meters_per_second = 0, angle: Rotation2d = Rotation2d()) .. py:method:: optimize(desiredState: SwerveModuleState, currentAngle: Rotation2d) -> SwerveModuleState :staticmethod: .. py:class:: SwerveDrivetrainConstants Common constants for a swerve drivetrain. .. py:attribute:: can_bus_name :type: str :value: 'rio' Name of the CAN bus the swerve drive is on. Possible CAN bus strings are: - empty string or "rio" for the native roboRIO CAN bus - CANivore name or serial number - "*" for any CANivore seen by the program Note that all devices must be on the same CAN bus. .. py:attribute:: pigeon2_id :type: int :value: 0 CAN ID of the Pigeon2 on the drivetrain. .. py:attribute:: pigeon2_configs :type: None | phoenix6.configs.Pigeon2Configuration The configuration object to apply to the Pigeon2. This defaults to null. If this remains null, then the Pigeon2 will not be configured (and whatever configs are on it remain on it). If this is not null, the Pigeon2 will be overwritten with these configs. .. py:method:: with_can_bus_name(new_can_bus_name: str) -> SwerveDrivetrainConstants Modifies the can_bus_name parameter and returns itself. Name of the CAN bus the swerve drive is on. Possible CAN bus strings are: - empty string or "rio" for the native roboRIO CAN bus - CANivore name or serial number - "*" for any CANivore seen by the program Note that all devices must be on the same CAN bus. :param new_can_bus_name: Parameter to modify :type new_can_bus_name: str :returns: this object :rtype: SwerveDrivetrainConstants .. py:method:: with_pigeon2_id(new_pigeon2_id: int) -> SwerveDrivetrainConstants Modifies the pigeon2_id parameter and returns itself. CAN ID of the Pigeon2 on the drivetrain. :param new_pigeon2_id: Parameter to modify :type new_pigeon2_id: int :returns: this object :rtype: SwerveDrivetrainConstants .. py:method:: with_pigeon2_configs(new_pigeon2_configs: None | phoenix6.configs.Pigeon2Configuration) -> SwerveDrivetrainConstants Modifies the pigeon2_configs parameter and returns itself. The configuration object to apply to the Pigeon2. This defaults to null. If this remains null, then the Pigeon2 will not be configured (and whatever configs are on it remain on it). If this is not null, the Pigeon2 will be overwritten with these configs. :param new_pigeon2_configs: Parameter to modify :type new_pigeon2_configs: None | Pigeon2Configuration :returns: this object :rtype: SwerveDrivetrainConstants .. py:class:: ClosedLoopOutputType(*args, **kwds) Bases: :py:obj:`enum.Enum` Supported closed-loop output types. .. py:attribute:: VOLTAGE :value: 0 .. py:attribute:: TORQUE_CURRENT_FOC :value: 1 Requires Pro .. py:class:: DriveMotorArrangement(*args, **kwds) Bases: :py:obj:`enum.Enum` Supported motor arrangements for the drive motors. .. py:attribute:: TALON_FX_INTEGRATED :value: 0 Talon FX integrated brushless motor. .. py:attribute:: TALON_FXS_NEO_JST :value: 1 Third party NEO brushless motor connected to a Talon FXS over JST. .. py:attribute:: TALON_FXS_VORTEX_JST :value: 2 Third party VORTEX brushless motor connected to a Talon FXS over JST. .. py:class:: SteerFeedbackType(*args, **kwds) Bases: :py:obj:`enum.Enum` Supported feedback sensors for the steer motors. .. py:attribute:: FUSED_CANCODER :value: 0 Requires Pro; Use FeedbackSensorSourceValue.FUSED_CANCODER for the steer motor. .. py:attribute:: SYNC_CANCODER :value: 1 Requires Pro; Use FeedbackSensorSourceValue.SYNC_CANCODER for the steer motor. .. py:attribute:: REMOTE_CANCODER :value: 2 Use FeedbackSensorSourceValue.REMOTE_CANCODER for the steer motor. .. py:attribute:: FUSED_CANDI_PWM1 :value: 3 Requires Pro; Use FeedbackSensorSourceValue.FUSED_CANDI_PWM1 for the steer motor. .. py:attribute:: FUSED_CANDI_PWM2 :value: 4 Requires Pro; Use FeedbackSensorSourceValue.FUSED_CANDI_PWM2 for the steer motor. .. py:attribute:: SYNC_CANDI_PWM1 :value: 5 Requires Pro; Use FeedbackSensorSourceValue.SYNC_CANDI_PWM1 for the steer motor. .. py:attribute:: SYNC_CANDI_PWM2 :value: 6 Requires Pro; Use FeedbackSensorSourceValue.SYNC_CANDI_PWM2 for the steer motor. .. py:attribute:: REMOTE_CANDI_PWM1 :value: 7 Use FeedbackSensorSourceValue.REMOTE_CANDI_PWM1 for the steer motor. .. py:attribute:: REMOTE_CANDI_PWM2 :value: 8 Use FeedbackSensorSourceValue.REMOTE_CANDI_PWM2 for the steer motor. .. py:attribute:: TALON_FXS_PULSE_WIDTH :value: 9 Use ExternalFeedbackSensorSourceValue.PULSE_WIDTH for the steer motor. This requires Talon FXS. .. py:class:: SteerMotorArrangement(*args, **kwds) Bases: :py:obj:`enum.Enum` Supported motor arrangements for the steer motors. .. py:attribute:: TALON_FX_INTEGRATED :value: 0 Talon FX integrated brushless motor. .. py:attribute:: TALON_FXS_MINION_JST :value: 1 CTR Electronics Minion® brushless motor connected to a Talon FXS over JST. .. py:attribute:: TALON_FXS_NEO_JST :value: 2 Third party NEO brushless motor connected to a Talon FXS over JST. .. py:attribute:: TALON_FXS_VORTEX_JST :value: 3 Third party VORTEX brushless motor connected to a Talon FXS over JST. .. py:attribute:: TALON_FXS_NEO550_JST :value: 4 Third party NEO550 brushless motor connected to a Talon FXS over JST. .. py:attribute:: TALON_FXS_BRUSHED_AB :value: 5 Brushed motor connected to a Talon FXS on terminals A and B. .. py:attribute:: TALON_FXS_BRUSHED_AC :value: 6 Brushed motor connected to a Talon FXS on terminals A and C. .. py:attribute:: TALON_FXS_BRUSHED_BC :value: 7 Brushed motor connected to a Talon FXS on terminals B and C. .. py:class:: SwerveModuleConstants Bases: :py:obj:`Generic`\ [\ :py:obj:`DriveMotorConfigsT`\ , :py:obj:`SteerMotorConfigsT`\ , :py:obj:`EncoderConfigsT`\ ] All constants for a swerve module. .. py:attribute:: steer_motor_id :type: int :value: 0 CAN ID of the steer motor. .. py:attribute:: drive_motor_id :type: int :value: 0 CAN ID of the drive motor. .. py:attribute:: encoder_id :type: int :value: 0 CAN ID of the absolute encoder used for azimuth. .. py:attribute:: encoder_offset :type: phoenix6.units.rotation :value: 0 Offset of the azimuth encoder. .. py:attribute:: location_x :type: phoenix6.units.meter :value: 0 The location of this module's wheels relative to the physical center of the robot in meters along the X axis of the robot. .. py:attribute:: location_y :type: phoenix6.units.meter :value: 0 The location of this module's wheels relative to the physical center of the robot in meters along the Y axis of the robot. .. py:attribute:: drive_motor_inverted :type: bool :value: False True if the drive motor is inverted. .. py:attribute:: steer_motor_inverted :type: bool :value: False True if the steer motor is inverted from the azimuth. The azimuth should rotate counter-clockwise (as seen from the top of the robot) for a positive motor output. .. py:attribute:: encoder_inverted :type: bool :value: False True if the azimuth encoder is inverted from the azimuth. The encoder should report a positive velocity when the azimuth rotates counter-clockwise (as seen from the top of the robot). .. py:attribute:: drive_motor_gear_ratio :type: float :value: 0 Gear ratio between the drive motor and the wheel. .. py:attribute:: steer_motor_gear_ratio :type: float :value: 0 Gear ratio between the steer motor and the azimuth encoder. For example, the SDS Mk4 has a steering ratio of 12.8. .. py:attribute:: coupling_gear_ratio :type: float :value: 0 Coupled gear ratio between the azimuth encoder and the drive motor. For a typical swerve module, the azimuth turn motor also drives the wheel a nontrivial amount, which affects the accuracy of odometry and control. This ratio represents the number of rotations of the drive motor caused by a rotation of the azimuth. .. py:attribute:: wheel_radius :type: phoenix6.units.meter :value: 0 Radius of the driving wheel in meters. .. py:attribute:: steer_motor_gains :type: phoenix6.configs.Slot0Configs The steer motor closed-loop gains. The steer motor uses the control ouput type specified by SteerMotorClosedLoopOutput and any SwerveModule.SteerRequestType. These gains operate on azimuth rotations (after the gear ratio). .. py:attribute:: drive_motor_gains :type: phoenix6.configs.Slot0Configs The drive motor closed-loop gains. When using closed-loop control, the drive motor uses the control output type specified by DriveMotorClosedLoopOutput and any closed-loop SwerveModule.DriveRequestType. These gains operate on motor rotor rotations (before the gear ratio). .. py:attribute:: steer_motor_closed_loop_output :type: ClosedLoopOutputType The closed-loop output type to use for the steer motors. .. py:attribute:: drive_motor_closed_loop_output :type: ClosedLoopOutputType The closed-loop output type to use for the drive motors. .. py:attribute:: slip_current :type: phoenix6.units.ampere :value: 120 The maximum amount of stator current the drive motors can apply without slippage. .. py:attribute:: speed_at12_volts :type: phoenix6.units.meters_per_second :value: 0 When using open-loop drive control, this specifies the speed at which the robot travels when driven with 12 volts. This is used to approximate the output for a desired velocity. If using closed loop control, this value is ignored. .. py:attribute:: drive_motor_type :type: DriveMotorArrangement Choose the motor used for the drive motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. .. py:attribute:: steer_motor_type :type: SteerMotorArrangement Choose the motor used for the steer motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. .. py:attribute:: feedback_source :type: SteerFeedbackType Choose how the feedback sensors should be configured. If the robot does not support Pro, then this should be set to RemoteCANcoder. Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder depending on if there is a risk that the CANcoder can fail in a way to provide "good" data. If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not Pro-licensed, the device will automatically fall back to RemoteCANcoder and report a UsingProFeatureOnUnlicensedDevice status code. .. py:attribute:: drive_motor_initial_configs :type: DriveMotorConfigsT The initial configs used to configure the drive motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode, overwritten with SwerveDrivetrain.config_neutral_mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.DriveMotorInverted) - Slot0Configs (SwerveModuleConstants.DriveMotorGains) - CurrentLimitsConfigs.StatorCurrentLimit / TorqueCurrentConfigs.PeakForwardTorqueCurrent / TorqueCurrentConfigs.PeakReverseTorqueCurrent (SwerveModuleConstants.SlipCurrent) - CurrentLimitsConfigs.StatorCurrentLimitEnable (Enabled) .. py:attribute:: steer_motor_initial_configs :type: SteerMotorConfigsT The initial configs used to configure the steer motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.SteerMotorInverted) - Slot0Configs (SwerveModuleConstants.SteerMotorGains) - FeedbackConfigs.FeedbackRemoteSensorID (SwerveModuleConstants.EncoderId) - FeedbackConfigs.FeedbackSensorSource (SwerveModuleConstants.FeedbackSource) - FeedbackConfigs.RotorToSensorRatio (SwerveModuleConstants.SteerMotorGearRatio) - MotionMagicConfigs.MotionMagicExpo_kV / MotionMagicConfigs.MotionMagicExpo_kA (Calculated from gear ratios) - ClosedLoopGeneralConfigs.ContinuousWrap (true) .. py:attribute:: encoder_initial_configs :type: EncoderConfigsT The initial configs used to configure the azimuth encoder of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. For CANcoder, the list of configs that will be overwritten is as follows: - MagnetSensorConfigs.MagnetOffset (SwerveModuleConstants.EncoderOffset) - MagnetSensorConfigs.SensorDirection (SwerveModuleConstants.EncoderInverted) .. py:attribute:: steer_inertia :type: phoenix6.units.kilogram_square_meter :value: 1e-05 Simulated azimuthal inertia. .. py:attribute:: drive_inertia :type: phoenix6.units.kilogram_square_meter :value: 0.001 Simulated drive inertia. .. py:attribute:: steer_friction_voltage :type: phoenix6.units.volt :value: 0.25 Simulated steer voltage required to overcome friction. .. py:attribute:: drive_friction_voltage :type: phoenix6.units.volt :value: 0.25 Simulated drive voltage required to overcome friction. .. py:method:: with_steer_motor_id(new_steer_motor_id: int) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_id parameter and returns itself. CAN ID of the steer motor. :param new_steer_motor_id: Parameter to modify :type new_steer_motor_id: int :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_id(new_drive_motor_id: int) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_id parameter and returns itself. CAN ID of the drive motor. :param new_drive_motor_id: Parameter to modify :type new_drive_motor_id: int :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_encoder_id(new_encoder_id: int) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the encoder_id parameter and returns itself. CAN ID of the absolute encoder used for azimuth. :param new_encoder_id: Parameter to modify :type new_encoder_id: int :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_encoder_offset(new_encoder_offset: phoenix6.units.rotation) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the encoder_offset parameter and returns itself. Offset of the azimuth encoder. :param new_encoder_offset: Parameter to modify :type new_encoder_offset: rotation :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_location_x(new_location_x: phoenix6.units.meter) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the location_x parameter and returns itself. The location of this module's wheels relative to the physical center of the robot in meters along the X axis of the robot. :param new_location_x: Parameter to modify :type new_location_x: meter :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_location_y(new_location_y: phoenix6.units.meter) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the location_y parameter and returns itself. The location of this module's wheels relative to the physical center of the robot in meters along the Y axis of the robot. :param new_location_y: Parameter to modify :type new_location_y: meter :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_inverted(new_drive_motor_inverted: bool) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_inverted parameter and returns itself. True if the drive motor is inverted. :param new_drive_motor_inverted: Parameter to modify :type new_drive_motor_inverted: bool :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_inverted(new_steer_motor_inverted: bool) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_inverted parameter and returns itself. True if the steer motor is inverted from the azimuth. The azimuth should rotate counter-clockwise (as seen from the top of the robot) for a positive motor output. :param new_steer_motor_inverted: Parameter to modify :type new_steer_motor_inverted: bool :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_encoder_inverted(new_encoder_inverted: bool) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the encoder_inverted parameter and returns itself. True if the azimuth encoder is inverted from the azimuth. The encoder should report a positive velocity when the azimuth rotates counter-clockwise (as seen from the top of the robot). :param new_encoder_inverted: Parameter to modify :type new_encoder_inverted: bool :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_gear_ratio(new_drive_motor_gear_ratio: float) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_gear_ratio parameter and returns itself. Gear ratio between the drive motor and the wheel. :param new_drive_motor_gear_ratio: Parameter to modify :type new_drive_motor_gear_ratio: float :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_gear_ratio(new_steer_motor_gear_ratio: float) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_gear_ratio parameter and returns itself. Gear ratio between the steer motor and the azimuth encoder. For example, the SDS Mk4 has a steering ratio of 12.8. :param new_steer_motor_gear_ratio: Parameter to modify :type new_steer_motor_gear_ratio: float :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_coupling_gear_ratio(new_coupling_gear_ratio: float) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the coupling_gear_ratio parameter and returns itself. Coupled gear ratio between the azimuth encoder and the drive motor. For a typical swerve module, the azimuth turn motor also drives the wheel a nontrivial amount, which affects the accuracy of odometry and control. This ratio represents the number of rotations of the drive motor caused by a rotation of the azimuth. :param new_coupling_gear_ratio: Parameter to modify :type new_coupling_gear_ratio: float :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_wheel_radius(new_wheel_radius: phoenix6.units.meter) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the wheel_radius parameter and returns itself. Radius of the driving wheel in meters. :param new_wheel_radius: Parameter to modify :type new_wheel_radius: meter :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_gains(new_steer_motor_gains: phoenix6.configs.Slot0Configs) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_gains parameter and returns itself. The steer motor closed-loop gains. The steer motor uses the control ouput type specified by SteerMotorClosedLoopOutput and any SwerveModule.SteerRequestType. These gains operate on azimuth rotations (after the gear ratio). :param new_steer_motor_gains: Parameter to modify :type new_steer_motor_gains: Slot0Configs :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_gains(new_drive_motor_gains: phoenix6.configs.Slot0Configs) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_gains parameter and returns itself. The drive motor closed-loop gains. When using closed-loop control, the drive motor uses the control output type specified by DriveMotorClosedLoopOutput and any closed-loop SwerveModule.DriveRequestType. These gains operate on motor rotor rotations (before the gear ratio). :param new_drive_motor_gains: Parameter to modify :type new_drive_motor_gains: Slot0Configs :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_closed_loop_output(new_steer_motor_closed_loop_output: ClosedLoopOutputType) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_closed_loop_output parameter and returns itself. The closed-loop output type to use for the steer motors. :param new_steer_motor_closed_loop_output: Parameter to modify :type new_steer_motor_closed_loop_output: ClosedLoopOutputType :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_closed_loop_output(new_drive_motor_closed_loop_output: ClosedLoopOutputType) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_closed_loop_output parameter and returns itself. The closed-loop output type to use for the drive motors. :param new_drive_motor_closed_loop_output: Parameter to modify :type new_drive_motor_closed_loop_output: ClosedLoopOutputType :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_slip_current(new_slip_current: phoenix6.units.ampere) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the slip_current parameter and returns itself. The maximum amount of stator current the drive motors can apply without slippage. :param new_slip_current: Parameter to modify :type new_slip_current: ampere :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_speed_at12_volts(new_speed_at12_volts: phoenix6.units.meters_per_second) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the speed_at12_volts parameter and returns itself. When using open-loop drive control, this specifies the speed at which the robot travels when driven with 12 volts. This is used to approximate the output for a desired velocity. If using closed loop control, this value is ignored. :param new_speed_at12_volts: Parameter to modify :type new_speed_at12_volts: meters_per_second :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_type(new_drive_motor_type: DriveMotorArrangement) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_type parameter and returns itself. Choose the motor used for the drive motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. :param new_drive_motor_type: Parameter to modify :type new_drive_motor_type: DriveMotorArrangement :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_type(new_steer_motor_type: SteerMotorArrangement) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_type parameter and returns itself. Choose the motor used for the steer motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. :param new_steer_motor_type: Parameter to modify :type new_steer_motor_type: SteerMotorArrangement :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_feedback_source(new_feedback_source: SteerFeedbackType) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the feedback_source parameter and returns itself. Choose how the feedback sensors should be configured. If the robot does not support Pro, then this should be set to RemoteCANcoder. Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder depending on if there is a risk that the CANcoder can fail in a way to provide "good" data. If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not Pro-licensed, the device will automatically fall back to RemoteCANcoder and report a UsingProFeatureOnUnlicensedDevice status code. :param new_feedback_source: Parameter to modify :type new_feedback_source: SteerFeedbackType :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_initial_configs(new_drive_motor_initial_configs: DriveMotorConfigsT) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_initial_configs parameter and returns itself. The initial configs used to configure the drive motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode, overwritten with SwerveDrivetrain.config_neutral_mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.DriveMotorInverted) - Slot0Configs (SwerveModuleConstants.DriveMotorGains) - CurrentLimitsConfigs.StatorCurrentLimit / TorqueCurrentConfigs.PeakForwardTorqueCurrent / TorqueCurrentConfigs.PeakReverseTorqueCurrent (SwerveModuleConstants.SlipCurrent) - CurrentLimitsConfigs.StatorCurrentLimitEnable (Enabled) :param new_drive_motor_initial_configs: Parameter to modify :type new_drive_motor_initial_configs: DriveMotorConfigsT :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_initial_configs(new_steer_motor_initial_configs: SteerMotorConfigsT) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_initial_configs parameter and returns itself. The initial configs used to configure the steer motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.SteerMotorInverted) - Slot0Configs (SwerveModuleConstants.SteerMotorGains) - FeedbackConfigs.FeedbackRemoteSensorID (SwerveModuleConstants.EncoderId) - FeedbackConfigs.FeedbackSensorSource (SwerveModuleConstants.FeedbackSource) - FeedbackConfigs.RotorToSensorRatio (SwerveModuleConstants.SteerMotorGearRatio) - MotionMagicConfigs.MotionMagicExpo_kV / MotionMagicConfigs.MotionMagicExpo_kA (Calculated from gear ratios) - ClosedLoopGeneralConfigs.ContinuousWrap (true) :param new_steer_motor_initial_configs: Parameter to modify :type new_steer_motor_initial_configs: SteerMotorConfigsT :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_encoder_initial_configs(new_encoder_initial_configs: EncoderConfigsT) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the encoder_initial_configs parameter and returns itself. The initial configs used to configure the azimuth encoder of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. For CANcoder, the list of configs that will be overwritten is as follows: - MagnetSensorConfigs.MagnetOffset (SwerveModuleConstants.EncoderOffset) - MagnetSensorConfigs.SensorDirection (SwerveModuleConstants.EncoderInverted) :param new_encoder_initial_configs: Parameter to modify :type new_encoder_initial_configs: EncoderConfigsT :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_inertia(new_steer_inertia: phoenix6.units.kilogram_square_meter) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_inertia parameter and returns itself. Simulated azimuthal inertia. :param new_steer_inertia: Parameter to modify :type new_steer_inertia: kilogram_square_meter :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_inertia(new_drive_inertia: phoenix6.units.kilogram_square_meter) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_inertia parameter and returns itself. Simulated drive inertia. :param new_drive_inertia: Parameter to modify :type new_drive_inertia: kilogram_square_meter :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_friction_voltage(new_steer_friction_voltage: phoenix6.units.volt) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_friction_voltage parameter and returns itself. Simulated steer voltage required to overcome friction. :param new_steer_friction_voltage: Parameter to modify :type new_steer_friction_voltage: volt :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_friction_voltage(new_drive_friction_voltage: phoenix6.units.volt) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_friction_voltage parameter and returns itself. Simulated drive voltage required to overcome friction. :param new_drive_friction_voltage: Parameter to modify :type new_drive_friction_voltage: volt :returns: this object :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:class:: SwerveModuleConstantsFactory Bases: :py:obj:`Generic`\ [\ :py:obj:`DriveMotorConfigsT`\ , :py:obj:`SteerMotorConfigsT`\ , :py:obj:`EncoderConfigsT`\ ] Constants that are common across the swerve modules, used for creating instances of module-specific SwerveModuleConstants. .. py:attribute:: drive_motor_gear_ratio :type: float :value: 0 Gear ratio between the drive motor and the wheel. .. py:attribute:: steer_motor_gear_ratio :type: float :value: 0 Gear ratio between the steer motor and the azimuth encoder. For example, the SDS Mk4 has a steering ratio of 12.8. .. py:attribute:: coupling_gear_ratio :type: float :value: 0 Coupled gear ratio between the azimuth encoder and the drive motor. For a typical swerve module, the azimuth turn motor also drives the wheel a nontrivial amount, which affects the accuracy of odometry and control. This ratio represents the number of rotations of the drive motor caused by a rotation of the azimuth. .. py:attribute:: wheel_radius :type: phoenix6.units.meter :value: 0 Radius of the driving wheel in meters. .. py:attribute:: steer_motor_gains :type: phoenix6.configs.Slot0Configs The steer motor closed-loop gains. The steer motor uses the control ouput type specified by SteerMotorClosedLoopOutput and any SwerveModule.SteerRequestType. These gains operate on azimuth rotations (after the gear ratio). .. py:attribute:: drive_motor_gains :type: phoenix6.configs.Slot0Configs The drive motor closed-loop gains. When using closed-loop control, the drive motor uses the control output type specified by DriveMotorClosedLoopOutput and any closed-loop SwerveModule.DriveRequestType. These gains operate on motor rotor rotations (before the gear ratio). .. py:attribute:: steer_motor_closed_loop_output :type: ClosedLoopOutputType The closed-loop output type to use for the steer motors. .. py:attribute:: drive_motor_closed_loop_output :type: ClosedLoopOutputType The closed-loop output type to use for the drive motors. .. py:attribute:: slip_current :type: phoenix6.units.ampere :value: 120 The maximum amount of stator current the drive motors can apply without slippage. .. py:attribute:: speed_at12_volts :type: phoenix6.units.meters_per_second :value: 0 When using open-loop drive control, this specifies the speed at which the robot travels when driven with 12 volts. This is used to approximate the output for a desired velocity. If using closed loop control, this value is ignored. .. py:attribute:: drive_motor_type :type: DriveMotorArrangement Choose the motor used for the drive motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. .. py:attribute:: steer_motor_type :type: SteerMotorArrangement Choose the motor used for the steer motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. .. py:attribute:: feedback_source :type: SteerFeedbackType Choose how the feedback sensors should be configured. If the robot does not support Pro, then this should be set to RemoteCANcoder. Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder depending on if there is a risk that the CANcoder can fail in a way to provide "good" data. If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not Pro-licensed, the device will automatically fall back to RemoteCANcoder and report a UsingProFeatureOnUnlicensedDevice status code. .. py:attribute:: drive_motor_initial_configs :type: DriveMotorConfigsT The initial configs used to configure the drive motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode, overwritten with SwerveDrivetrain.config_neutral_mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.DriveMotorInverted) - Slot0Configs (SwerveModuleConstants.DriveMotorGains) - CurrentLimitsConfigs.StatorCurrentLimit / TorqueCurrentConfigs.PeakForwardTorqueCurrent / TorqueCurrentConfigs.PeakReverseTorqueCurrent (SwerveModuleConstants.SlipCurrent) - CurrentLimitsConfigs.StatorCurrentLimitEnable (Enabled) .. py:attribute:: steer_motor_initial_configs :type: SteerMotorConfigsT The initial configs used to configure the steer motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.SteerMotorInverted) - Slot0Configs (SwerveModuleConstants.SteerMotorGains) - FeedbackConfigs.FeedbackRemoteSensorID (SwerveModuleConstants.EncoderId) - FeedbackConfigs.FeedbackSensorSource (SwerveModuleConstants.FeedbackSource) - FeedbackConfigs.RotorToSensorRatio (SwerveModuleConstants.SteerMotorGearRatio) - MotionMagicConfigs.MotionMagicExpo_kV / MotionMagicConfigs.MotionMagicExpo_kA (Calculated from gear ratios) - ClosedLoopGeneralConfigs.ContinuousWrap (true) .. py:attribute:: encoder_initial_configs :type: EncoderConfigsT The initial configs used to configure the azimuth encoder of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. For CANcoder, the list of configs that will be overwritten is as follows: - MagnetSensorConfigs.MagnetOffset (SwerveModuleConstants.EncoderOffset) - MagnetSensorConfigs.SensorDirection (SwerveModuleConstants.EncoderInverted) .. py:attribute:: steer_inertia :type: phoenix6.units.kilogram_square_meter :value: 1e-05 Simulated azimuthal inertia. .. py:attribute:: drive_inertia :type: phoenix6.units.kilogram_square_meter :value: 0.001 Simulated drive inertia. .. py:attribute:: steer_friction_voltage :type: phoenix6.units.volt :value: 0.25 Simulated steer voltage required to overcome friction. .. py:attribute:: drive_friction_voltage :type: phoenix6.units.volt :value: 0.25 Simulated drive voltage required to overcome friction. .. py:method:: with_drive_motor_gear_ratio(new_drive_motor_gear_ratio: float) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_gear_ratio parameter and returns itself. Gear ratio between the drive motor and the wheel. :param new_drive_motor_gear_ratio: Parameter to modify :type new_drive_motor_gear_ratio: float :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_gear_ratio(new_steer_motor_gear_ratio: float) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_gear_ratio parameter and returns itself. Gear ratio between the steer motor and the azimuth encoder. For example, the SDS Mk4 has a steering ratio of 12.8. :param new_steer_motor_gear_ratio: Parameter to modify :type new_steer_motor_gear_ratio: float :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_coupling_gear_ratio(new_coupling_gear_ratio: float) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the coupling_gear_ratio parameter and returns itself. Coupled gear ratio between the azimuth encoder and the drive motor. For a typical swerve module, the azimuth turn motor also drives the wheel a nontrivial amount, which affects the accuracy of odometry and control. This ratio represents the number of rotations of the drive motor caused by a rotation of the azimuth. :param new_coupling_gear_ratio: Parameter to modify :type new_coupling_gear_ratio: float :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_wheel_radius(new_wheel_radius: phoenix6.units.meter) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the wheel_radius parameter and returns itself. Radius of the driving wheel in meters. :param new_wheel_radius: Parameter to modify :type new_wheel_radius: meter :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_gains(new_steer_motor_gains: phoenix6.configs.Slot0Configs) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_gains parameter and returns itself. The steer motor closed-loop gains. The steer motor uses the control ouput type specified by SteerMotorClosedLoopOutput and any SwerveModule.SteerRequestType. These gains operate on azimuth rotations (after the gear ratio). :param new_steer_motor_gains: Parameter to modify :type new_steer_motor_gains: Slot0Configs :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_gains(new_drive_motor_gains: phoenix6.configs.Slot0Configs) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_gains parameter and returns itself. The drive motor closed-loop gains. When using closed-loop control, the drive motor uses the control output type specified by DriveMotorClosedLoopOutput and any closed-loop SwerveModule.DriveRequestType. These gains operate on motor rotor rotations (before the gear ratio). :param new_drive_motor_gains: Parameter to modify :type new_drive_motor_gains: Slot0Configs :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_closed_loop_output(new_steer_motor_closed_loop_output: ClosedLoopOutputType) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_closed_loop_output parameter and returns itself. The closed-loop output type to use for the steer motors. :param new_steer_motor_closed_loop_output: Parameter to modify :type new_steer_motor_closed_loop_output: ClosedLoopOutputType :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_closed_loop_output(new_drive_motor_closed_loop_output: ClosedLoopOutputType) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_closed_loop_output parameter and returns itself. The closed-loop output type to use for the drive motors. :param new_drive_motor_closed_loop_output: Parameter to modify :type new_drive_motor_closed_loop_output: ClosedLoopOutputType :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_slip_current(new_slip_current: phoenix6.units.ampere) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the slip_current parameter and returns itself. The maximum amount of stator current the drive motors can apply without slippage. :param new_slip_current: Parameter to modify :type new_slip_current: ampere :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_speed_at12_volts(new_speed_at12_volts: phoenix6.units.meters_per_second) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the speed_at12_volts parameter and returns itself. When using open-loop drive control, this specifies the speed at which the robot travels when driven with 12 volts. This is used to approximate the output for a desired velocity. If using closed loop control, this value is ignored. :param new_speed_at12_volts: Parameter to modify :type new_speed_at12_volts: meters_per_second :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_type(new_drive_motor_type: DriveMotorArrangement) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_type parameter and returns itself. Choose the motor used for the drive motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. :param new_drive_motor_type: Parameter to modify :type new_drive_motor_type: DriveMotorArrangement :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_type(new_steer_motor_type: SteerMotorArrangement) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_type parameter and returns itself. Choose the motor used for the steer motor. If using a Talon FX, this should be set to TalonFX_Integrated. If using a Talon FXS, this should be set to the motor attached to the Talon FXS. :param new_steer_motor_type: Parameter to modify :type new_steer_motor_type: SteerMotorArrangement :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_feedback_source(new_feedback_source: SteerFeedbackType) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the feedback_source parameter and returns itself. Choose how the feedback sensors should be configured. If the robot does not support Pro, then this should be set to RemoteCANcoder. Otherwise, users have the option to use either FusedCANcoder or SyncCANcoder depending on if there is a risk that the CANcoder can fail in a way to provide "good" data. If this is set to FusedCANcoder or SyncCANcoder when the steer motor is not Pro-licensed, the device will automatically fall back to RemoteCANcoder and report a UsingProFeatureOnUnlicensedDevice status code. :param new_feedback_source: Parameter to modify :type new_feedback_source: SteerFeedbackType :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_motor_initial_configs(new_drive_motor_initial_configs: DriveMotorConfigsT) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_motor_initial_configs parameter and returns itself. The initial configs used to configure the drive motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode, overwritten with SwerveDrivetrain.config_neutral_mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.DriveMotorInverted) - Slot0Configs (SwerveModuleConstants.DriveMotorGains) - CurrentLimitsConfigs.StatorCurrentLimit / TorqueCurrentConfigs.PeakForwardTorqueCurrent / TorqueCurrentConfigs.PeakReverseTorqueCurrent (SwerveModuleConstants.SlipCurrent) - CurrentLimitsConfigs.StatorCurrentLimitEnable (Enabled) :param new_drive_motor_initial_configs: Parameter to modify :type new_drive_motor_initial_configs: DriveMotorConfigsT :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_motor_initial_configs(new_steer_motor_initial_configs: SteerMotorConfigsT) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_motor_initial_configs parameter and returns itself. The initial configs used to configure the steer motor of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. The list of configs that will be overwritten is as follows: - MotorOutputConfigs.NeutralMode (Brake mode) - MotorOutputConfigs.Inverted (SwerveModuleConstants.SteerMotorInverted) - Slot0Configs (SwerveModuleConstants.SteerMotorGains) - FeedbackConfigs.FeedbackRemoteSensorID (SwerveModuleConstants.EncoderId) - FeedbackConfigs.FeedbackSensorSource (SwerveModuleConstants.FeedbackSource) - FeedbackConfigs.RotorToSensorRatio (SwerveModuleConstants.SteerMotorGearRatio) - MotionMagicConfigs.MotionMagicExpo_kV / MotionMagicConfigs.MotionMagicExpo_kA (Calculated from gear ratios) - ClosedLoopGeneralConfigs.ContinuousWrap (true) :param new_steer_motor_initial_configs: Parameter to modify :type new_steer_motor_initial_configs: SteerMotorConfigsT :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_encoder_initial_configs(new_encoder_initial_configs: EncoderConfigsT) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the encoder_initial_configs parameter and returns itself. The initial configs used to configure the azimuth encoder of the swerve module. The default value is the factory-default. Users may change the initial configuration as they need. Any config that's not referenced in the SwerveModuleConstants class is available to be changed. For CANcoder, the list of configs that will be overwritten is as follows: - MagnetSensorConfigs.MagnetOffset (SwerveModuleConstants.EncoderOffset) - MagnetSensorConfigs.SensorDirection (SwerveModuleConstants.EncoderInverted) :param new_encoder_initial_configs: Parameter to modify :type new_encoder_initial_configs: EncoderConfigsT :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_inertia(new_steer_inertia: phoenix6.units.kilogram_square_meter) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_inertia parameter and returns itself. Simulated azimuthal inertia. :param new_steer_inertia: Parameter to modify :type new_steer_inertia: kilogram_square_meter :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_inertia(new_drive_inertia: phoenix6.units.kilogram_square_meter) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_inertia parameter and returns itself. Simulated drive inertia. :param new_drive_inertia: Parameter to modify :type new_drive_inertia: kilogram_square_meter :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_steer_friction_voltage(new_steer_friction_voltage: phoenix6.units.volt) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the steer_friction_voltage parameter and returns itself. Simulated steer voltage required to overcome friction. :param new_steer_friction_voltage: Parameter to modify :type new_steer_friction_voltage: volt :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: with_drive_friction_voltage(new_drive_friction_voltage: phoenix6.units.volt) -> SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Modifies the drive_friction_voltage parameter and returns itself. Simulated drive voltage required to overcome friction. :param new_drive_friction_voltage: Parameter to modify :type new_drive_friction_voltage: volt :returns: this object :rtype: SwerveModuleConstantsFactory[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:method:: create_module_constants(steer_motor_id: int, drive_motor_id: int, encoder_id: int, encoder_offset: phoenix6.units.rotation, location_x: phoenix6.units.meter, location_y: phoenix6.units.meter, drive_motor_inverted: bool, steer_motor_inverted: bool, encoder_inverted: bool) -> SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] Creates the constants for a swerve module with the given properties. :param steer_motor_id: CAN ID of the steer motor. :type steer_motor_id: int :param drive_motor_id: CAN ID of the drive motor. :type drive_motor_id: int :param encoder_id: CAN ID of the absolute encoder used for azimuth. :type encoder_id: int :param encoder_offset: Offset of the azimuth encoder. :type encoder_offset: rotation :param location_x: The location of this module's wheels relative to the physical center of the robot in meters along the X axis of the robot. :type location_x: meter :param location_y: The location of this module's wheels relative to the physical center of the robot in meters along the Y axis of the robot. :type location_y: meter :param drive_motor_inverted: True if the drive motor is inverted. :type drive_motor_inverted: bool :param steer_motor_inverted: True if the steer motor is inverted from the azimuth. The azimuth should rotate counter-clockwise (as seen from the top of the robot) for a positive motor output. :type steer_motor_inverted: bool :param encoder_inverted: True if the azimuth encoder is inverted from the azimuth. The encoder should report a positive velocity when the azimuth rotates counter-clockwise (as seen from the top of the robot). :type encoder_inverted: bool :returns: Constants for the swerve module :rtype: SwerveModuleConstants[DriveMotorConfigsT, SteerMotorConfigsT, EncoderConfigsT] .. py:class:: SwerveDrivetrain(drive_motor_type: type[DriveMotorT], steer_motor_type: type[SteerMotorT], encoder_type: type[EncoderT], drivetrain_constants: phoenix6.swerve.swerve_drivetrain_constants.SwerveDrivetrainConstants, modules: list[phoenix6.swerve.swerve_module_constants.SwerveModuleConstants]) SwerveDrivetrain(drive_motor_type: type[DriveMotorT], steer_motor_type: type[SteerMotorT], encoder_type: type[EncoderT], drivetrain_constants: phoenix6.swerve.swerve_drivetrain_constants.SwerveDrivetrainConstants, odometry_update_frequency: phoenix6.units.hertz, modules: list[phoenix6.swerve.swerve_module_constants.SwerveModuleConstants]) SwerveDrivetrain(drive_motor_type: type[DriveMotorT], steer_motor_type: type[SteerMotorT], encoder_type: type[EncoderT], drivetrain_constants: phoenix6.swerve.swerve_drivetrain_constants.SwerveDrivetrainConstants, odometry_update_frequency: phoenix6.units.hertz, odometry_standard_deviation: tuple[float, float, float], vision_standard_deviation: tuple[float, float, float], modules: list[phoenix6.swerve.swerve_module_constants.SwerveModuleConstants]) Bases: :py:obj:`Generic`\ [\ :py:obj:`DriveMotorT`\ , :py:obj:`SteerMotorT`\ , :py:obj:`EncoderT`\ ] Swerve Drive class utilizing CTR Electronics' Phoenix 6 API. This class handles the kinematics, configuration, and odometry of a swerve drive utilizing CTR Electronics devices. We recommend using the Swerve Project Generator in Tuner X to create a template project that demonstrates how to use this class. This class performs pose estimation internally using a separate odometry thread. Vision measurements can be added using add_vision_measurement. Other odometry APIs such as reset_pose are also available. The resulting pose estimate can be retrieved along with module states and other information using get_state. Additionally, the odometry thread synchronously provides all new state updates to a telemetry function registered with register_telemetry. This class will construct the hardware devices internally, so the user only specifies the constants (IDs, PID gains, gear ratios, etc). Getters for these hardware devices are available. If using the generator, the order in which modules are constructed is Front Left, Front Right, Back Left, Back Right. This means if you need the Back Left module, call get_module(2) to get the third (0-indexed) module. .. py:class:: SwerveDriveState Plain-Old-Data class holding the state of the swerve drivetrain. This encapsulates most data that is relevant for telemetry or decision-making from the Swerve Drive. .. py:attribute:: pose The current pose of the robot .. py:attribute:: speeds The current velocity of the robot .. py:attribute:: module_states :type: list[SwerveModuleState] The current module states .. py:attribute:: module_targets :type: list[SwerveModuleState] The target module states .. py:attribute:: module_positions :type: list[SwerveModulePosition] The current module positions .. py:attribute:: raw_heading The raw heading of the robot, unaffected by vision updates and odometry resets .. py:attribute:: timestamp :type: phoenix6.units.second :value: 0.0 The timestamp of the state capture, in the timebase of utils.get_current_time_seconds() .. py:attribute:: odometry_period :type: phoenix6.units.second :value: 0.0 The measured odometry update period, in seconds .. py:attribute:: successful_daqs :value: 0 Number of successful data acquisitions .. py:attribute:: failed_daqs :value: 0 Number of failed data acquisitions .. py:class:: OdometryThread(drivetrain: int) Performs swerve module updates in a separate thread to minimize latency. :param drivetrain: ID of the swerve drivetrain :type drivetrain: int .. py:method:: start() Starts the odometry thread. .. py:method:: stop() Stops the odometry thread. .. py:method:: is_odometry_valid() -> bool Check if the odometry is currently valid. :returns: True if odometry is valid :rtype: bool .. py:method:: set_thread_priority(priority: int) Sets the odometry thread priority to a real time priority under the specified priority level :param priority: Priority level to set the odometry thread to. This is a value between 0 and 99, with 99 indicating higher priority and 0 indicating lower priority. :type priority: int .. py:property:: odometry_thread :type: OdometryThread Gets a reference to the odometry thread. :returns: Odometry thread :rtype: OdometryThread .. py:property:: kinematics :type: wpimath.kinematics.SwerveDrive2Kinematics | wpimath.kinematics.SwerveDrive3Kinematics | wpimath.kinematics.SwerveDrive4Kinematics | wpimath.kinematics.SwerveDrive6Kinematics Gets a reference to the kinematics used for the drivetrain. :returns: Swerve kinematics :rtype: SwerveDrive2Kinematics | SwerveDrive3Kinematics | SwerveDrive4Kinematics | SwerveDrive6Kinematics .. py:property:: modules :type: list[phoenix6.swerve.swerve_module.SwerveModule[DriveMotorT, SteerMotorT, EncoderT]] Get a reference to the full array of modules. The indexes correspond to the module described in the constructor. :returns: Reference to the SwerveModule array :rtype: list[SwerveModule[DriveMotorT, SteerMotorT, EncoderT]] .. py:property:: module_locations :type: list[Translation2d] Gets the locations of the swerve modules. :returns: Reference to the array of swerve module locations :rtype: list[Translation2d] .. py:property:: pigeon2 :type: phoenix6.hardware.pigeon2.Pigeon2 Gets this drivetrain's Pigeon 2 reference. This should be used only to access signals and change configurations that the swerve drivetrain does not configure itself. :returns: This drivetrain's Pigeon 2 reference :rtype: Pigeon2 .. py:method:: close() Closes this SwerveDrivetrain instance. .. py:method:: update_sim_state(dt: phoenix6.units.second, supply_voltage: phoenix6.units.volt) Updates all the simulation state variables for this drivetrain class. User provides the update variables for the simulation. :param dt: time since last update call :type dt: second :param supply_voltage: voltage as seen at the motor controllers :type supply_voltage: volt .. py:method:: is_on_can_fd() -> bool Gets whether the drivetrain is on a CAN FD bus. :returns: True if on CAN FD :rtype: bool .. py:method:: get_odometry_frequency() -> phoenix6.units.hertz Gets the target odometry update frequency. :returns: Target odometry update frequency :rtype: hertz .. py:method:: is_odometry_valid() -> bool Check if the odometry is currently valid. :returns: True if odometry is valid :rtype: bool .. py:method:: set_control(request: phoenix6.swerve.requests.SwerveRequest) Applies the specified control request to this swerve drivetrain. :param request: Request to apply :type request: requests.SwerveRequest .. py:method:: get_state() -> SwerveDriveState Gets the current state of the swerve drivetrain. This includes information such as the pose estimate, module states, and chassis speeds. :returns: Current state of the drivetrain :rtype: SwerveDriveState .. py:method:: get_state_copy() -> SwerveDriveState Gets a copy of the current state of the swerve drivetrain. This includes information such as the pose estimate, module states, and chassis speeds. This can be used to get a thread-safe copy of the state object. :returns: Copy of the current state of the drivetrain :rtype: SwerveDriveState .. py:method:: register_telemetry(telemetry_function: Callable[[SwerveDriveState], None]) Register the specified lambda to be executed whenever our SwerveDriveState function is updated in our odometry thread. It is imperative that this function is cheap, as it will be executed along with the odometry call, and if this takes a long time, it may negatively impact the odometry of this stack. This can also be used for logging data if the function performs logging instead of telemetry. Additionally, the SwerveDriveState object can be cloned and stored for later processing. :param telemetry_function: Function to call for telemetry or logging :type telemetry_function: Callable[[SwerveDriveState], None] .. py:method:: config_neutral_mode(neutral_mode: phoenix6.signals.spn_enums.NeutralModeValue) -> phoenix6.status_code.StatusCode Configures the neutral mode to use for all modules' drive motors. :param neutral_mode: The drive motor neutral mode :type neutral_mode: NeutralModeValue :returns: Status code of the first failed config call, or OK if all succeeded :rtype: StatusCode .. py:method:: tare_everything() Zero's this swerve drive's odometry entirely. This will zero the entire odometry, and place the robot at 0,0 .. py:method:: seed_field_centric() Resets the rotation of the robot pose to 0 from the ForwardPerspectiveValue.OPERATOR_PERSPECTIVE perspective. This makes the current orientation of the robot X forward for field-centric maneuvers. This is equivalent to calling reset_rotation with the operator perspective rotation. .. py:method:: reset_pose(pose: Pose2d) Resets the pose of the robot. The pose should be from the ForwardPerspectiveValue.BLUE_ALLIANCE perspective. :param pose: Pose to make the current pose :type pose: Pose2d .. py:method:: reset_translation(translation: Translation2d) Resets the translation of the robot pose without affecting rotation. The translation should be from the ForwardPerspectiveValue.BLUE_ALLIANCE perspective. :param translation: Translation to make the current translation :type translation: Translation2d .. py:method:: reset_rotation(rotation: Rotation2d) Resets the rotation of the robot pose without affecting translation. The rotation should be from the ForwardPerspectiveValue.BLUE_ALLIANCE perspective. :param rotation: Rotation to make the current rotation :type rotation: Rotation2d .. py:method:: set_operator_perspective_forward(field_direction: Rotation2d) Takes the ForwardPerspectiveValue.BLUE_ALLIANCE perpective direction and treats it as the forward direction for ForwardPerspectiveValue.OPERATOR_PERSPECTIVE. If the operator is in the Blue Alliance Station, this should be 0 degrees. If the operator is in the Red Alliance Station, this should be 180 degrees. This does not change the robot pose, which is in the ForwardPerspectiveValue.BLUE_ALLIANCE perspective. As a result, the robot pose may need to be reset using reset_pose. :param field_direction: Heading indicating which direction is forward from the ForwardPerspectiveValue.BLUE_ALLIANCE perspective :type field_direction: Rotation2d .. py:method:: get_operator_forward_direction() -> Rotation2d Returns the ForwardPerspectiveValue.BLUE_ALLIANCE perpective direction that is treated as the forward direction for ForwardPerspectiveValue.OPERATOR_PERSPECTIVE. If the operator is in the Blue Alliance Station, this should be 0 degrees. If the operator is in the Red Alliance Station, this should be 180 degrees. :returns: Heading indicating which direction is forward from the ForwardPerspectiveValue.BLUE_ALLIANCE perspective :rtype: Rotation2d .. py:method:: add_vision_measurement(vision_robot_pose: Pose2d, timestamp: phoenix6.units.second, vision_measurement_std_devs: tuple[float, float, float] | None = None) Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate while still accounting for measurement noise. This method can be called as infrequently as you want. To promote stability of the pose estimate and make it robust to bad vision data, we recommend only adding vision measurements that are already within one meter or so of the current pose estimate. Note that the vision measurement standard deviations passed into this method will continue to apply to future measurements until a subsequent call to set_vision_measurement_std_devs or this method. :param vision_robot_pose: The pose of the robot as measured by the vision camera. :type vision_robot_pose: Pose2d :param timestamp: The timestamp of the vision measurement in seconds. Note that you must use a timestamp with an epoch since system startup (i.e., the epoch of this timestamp is the same epoch as utils.get_current_time_seconds). This means that you should use utils.get_current_time_seconds as your time source or sync the epochs. An FPGA timestamp can be converted to the correct timebase using utils.fpga_to_current_time. :type timestamp: second :param vision_measurement_std_devs: Standard deviations of the vision pose measurement (x position in meters, y position in meters, and heading in radians). Increase these numbers to trust the vision pose measurement less. :type vision_measurement_std_devs: tuple[float, float, float] | None .. py:method:: set_vision_measurement_std_devs(vision_measurement_std_devs: tuple[float, float, float]) Sets the pose estimator's trust of global measurements. This might be used to change trust in vision measurements after the autonomous period, or to change trust as distance to a vision target increases. :param vision_measurement_std_devs: Standard deviations of the vision measurements. Increase these numbers to trust global measurements from vision less. This matrix is in the form [x, y, theta]ᵀ, with units in meters and radians. :type vision_measurement_std_devs: tuple[float, float, float] .. py:method:: set_state_std_devs(state_std_devs: tuple[float, float, float]) Sets the pose estimator's trust in robot odometry. This might be used to change trust in odometry after an impact with the wall or traversing a bump. :param state_std_devs: Standard deviations of the pose estimate. Increase these numbers to trust your state estimate less. This matrix is in the form [x, y, theta]ᵀ, with units in meters and radians. :type state_std_devs: tuple[float, float, float] .. py:method:: sample_pose_at(timestamp: phoenix6.units.second) -> Pose2d | None Return the pose at a given timestamp, if the buffer is not empty. :param timestamp: The pose's timestamp. Note that you must use a timestamp with an epoch since system startup (i.e., the epoch of this timestamp is the same epoch as utils.get_current_time_seconds). This means that you should use utils.get_current_time_seconds as your time source in this case. An FPGA timestamp can be converted to the correct timebase using utils.fpga_to_current_time. :type timestamp: second :returns: The pose at the given timestamp (or None if the buffer is empty). :rtype: Pose2d | None .. py:method:: get_module(index: int) -> phoenix6.swerve.swerve_module.SwerveModule[DriveMotorT, SteerMotorT, EncoderT] Get a reference to the module at the specified index. The index corresponds to the module described in the constructor. :param index: Which module to get :type index: int :returns: Reference to SwerveModule :rtype: SwerveModule[DriveMotorT, SteerMotorT, EncoderT] .. py:method:: get_rotation3d() -> wpimath.geometry.Rotation3d Gets the current orientation of the robot as a Rotation3d from the Pigeon 2 quaternion values. :returns: The robot orientation as a Rotation3d :rtype: Rotation3d .. py:class:: SwerveControlParameters Contains everything the control requests need to calculate the module state. .. py:attribute:: drivetrain_id :value: 0 ID of the native drivetrain instance, used for native calls .. py:attribute:: kinematics :type: wpimath.kinematics.SwerveDrive2Kinematics | wpimath.kinematics.SwerveDrive3Kinematics | wpimath.kinematics.SwerveDrive4Kinematics | wpimath.kinematics.SwerveDrive6Kinematics The kinematics object used for control .. py:attribute:: module_locations :type: list[Translation2d] The locations of the swerve modules .. py:attribute:: max_speed :type: phoenix6.units.meters_per_second :value: 0.0 The max speed of the robot at 12 V output, in m/s .. py:attribute:: operator_forward_direction The forward direction from the operator perspective .. py:attribute:: current_chassis_speed The current chassis speeds of the robot .. py:attribute:: current_pose The current pose of the robot .. py:attribute:: timestamp :type: phoenix6.units.second :value: 0.0 The timestamp of the current control apply, in the timebase of utils.get_current_time_seconds() .. py:attribute:: update_period :type: phoenix6.units.second :value: 0.0 The update period of control apply .. py:class:: SwerveModule(drive_motor_type: type[DriveMotorT], steer_motor_type: type[SteerMotorT], encoder_type: type[EncoderT], constants: phoenix6.swerve.swerve_module_constants.SwerveModuleConstants, canbus_name: str, drivetrain_id: int, index: int) Bases: :py:obj:`Generic`\ [\ :py:obj:`DriveMotorT`\ , :py:obj:`SteerMotorT`\ , :py:obj:`EncoderT`\ ] 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. :param drive_motor_type: Type of the drive motor :type drive_motor_type: type[DriveMotorT] :param steer_motor_type: Type of the steer motor :type steer_motor_type: type[SteerMotorT] :param encoder_type: Type of the azimuth encoder :type encoder_type: type[EncoderT] :param constants: Constants used to construct the module :type constants: SwerveModuleConstants :param canbus_name: The name of the CAN bus this module is on :type canbus_name: str :param drivetrain_id: ID of the swerve drivetrain :type drivetrain_id: int :param index: Index of this swerve module :type index: int .. py:class:: SteerRequestType(*args, **kwds) Bases: :py:obj:`enum.Enum` All possible control requests for the module steer motor. .. py:attribute:: MOTION_MAGIC_EXPO :value: 0 Control the drive motor using a Motion Magic® Expo request. The control output type is determined by SwerveModuleConstants.SteerMotorClosedLoopOutput .. py:attribute:: POSITION :value: 1 Control the drive motor using an unprofiled position request. The control output type is determined by SwerveModuleConstants.SteerMotorClosedLoopOutput .. py:class:: DriveRequestType(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: OPEN_LOOP_VOLTAGE :value: 0 Control the drive motor using an open-loop voltage request. .. py:attribute:: VELOCITY :value: 1 Control the drive motor using a velocity closed-loop request. The control output type is determined by SwerveModuleConstants.DriveMotorClosedLoopOutput .. py:class:: ModuleRequest Contains everything the swerve module needs to apply a request. .. py:attribute:: state Unoptimized speed and direction the module should target. .. py:attribute:: wheel_force_feedforward_x :type: phoenix6.units.newton :value: 0.0 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. .. py:attribute:: wheel_force_feedforward_y :type: phoenix6.units.newton :value: 0.0 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. .. py:attribute:: drive_request The type of control request to use for the drive motor. .. py:attribute:: steer_request The type of control request to use for the steer motor. .. py:attribute:: update_period :type: second :value: 0.0 The update period of the module request. Setting this to a non-zero value adds a velocity feedforward to the steer motor. .. py:attribute:: enable_foc :value: 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. .. py:method:: with_state(new_state: SwerveModuleState) -> SwerveModule Modifies the state parameter and returns itself. Unoptimized speed and direction the module should target. :param new_state: Parameter to modify :type new_state: SwerveModuleState :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_wheel_force_feedforward_x(new_wheel_force_feedforward_x: phoenix6.units.newton) -> SwerveModule Modifies the wheel_force_feedforward_x 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. :param wheel_force_feedforward_x: Parameter to modify :type wheel_force_feedforward_x: newton :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_wheel_force_feedforward_y(new_wheel_force_feedforward_y: phoenix6.units.newton) -> SwerveModule Modifies the wheel_force_feedforward_y 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. :param wheel_force_feedforward_y: Parameter to modify :type wheel_force_feedforward_y: newton :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_drive_request(new_drive_request: SwerveModule) -> SwerveModule Modifies the drive_request parameter and returns itself. The type of control request to use for the drive motor. :param new_drive_request: Parameter to modify :type new_drive_request: SwerveModule.DriveRequestType :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_steer_request(new_steer_request: SwerveModule) -> SwerveModule Modifies the steer_request parameter and returns itself. The type of control request to use for the steer motor. :param new_steer_request: Parameter to modify :type new_steer_request: SwerveModule.SteerRequestType :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_update_period(new_update_period: second) -> SwerveModule Modifies the update_period 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. :param new_update_period: Parameter to modify :type new_update_period: second :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:method:: with_enable_foc(new_enable_foc: bool) -> SwerveModule Modifies the enable_foc 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. :param new_enable_foc: Parameter to modify :type new_enable_foc: bool :returns: Itself :rtype: SwerveModule.ModuleRequest .. py:property:: drive_closed_loop_output_type :type: phoenix6.swerve.swerve_module_constants.ClosedLoopOutputType Gets the closed-loop output type to use for the drive motor. :returns: Drive motor closed-loop output type :rtype: ClosedLoopOutputType .. py:property:: steer_closed_loop_output_type :type: phoenix6.swerve.swerve_module_constants.ClosedLoopOutputType Gets the closed-loop output type to use for the steer motor. :returns: Steer motor closed-loop output type :rtype: ClosedLoopOutputType .. py:property:: drive_motor :type: DriveMotorT 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 :rtype: DriveMotorT .. py:property:: steer_motor :type: SteerMotorT 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 :rtype: SteerMotorT .. py:property:: encoder :type: 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 :rtype: EncoderT .. py:method:: apply(module_request: ModuleRequest) apply(drive_request: phoenix6.hardware.parent_device.SupportsSendRequest, steer_request: phoenix6.hardware.parent_device.SupportsSendRequest) .. py:method:: get_position(refresh: bool) -> SwerveModulePosition 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. :param refresh: True if the signals should be refreshed :type refresh: bool :returns: SwerveModulePosition containing this module's state :rtype: SwerveModulePosition .. py:method:: get_cached_position() -> SwerveModulePosition Gets the last cached swerve module position. This differs from get_position in that it will not perform any latency compensation or refresh the signals. :returns: Last cached SwerveModulePosition :rtype: SwerveModulePosition .. py:method:: get_current_state() -> SwerveModuleState 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 :rtype: SwerveModuleState .. py:method:: get_target_state() -> SwerveModuleState Get the target state of the module. This is typically used for telemetry. :returns: Target state of the module :rtype: SwerveModuleState .. py:method:: reset_position() Resets this module's drive motor position to 0 rotations.