CTRE Phoenix 6 C++ 25.2.1
Loading...
Searching...
No Matches
ctre::phoenix6::sim::TalonFXSSimState Class Reference

Class to control the state of a simulated hardware::TalonFXS. More...

#include <ctre/phoenix6/sim/TalonFXSSimState.hpp>

Public Member Functions

 TalonFXSSimState (hardware::core::CoreTalonFXS const &device)
 Creates an object to control the state of the given hardware::TalonFXS.
 
 TalonFXSSimState (hardware::core::CoreTalonFXS const &device, ChassisReference motorOrientation, ChassisReference extSensorOrientation)
 Creates an object to control the state of the given hardware::TalonFXS.
 
 TalonFXSSimState (TalonFXSSimState const &)=delete
 
 TalonFXSSimState (TalonFXSSimState &&)=default
 
TalonFXSSimStateoperator= (TalonFXSSimState const &)=delete
 
TalonFXSSimStateoperator= (TalonFXSSimState &&)=default
 
ctre::phoenix::StatusCode GetLastStatusCode () const
 Gets the last status code generated by a simulation function.
 
units::voltage::volt_t GetMotorVoltage () const
 Gets the simulated output voltage of the motor.
 
units::current::ampere_t GetTorqueCurrent () const
 Gets the simulated output torque current of the motor.
 
units::current::ampere_t GetSupplyCurrent () const
 Gets the simulated supply current of the TalonFXS.
 
ctre::phoenix::StatusCode SetSupplyVoltage (units::voltage::volt_t volts)
 Sets the simulated supply voltage of the TalonFXS.
 
ctre::phoenix::StatusCode SetForwardLimit (bool closed)
 Sets the simulated forward limit switch of the TalonFXS.
 
ctre::phoenix::StatusCode SetReverseLimit (bool closed)
 Sets the simulated reverse limit switch of the TalonFXS.
 
ctre::phoenix::StatusCode SetRawRotorPosition (units::angle::turn_t rotations)
 Sets the simulated raw rotor position of the TalonFXS.
 
ctre::phoenix::StatusCode AddRotorPosition (units::angle::turn_t dRotations)
 Adds to the simulated rotor position of the TalonFXS.
 
ctre::phoenix::StatusCode SetRotorVelocity (units::angular_velocity::turns_per_second_t rps)
 Sets the simulated rotor velocity of the TalonFXS.
 
ctre::phoenix::StatusCode SetRotorAcceleration (units::angular_acceleration::turns_per_second_squared_t rpss)
 Sets the simulated rotor acceleration of the TalonFXS.
 
ctre::phoenix::StatusCode SetRawQuadraturePosition (units::angle::turn_t rotations)
 Sets the simulated raw quadrature position of the TalonFXS.
 
ctre::phoenix::StatusCode AddQuadraturePosition (units::angle::turn_t dRotations)
 Adds to the simulated quadrature position of the TalonFXS.
 
ctre::phoenix::StatusCode SetQuadratureVelocity (units::angular_velocity::turns_per_second_t rps)
 Sets the simulated quadrature velocity of the TalonFXS.
 
ctre::phoenix::StatusCode SetQuadratureAcceleration (units::angular_acceleration::turns_per_second_squared_t rpss)
 Sets the simulated quadrature acceleration of the TalonFXS.
 
ctre::phoenix::StatusCode SetPulseWidthPosition (units::angle::turn_t rotations)
 Sets the simulated pulse width position of the TalonFXS.
 
ctre::phoenix::StatusCode SetPulseWidthVelocity (units::angular_velocity::turns_per_second_t rps)
 Sets the simulated pulse width velocity of the TalonFXS.
 

Public Attributes

ChassisReference MotorOrientation
 The orientation of the motor attached to the TalonFXS relative to the robot chassis.
 
ChassisReference ExtSensorOrientation
 The orientation of an external sensor attached to the TalonFXS relative to the robot chassis.
 
int QuadratureEdgesPerRotation = 4096
 The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the TalonFXS.
 

Detailed Description

Class to control the state of a simulated hardware::TalonFXS.

Constructor & Destructor Documentation

◆ TalonFXSSimState() [1/4]

