CTRE Phoenix C++ 5.33.1
|
Collection of simulation functions available to a CANCoder. More...
#include <ctre/phoenix/sensors/CANCoderSimCollection.h>
Public Member Functions | |
CANCoderSimCollection (ctre::phoenix::sensors::CANCoder &canCoder) | |
Constructor for CANCoderSimCollection. More... | |
ErrorCode | SetBusVoltage (double vbat) |
Sets the simulated bus voltage of the CANCoder. More... | |
ErrorCode | SetRawPosition (int newPos) |
Sets the simulated raw position of the CANCoder. More... | |
ErrorCode | AddPosition (int dPos) |
Adds to the simulated position of the CANCoder. More... | |
ErrorCode | SetVelocity (int newVel) |
Sets the simulated velocity of the CANCoder. More... | |
Collection of simulation functions available to a CANCoder.
Use the getSimCollection() function in your CANCoder object to create the respective sim collection.
If the Phoenix 5 API must be used for this device, the device must have 22.X firmware. This firmware is available in Tuner X after selecting Phoenix 5 in the firmware year dropdown.
ctre::phoenix::sensors::CANCoderSimCollection::CANCoderSimCollection | ( | ctre::phoenix::sensors::CANCoder & | canCoder | ) |
Constructor for CANCoderSimCollection.
canCoder | CANCoder to connect Collection to |
ErrorCode ctre::phoenix::sensors::CANCoderSimCollection::AddPosition | ( | int | dPos | ) |
Adds to the simulated position of the CANCoder.
dPos | the change in position in native units |
ErrorCode ctre::phoenix::sensors::CANCoderSimCollection::SetBusVoltage | ( | double | vbat | ) |
Sets the simulated bus voltage of the CANCoder.
The minimum allowed bus voltage is 4 V - values below this will be promoted to 4 V.
vbat | the bus voltage in volts |
ErrorCode ctre::phoenix::sensors::CANCoderSimCollection::SetRawPosition | ( | int | newPos | ) |
Sets the simulated raw position of the CANCoder.
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 your hardware API calls for home-ing your sensor.
Inputs to this function over time should be continuous, as user calls of setPosition() will be accounted for in the calculation.
newPos | the new raw position in native units |
ErrorCode ctre::phoenix::sensors::CANCoderSimCollection::SetVelocity | ( | int | newVel | ) |
Sets the simulated velocity of the CANCoder.
newVel | the new velocity in native units per 100ms |