CTRE Phoenix Pro C++ 23.0.12
ctre::phoenixpro::sim::TalonFXSimState Class Reference

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

#include <ctre/phoenixpro/sim/TalonFXSimState.hpp>

Public Member Functions

 TalonFXSimState (hardware::core::CoreTalonFX const &device)
 Creates an object to control the state of the given hardware::TalonFX. More...
 
 TalonFXSimState (hardware::core::CoreTalonFX const &device, ChassisReference orientation)
 Creates an object to control the state of the given hardware::TalonFX. More...
 
 TalonFXSimState (TalonFXSimState const &)=delete
 
 TalonFXSimState (TalonFXSimState &&)=default
 
TalonFXSimStateoperator= (TalonFXSimState const &)=delete
 
TalonFXSimStateoperator= (TalonFXSimState &&)=default
 
ctre::phoenix::StatusCode GetLastStatusCode () const
 Gets the last status code generated by a simulation function. More...
 
units::voltage::volt_t GetMotorVoltage () const
 Gets the simulated output voltage of the motor. More...
 
units::current::ampere_t GetTorqueCurrent () const
 Gets the simulated output torque current of the motor. More...
 
units::current::ampere_t GetSupplyCurrent () const
 Gets the simulated supply current of the TalonFX. More...
 
ctre::phoenix::StatusCode SetSupplyVoltage (units::voltage::volt_t volts)
 Sets the simulated supply voltage of the TalonFX. More...
 
ctre::phoenix::StatusCode SetForwardLimit (bool closed)
 Sets the simulated forward limit switch of the TalonFX. More...
 
ctre::phoenix::StatusCode SetReverseLimit (bool closed)
 Sets the simulated reverse limit switch of the TalonFX. More...
 
ctre::phoenix::StatusCode SetRawRotorPosition (units::angle::turn_t rotations)
 Sets the simulated raw rotor position of the TalonFX. More...
 
ctre::phoenix::StatusCode AddRotorPosition (units::angle::turn_t dRotations)
 Adds to the simulated rotor position of the TalonFX. More...
 
ctre::phoenix::StatusCode SetRotorVelocity (units::angular_velocity::turns_per_second_t rps)
 Sets the simulated rotor velocity of the TalonFX. More...
 

Public Attributes

ChassisReference Orientation
 The orientation of the TalonFX relative to the robot chassis. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ TalonFXSimState() [1/4]

ctre::phoenixpro::sim::TalonFXSimState::TalonFXSimState ( hardware::core::CoreTalonFX const &  device)
inline

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

This constructor defaults to a counter-clockwise positive orientation relative to the robot chassis.

Parameters
deviceDevice to which this simulation state is attached

◆ TalonFXSimState() [2/4]

ctre::phoenixpro::sim::TalonFXSimState::TalonFXSimState ( hardware::core::CoreTalonFX const &  device,
ChassisReference  orientation 
)

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

Parameters
deviceDevice to which this simulation state is attached
orientationOrientation of the device relative to the robot chassis

◆ TalonFXSimState() [3/4]

ctre::phoenixpro::sim::TalonFXSimState::TalonFXSimState ( TalonFXSimState const &  )
delete

◆ TalonFXSimState() [4/4]

ctre::phoenixpro::sim::TalonFXSimState::TalonFXSimState ( TalonFXSimState &&  )
default

Member Function Documentation

◆ AddRotorPosition()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::AddRotorPosition ( units::angle::turn_t  dRotations)

Adds to the simulated rotor position of the TalonFX.

Parameters
dRotationsThe change in position in rotations
Returns
Status code

◆ GetLastStatusCode()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::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::phoenixpro::sim::TalonFXSimState::GetMotorVoltage ( ) const

Gets the simulated output voltage of the motor.

Returns
Voltage applied to the motor in Volts

◆ GetSupplyCurrent()

units::current::ampere_t ctre::phoenixpro::sim::TalonFXSimState::GetSupplyCurrent ( ) const

Gets the simulated supply current of the TalonFX.

Returns
Supply current of the TalonFX in Amperes

◆ GetTorqueCurrent()

units::current::ampere_t ctre::phoenixpro::sim::TalonFXSimState::GetTorqueCurrent ( ) const

Gets the simulated output torque current of the motor.

Returns
Torque current applied to the motor in Amperes

◆ operator=() [1/2]

TalonFXSimState & ctre::phoenixpro::sim::TalonFXSimState::operator= ( TalonFXSimState &&  )
default

◆ operator=() [2/2]

TalonFXSimState & ctre::phoenixpro::sim::TalonFXSimState::operator= ( TalonFXSimState const &  )
delete

◆ SetForwardLimit()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::SetForwardLimit ( bool  closed)

Sets the simulated forward limit switch of the TalonFX.

Parameters
closedWhether the limit switch is closed
Returns
Status code

◆ SetRawRotorPosition()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::SetRawRotorPosition ( units::angle::turn_t  rotations)

Sets the simulated raw rotor position of the TalonFX.

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

The TalonFX 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::phoenixpro::sim::TalonFXSimState::SetReverseLimit ( bool  closed)

Sets the simulated reverse limit switch of the TalonFX.

Parameters
closedWhether the limit switch is closed
Returns
Status code

◆ SetRotorVelocity()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::SetRotorVelocity ( units::angular_velocity::turns_per_second_t  rps)

Sets the simulated rotor velocity of the TalonFX.

Parameters
rpsThe new velocity in rotations per second
Returns
Status code

◆ SetSupplyVoltage()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::TalonFXSimState::SetSupplyVoltage ( units::voltage::volt_t  volts)

Sets the simulated supply voltage of the TalonFX.

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

◆ Orientation

ChassisReference ctre::phoenixpro::sim::TalonFXSimState::Orientation

The orientation of the TalonFX relative to the robot chassis.

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


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