ctre::phoenix6::sim::TalonFXSSimState::TalonFXSSimState ( hardware::core::CoreTalonFXS const & device)
inline

Creates an object to control the state of the given hardware::TalonFXS.

This constructor defaults to a counter-clockwise positive motor and eternal sensor orientation relative to the robot chassis. Note the recommended method of accessing simulation features is to use hardware::TalonFXS::GetSimState.

Parameters
deviceDevice to which this simulation state is attached

◆ TalonFXSSimState() [2/4]

ctre::phoenix6::sim::TalonFXSSimState::TalonFXSSimState ( hardware::core::CoreTalonFXS const & device,
ChassisReference motorOrientation,
ChassisReference extSensorOrientation )

Creates an object to control the state of the given hardware::TalonFXS.

Note the recommended method of accessing simulation features is to use hardware::TalonFXS::GetSimState.

Parameters
deviceDevice to which this simulation state is attached
motorOrientationOrientation of the motor (and commutation sensor) relative to the robot chassis
extSensorOrientationOrientation of the external sensor relative to the robot chassis

◆ TalonFXSSimState() [3/4]

ctre::phoenix6::sim::TalonFXSSimState::TalonFXSSimState ( TalonFXSSimState const & )
delete

◆ TalonFXSSimState() [4/4]

ctre::phoenix6::sim::TalonFXSSimState::TalonFXSSimState ( TalonFXSSimState && )
default

Member Function Documentation

◆ AddQuadraturePosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::AddQuadraturePosition ( units::angle::turn_t dRotations)

Adds to the simulated quadrature position of the TalonFXS.

This adds to the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.

Parameters
dRotationsThe change in position in rotations
Returns
Status code

◆ AddRotorPosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::AddRotorPosition ( units::angle::turn_t dRotations)

Adds to the simulated rotor position of the TalonFXS.

This adds to the position of the rotor (before gear ratio) used for the Commutation feedback source.

Parameters
dRotationsThe change in position in rotations
Returns
Status code

◆ GetLastStatusCode()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::GetLastStatusCode ( ) const

Gets the last status code generated by a simulation function.

Not all functions return a status code but can potentially report errors. This function can be used to retrieve those status codes.

Returns
Last status code generated by a simulation function

◆ GetMotorVoltage()

units::voltage::volt_t ctre::phoenix6::sim::TalonFXSSimState::GetMotorVoltage ( ) const

Gets the simulated output voltage of the motor.

Returns
Voltage applied to the motor in Volts

◆ GetSupplyCurrent()

units::current::ampere_t ctre::phoenix6::sim::TalonFXSSimState::GetSupplyCurrent ( ) const

Gets the simulated supply current of the TalonFXS.

Phoenix 6 simulation automatically calculates current.

Returns
Supply current of the TalonFXS in Amperes

◆ GetTorqueCurrent()

units::current::ampere_t ctre::phoenix6::sim::TalonFXSSimState::GetTorqueCurrent ( ) const

Gets the simulated output torque current of the motor.

Phoenix 6 simulation automatically calculates current.

Returns
Torque current applied to the motor in Amperes

◆ operator=() [1/2]

TalonFXSSimState & ctre::phoenix6::sim::TalonFXSSimState::operator= ( TalonFXSSimState && )
default

◆ operator=() [2/2]

TalonFXSSimState & ctre::phoenix6::sim::TalonFXSSimState::operator= ( TalonFXSSimState const & )
delete

◆ SetForwardLimit()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetForwardLimit ( bool closed)

Sets the simulated forward limit switch of the TalonFXS.

Parameters
closedWhether the limit switch is closed
Returns
Status code

◆ SetPulseWidthPosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetPulseWidthPosition ( units::angle::turn_t rotations)

Sets the simulated pulse width position of the TalonFXS.

This is the position of an external PWM encoder after any gear ratio between the rotor and the sensor.

Parameters
rotationsThe new position in rotations
Returns
Status code

◆ SetPulseWidthVelocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetPulseWidthVelocity ( units::angular_velocity::turns_per_second_t rps)

Sets the simulated pulse width velocity of the TalonFXS.

This is the velocity of an external PWM encoder after any gear ratio between the rotor and the sensor.

