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

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

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

Public Member Functions

 CANdiSimState (hardware::core::CoreCANdi const &device)
 Creates an object to control the state of the given hardware::CANdi.
 
 CANdiSimState (hardware::core::CoreCANdi const &device, ChassisReference pwm1Orientation, ChassisReference pwm2Orientation, ChassisReference quadratureOrientation)
 Creates an object to control the state of the given hardware::CANdi.
 
 CANdiSimState (CANdiSimState const &)=delete
 
 CANdiSimState (CANdiSimState &&)=default
 
CANdiSimStateoperator= (CANdiSimState const &)=delete
 
CANdiSimStateoperator= (CANdiSimState &&)=default
 
ctre::phoenix::StatusCode SetSupplyVoltage (units::voltage::volt_t volts)
 Sets the simulated supply voltage of the CANdi.
 
ctre::phoenix::StatusCode SetOutputCurrent (units::current::ampere_t current)
 Sets the simulated output current of the CANdi.
 
ctre::phoenix::StatusCode SetPwm1RiseRise (units::time::second_t time)
 Sets the simulated PWM1 Rise to Rise timing of the CANdi.
 
ctre::phoenix::StatusCode SetPwm1RiseFall (units::time::second_t time)
 Sets the simulated PWM1 Rise to Fall timing of the CANdi.
 
ctre::phoenix::StatusCode SetPwm1Connected (bool connected)
 Sets whether a PWM sensor is connected to the S1 pin.
 
ctre::phoenix::StatusCode SetPwm1Position (units::angle::turn_t position)
 Sets the simulated pulse width position of the CANdi.
 
ctre::phoenix::StatusCode SetPwm1Velocity (units::angular_velocity::turns_per_second_t velocity)
 Sets the simulated pulse width velocity of the CANdi.
 
ctre::phoenix::StatusCode SetPwm2RiseRise (units::time::second_t time)
 Sets the simulated PWM2 Rise to Rise timing of the CANdi.
 
ctre::phoenix::StatusCode SetPwm2RiseFall (units::time::second_t time)
 Sets the simulated PWM2 Rise to Fall timing of the CANdi.
 
ctre::phoenix::StatusCode SetPwm2Connected (bool connected)
 Sets whether a PWM sensor is connected to the S2 pin.
 
ctre::phoenix::StatusCode SetPwm2Position (units::angle::turn_t position)
 Sets the simulated pulse width position of the CANdi.
 
ctre::phoenix::StatusCode SetPwm2Velocity (units::angular_velocity::turns_per_second_t velocity)
 Sets the simulated pulse width velocity of the CANdi.
 
ctre::phoenix::StatusCode SetRawQuadraturePosition (units::angle::turn_t position)
 Sets the simulated raw quadrature position of the CANdi.
 
ctre::phoenix::StatusCode SetQuadratureVelocity (units::angular_velocity::turns_per_second_t velocity)
 Sets the simulated pulse width velocity of the CANdi.
 
ctre::phoenix::StatusCode SetS1State (ctre::phoenix6::signals::S1StateValue state)
 Sets the state of the S1 pin.
 
ctre::phoenix::StatusCode SetS2State (ctre::phoenix6::signals::S2StateValue state)
 Sets the state of the S2 pin.
 

Public Attributes

ChassisReference Pwm1Orientation
 The orientation of the PWM1 sensor relative to the robot chassis.
 
ChassisReference Pwm2Orientation
 The orientation of the PWM2 sensor relative to the robot chassis.
 
ChassisReference QuadratureOrientation
 The orientation of the Quadrature sensor relative to the robot chassis.
 
int QuadratureEdgesPerRotation = 4096
 The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the CANdi.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ CANdiSimState() [1/4]

ctre::phoenix6::sim::CANdiSimState::CANdiSimState ( hardware::core::CoreCANdi const & device)
inline

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

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

Parameters
deviceDevice to which this simulation state is attached

◆ CANdiSimState() [2/4]

ctre::phoenix6::sim::CANdiSimState::CANdiSimState ( hardware::core::CoreCANdi const & device,
ChassisReference pwm1Orientation,
ChassisReference pwm2Orientation,
ChassisReference quadratureOrientation )

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

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

Parameters
deviceDevice to which this simulation state is attached
pwm1OrientationOrientation of the PWM1 sensor relative to the robot chassis
pwm2OrientationOrientation of the PWM2 sensor relative to the robot chassis
quadratureOrientationOrientation of the Quadrature sensor relative to the robot chassis

