Status Signals¶
Phoenix 6 expands the functionality of status signals with the introduction of the StatusSignal
(Java, C++).
Note
For more information about status signals in Phoenix 6, see Status Signals.
Using Status Signals¶
v5 |
// get latest TalonFX selected sensor position
// units are encoder ticks
int sensorPos = m_talonFX.getSelectedSensorPosition();
// latency is unknown
// cannot synchronously wait for new data
// get latest TalonFX selected sensor position
// units are encoder ticks
int sensorPos = m_talonFX.GetSelectedSensorPosition();
// latency is unknown
// cannot synchronously wait for new data
|
v6 |
// acquire a refreshed TalonFX rotor position signal
var rotorPosSignal = m_talonFX.getRotorPosition();
// because we are calling getRotorPosition() every loop,
// we do not need to call refresh()
//rotorPosSignal.refresh();
// retrieve position value that we just refreshed
// units are rotations, uses the units library
var rotorPos = rotorPosSignal.getValue();
// the units library can be bypassed using getValueAsDouble()
double rotorPosRotations = rotorPosSignal.getValueAsDouble();
// get latency of the signal
var rotorPosLatency = rotorPosSignal.getTimestamp().getLatency();
// synchronously wait 20 ms for new data
rotorPosSignal.waitForUpdate(0.020);
// acquire a refreshed TalonFX rotor position signal
auto& rotorPosSignal = m_talonFX.GetRotorPosition();
// because we are calling GetRotorPosition() every loop,
// we do not need to call Refresh()
//rotorPosSignal.Refresh();
// retrieve position value that we just refreshed
// units are rotations, uses the units library
auto rotorPos = rotorPosSignal.GetValue();
// get latency of the signal
auto rotorPosLatency = rotorPosSignal.GetTimestamp().GetLatency();
// synchronously wait 20 ms for new data
rotorPosSignal.WaitForUpdate(20_ms);
|
Changing Update Frequency (Status Frame Period)¶
v5 |
// slow down the Status 2 frame (selected sensor data) to 5 Hz (200ms)
m_talonFX.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0, 200);
// slow down the Status 2 frame (selected sensor data) to 5 Hz (200ms)
m_talonFX.SetStatusFramePeriod(StatusFrameEnhanced::Status_2_Feedback0, 200);
|
v6 |
// slow down the position signal to 5 Hz
m_talonFX.getPosition().setUpdateFrequency(5);
// slow down the position signal to 5 Hz
m_talonFX.GetPosition().SetUpdateFrequency(5_Hz);
|
Note
When different update frequencies are specified for signals that share a status frame, the highest update frequency of all the relevant signals will be applied to the entire frame. Users can get a signal’s applied update frequency using the getAppliedUpdateFrequency()
method.
Common Signals¶
Several status signals have changed name or form in Phoenix 6.
General Signals¶
Phoenix 5 |
Phoenix 6 |
---|---|
|
|
|
|
|
|
Talon FX Signals¶
Phoenix 5 |
Phoenix 6 |
---|---|
|
|
|
StatorCurrent (motoring +, braking -),TorqueCurrent (forward +, reverse -) |
|
|
|
|
|
|
|
|
|
|
CANcoder Signals¶
Phoenix 5 |
Phoenix 6 |
---|---|
|
|
Pigeon 2 Signals¶
Note
Many Pigeon 2 signal getters in Phoenix 5 fill an array, such as YawPitchRoll
. In Phoenix 6, these signals have been broken up into their individual components, such as Yaw
, Pitch
, and Roll
.
Phoenix 5 |
Phoenix 6 |
---|---|
|
|
|
|
|
|
|
|
|
|