Parameters
rpsThe new velocity in rotations per second
Returns
Status code

◆ SetQuadratureAcceleration()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetQuadratureAcceleration ( units::angular_acceleration::turns_per_second_squared_t rpss)

Sets the simulated quadrature acceleration of the TalonFXS.

This is the acceleration of an external quadrature encoder after any gear ratio between the rotor and the sensor.

Parameters
rpssThe new acceleration in rotations per second²
Returns
Status code

◆ SetQuadratureVelocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetQuadratureVelocity ( units::angular_velocity::turns_per_second_t rps)

Sets the simulated quadrature velocity of the TalonFXS.

This is the velocity of an external quadrature encoder after any gear ratio between the rotor and the sensor.

Parameters
rpsThe new velocity in rotations per second
Returns
Status code

◆ SetRawQuadraturePosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetRawQuadraturePosition ( units::angle::turn_t rotations)

Sets the simulated raw quadrature position of the TalonFXS.

This is the position of an external quadrature encoder after any gear ratio between the rotor and the sensor.

Inputs to this function over time should be continuous, as user calls of hardware::TalonFXS::SetPosition will be accounted for in the callee.

The TalonFXS integrates this to calculate the true reported quadrature position.

When using the WPI Sim GUI, you will notice a readonly position and settable rawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes to rawPositionInput will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.

Parameters
rotationsThe raw position in rotations
Returns
Status code

◆ SetRawRotorPosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetRawRotorPosition ( units::angle::turn_t rotations)

Sets the simulated raw rotor position of the TalonFXS.

This is the position of the rotor (before gear ratio) used for the Commutation feedback source.

Inputs to this function over time should be continuous, as user calls of hardware::TalonFXS::SetPosition will be accounted for in the callee.

The TalonFXS integrates this to calculate the true reported rotor position.

When using the WPI Sim GUI, you will notice a readonly position and settable rawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes to rawPositionInput will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.

Parameters
rotationsThe raw position in rotations
Returns
Status code

◆ SetReverseLimit()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetReverseLimit ( bool closed)

Sets the simulated reverse limit switch of the TalonFXS.

Parameters
closedWhether the limit switch is closed
Returns
Status code

◆ SetRotorAcceleration()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetRotorAcceleration ( units::angular_acceleration::turns_per_second_squared_t rpss)

Sets the simulated rotor acceleration of the TalonFXS.

This is the acceleration of the rotor (before gear ratio) used for the Commutation feedback source.

Parameters
rpssThe new acceleration in rotations per second²
Returns
Status code

◆ SetRotorVelocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetRotorVelocity ( units::angular_velocity::turns_per_second_t rps)

Sets the simulated rotor velocity of the TalonFXS.

This is the velocity of the rotor (before gear ratio) used for the Commutation feedback source.

Parameters
rpsThe new velocity in rotations per second
Returns
Status code

◆ SetSupplyVoltage()

ctre::phoenix::StatusCode ctre::phoenix6::sim::TalonFXSSimState::SetSupplyVoltage ( units::voltage::volt_t volts)

Sets the simulated supply voltage of the TalonFXS.

The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.

Parameters
voltsThe supply voltage in Volts
Returns
Status code

Member Data Documentation

◆ ExtSensorOrientation

ChassisReference ctre::phoenix6::sim::TalonFXSSimState::ExtSensorOrientation

The orientation of an external sensor attached to the TalonFXS relative to the robot chassis.

This does NOT include the Commutation sensor source.

This value should not be changed based on the TalonFXS invert. Rather, this value should be changed when the mechanical linkage between the external sensor and the robot changes.

◆ MotorOrientation

ChassisReference ctre::phoenix6::sim::TalonFXSSimState::MotorOrientation

The orientation of the motor attached to the TalonFXS relative to the robot chassis.

This include the Commutation sensor source.

This value should not be changed based on the TalonFXS invert. Rather, this value should be changed when the mechanical linkage between the motor and the robot changes.

◆ QuadratureEdgesPerRotation

int ctre::phoenix6::sim::TalonFXSSimState::QuadratureEdgesPerRotation = 4096

The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the TalonFXS.


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