◆ CANdiSimState() [3/4]

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

◆ CANdiSimState() [4/4]

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

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ SetOutputCurrent()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetOutputCurrent ( units::current::ampere_t current)

Sets the simulated output current of the CANdi.

Parameters
currentThe output current
Returns
Status code

◆ SetPwm1Connected()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm1Connected ( bool connected)

Sets whether a PWM sensor is connected to the S1 pin.

Parameters
connectedTrue if sensor is connected
Returns
Status code

◆ SetPwm1Position()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm1Position ( units::angle::turn_t position)

Sets the simulated pulse width position of the CANdi.

This is the position of an external PWM encoder connected to the S1 pin.

Parameters
positionThe new position
Returns
Status code

◆ SetPwm1RiseFall()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm1RiseFall ( units::time::second_t time)

Sets the simulated PWM1 Rise to Fall timing of the CANdi.

Parameters
timeThe time between the Rise and Fall events in seconds
Returns
Status code

◆ SetPwm1RiseRise()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm1RiseRise ( units::time::second_t time)

Sets the simulated PWM1 Rise to Rise timing of the CANdi.

Parameters
timeThe time between two Rise events
Returns
Status code

◆ SetPwm1Velocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm1Velocity ( units::angular_velocity::turns_per_second_t velocity)

Sets the simulated pulse width velocity of the CANdi.

This is the velocity of an external PWM encoder connected to the S1 pin.

Parameters
velocityThe new velocity
Returns
Status code

◆ SetPwm2Connected()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm2Connected ( bool connected)

Sets whether a PWM sensor is connected to the S2 pin.

Parameters
connectedTrue if sensor is connected
Returns
Status code

◆ SetPwm2Position()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm2Position ( units::angle::turn_t position)

Sets the simulated pulse width position of the CANdi.

This is the position of an external PWM encoder connected to the S2 pin.

Parameters
positionThe new position
Returns
Status code

◆ SetPwm2RiseFall()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm2RiseFall ( units::time::second_t time)

Sets the simulated PWM2 Rise to Fall timing of the CANdi.

Parameters
timeThe time between the Rise and Fall events in seconds
Returns
Status code

◆ SetPwm2RiseRise()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm2RiseRise ( units::time::second_t time)

Sets the simulated PWM2 Rise to Rise timing of the CANdi.

Parameters
timeThe time between two Rise events
Returns
Status code

◆ SetPwm2Velocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetPwm2Velocity ( units::angular_velocity::turns_per_second_t velocity)

Sets the simulated pulse width velocity of the CANdi.

This is the velocity of an external PWM encoder connected to the S2 pin.

Parameters
velocityThe new velocity
Returns
Status code

◆ SetQuadratureVelocity()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetQuadratureVelocity ( units::angular_velocity::turns_per_second_t velocity)

Sets the simulated pulse width velocity of the CANdi.

Parameters
velocityThe new velocity
Returns
Status code

◆ SetRawQuadraturePosition()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetRawQuadraturePosition ( units::angle::turn_t position)

Sets the simulated raw quadrature position of the CANdi.

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

The CANdi 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
positionThe raw position
Returns
Status code

◆ SetS1State()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetS1State ( ctre::phoenix6::signals::S1StateValue state)

Sets the state of the S1 pin.

Parameters
stateThe state to set the S1 pin to
Returns
Status code

◆ SetS2State()

ctre::phoenix::StatusCode ctre::phoenix6::sim::CANdiSimState::SetS2State ( ctre::phoenix6::signals::S2StateValue state)

Sets the state of the S2 pin.

Parameters
stateThe state to St the S2 pin to
Returns
Status code

◆ SetSupplyVoltage()

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

Sets the simulated supply voltage of the CANdi.

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

◆ Pwm1Orientation

ChassisReference ctre::phoenix6::sim::CANdiSimState::Pwm1Orientation

The orientation of the PWM1 sensor relative to the robot chassis.

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

◆ Pwm2Orientation

ChassisReference ctre::phoenix6::sim::CANdiSimState::Pwm2Orientation

The orientation of the PWM2 sensor relative to the robot chassis.

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

◆ QuadratureEdgesPerRotation

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

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

◆ QuadratureOrientation

ChassisReference ctre::phoenix6::sim::CANdiSimState::QuadratureOrientation

The orientation of the Quadrature sensor relative to the robot chassis.

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


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