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

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

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

Public Member Functions

 CANcoderSimState (hardware::core::CoreCANcoder const &device)
 Creates an object to control the state of the given hardware::CANcoder. More...
 
 CANcoderSimState (hardware::core::CoreCANcoder const &device, ChassisReference orientation)
 Creates an object to control the state of the given hardware::CANcoder. More...
 
 CANcoderSimState (CANcoderSimState const &)=delete
 
 CANcoderSimState (CANcoderSimState &&)=default
 
CANcoderSimStateoperator= (CANcoderSimState const &)=delete
 
CANcoderSimStateoperator= (CANcoderSimState &&)=default
 
ctre::phoenix::StatusCode SetSupplyVoltage (units::voltage::volt_t volts)
 Sets the simulated supply voltage of the CANcoder. More...
 
ctre::phoenix::StatusCode SetRawPosition (units::angle::turn_t rotations)
 Sets the simulated raw position of the CANcoder. More...
 
ctre::phoenix::StatusCode AddPosition (units::angle::turn_t dRotations)
 Adds to the simulated position of the CANcoder. More...
 
ctre::phoenix::StatusCode SetVelocity (units::angular_velocity::turns_per_second_t rps)
 Sets the simulated velocity of the CANcoder. More...
 

Public Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ CANcoderSimState() [1/4]

ctre::phoenixpro::sim::CANcoderSimState::CANcoderSimState ( hardware::core::CoreCANcoder const &  device)
inline

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

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

Parameters
deviceDevice to which this simulation state is attached

◆ CANcoderSimState() [2/4]

ctre::phoenixpro::sim::CANcoderSimState::CANcoderSimState ( hardware::core::CoreCANcoder const &  device,
ChassisReference  orientation 
)

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

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

◆ CANcoderSimState() [3/4]

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

◆ CANcoderSimState() [4/4]

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

Member Function Documentation

◆ AddPosition()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::CANcoderSimState::AddPosition ( units::angle::turn_t  dRotations)

Adds to the simulated position of the CANcoder.

Parameters
dRotationsThe change in position in rotations
Returns
Status code

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ SetRawPosition()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::CANcoderSimState::SetRawPosition ( units::angle::turn_t  rotations)

Sets the simulated raw position of the CANcoder.

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

The CANcoder integrates this to calculate the true reported 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

◆ SetSupplyVoltage()

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

Sets the simulated supply voltage of the CANcoder.

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

◆ SetVelocity()

ctre::phoenix::StatusCode ctre::phoenixpro::sim::CANcoderSimState::SetVelocity ( units::angular_velocity::turns_per_second_t  rps)

Sets the simulated velocity of the CANcoder.

Parameters
rpsThe new velocity in rotations per second
Returns
Status code

Member Data Documentation

◆ Orientation

ChassisReference ctre::phoenixpro::sim::CANcoderSimState::Orientation

The orientation of the CANcoder relative to the robot chassis.

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


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