Parent class for all devices.
More...
#include <ctre/phoenix6/hardware/ParentDevice.hpp>
|
virtual ctre::phoenix::StatusCode | SetControlPrivate (const controls::ControlRequest &request) |
|
template<typename T > |
StatusSignal< T > & | LookupStatusSignal (uint16_t spn, std::string signalName, bool reportOnConstruction, bool refresh) |
|
template<typename T > |
StatusSignal< T > & | LookupStatusSignal (uint16_t spn, std::function< std::map< uint16_t, std::string >()> mapFiller, std::string signalName, bool reportOnConstruction, bool refresh) |
|
template<typename T , typename U > |
StatusSignal< T > | LookupDimensionlessStatusSignal (uint16_t spn, std::string signalName, bool refresh) |
| Returns a unitless version of the StatusSignal by value.
|
|
Parent class for all devices.
◆ ParentDevice() [1/2]
ctre::phoenix6::hardware::ParentDevice::ParentDevice |
( |
int | deviceID, |
|
|
std::string | model, |
|
|
std::string | canbus ) |
|
inline |
◆ ~ParentDevice()
virtual ctre::phoenix6::hardware::ParentDevice::~ParentDevice |
( |
| ) |
|
|
virtualdefault |
◆ ParentDevice() [2/2]
◆ GetAppliedControl() [1/2]
Get the latest applied control.
Caller can cast this to the derived class if they know its type. Otherwise, use controls::ControlRequest::GetControlInfo to get info out of it.
This returns a shared pointer to avoid becoming a dangling pointer due to parallel operations changing the underlying data. Make sure to save the shared_ptr to a variable before chaining function calls, otherwise the data may be freed early.
- Returns
- Latest applied control
◆ GetAppliedControl() [2/2]
Get the latest applied control.
Caller can cast this to the derived class if they know its type. Otherwise, use controls::ControlRequest::GetControlInfo to get info out of it.
This returns a shared pointer to avoid becoming a dangling pointer due to parallel operations changing the underlying data. Make sure to save the shared_ptr to a variable before chaining function calls, otherwise the data may be freed early.
- Returns
- Latest applied control
◆ GetDeviceHash()
uint64_t ctre::phoenix6::hardware::ParentDevice::GetDeviceHash |
( |
| ) |
const |
|
inline |
Gets a number unique for this device's hardware type and ID.
This number is not unique across networks.
This can be used to easily reference hardware devices on the same network in collections such as maps.
- Returns
- Hash of this device.
◆ GetDeviceID()
int ctre::phoenix6::hardware::ParentDevice::GetDeviceID |
( |
| ) |
const |
|
inline |
- Returns
- The device ID of this device [0,62].
◆ GetGenericSignal()
This is a reserved routine for internal testing.
Use the other get routines to retrieve signal values.
- Parameters
-
signal | Signal to get. |
refresh | Whether to refresh |
- Returns
- StatusSignalValue holding value
◆ GetNetwork()
const std::string & ctre::phoenix6::hardware::ParentDevice::GetNetwork |
( |
| ) |
const |
|
inline |
- Returns
- Name of the network this device is on.
◆ GetResetOccurredChecker()
std::function< bool()> ctre::phoenix6::hardware::ParentDevice::GetResetOccurredChecker |
( |
| ) |
const |
|
inline |
- Returns
- a function that checks for device resets.
◆ HasResetOccurred()
bool ctre::phoenix6::hardware::ParentDevice::HasResetOccurred |
( |
| ) |
|
|
inline |
- Returns
- true if device has reset since the previous call of this routine.
◆ IsConnected()
bool ctre::phoenix6::hardware::ParentDevice::IsConnected |
( |
units::second_t | maxLatencySeconds = 500_ms | ) |
|
|
inline |
Returns whether the device is still connected to the robot.
This is equivalent to refreshing and checking the latency of the Version status signal.
- Parameters
-
maxLatencySeconds | The maximum latency of the Version status signal before the device is reported as disconnected |
- Returns
- true if the device is connected
◆ LookupDimensionlessStatusSignal()
StatusSignal< T > ctre::phoenix6::hardware::ParentDevice::LookupDimensionlessStatusSignal |
( |
uint16_t | spn, |
|
|
std::string | signalName, |
|
|
bool | refresh ) |
|
inlineprotected |
Returns a unitless version of the StatusSignal by value.
Do not store the result in a reference.
◆ LookupStatusSignal() [1/2]
template<typename T >
StatusSignal< T > & ctre::phoenix6::hardware::ParentDevice::LookupStatusSignal |
( |
uint16_t | spn, |
|
|
std::function< std::map< uint16_t, std::string >()> | mapFiller, |
|
|
std::string | signalName, |
|
|
bool | reportOnConstruction, |
|
|
bool | refresh ) |
|
inlineprotected |
◆ LookupStatusSignal() [2/2]
template<typename T >
StatusSignal< T > & ctre::phoenix6::hardware::ParentDevice::LookupStatusSignal |
( |
uint16_t | spn, |
|
|
std::string | signalName, |
|
|
bool | reportOnConstruction, |
|
|
bool | refresh ) |
|
inlineprotected |
◆ operator=()
◆ OptimizeBusUtilization()
ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::OptimizeBusUtilization |
( |
units::frequency::hertz_t | optimizedFreqHz = 0_Hz, |
|
|
units::time::second_t | timeoutSeconds = 100_ms ) |
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequencies. Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
- Parameters
-
optimizedFreqHz | The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz. |
timeoutSeconds | Maximum amount of time to wait for each status frame when performing the action |
- Returns
- Status code of the first failed update frequency set call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [1/6]
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to optimize bus utilization, passed as an array of device addresses. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [2/6]
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to optimize bus utilization, passed as a vector or initializer list of device addresses. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [3/6]
template<typename... Devices,
typename = std::enable_if_t<is_all_device_v<Devices...>>>
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to optimize bus utilization, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [4/6]
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
optimizedFreqHz | The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz. |
devices | Devices for which to optimize bus utilization, passed as an array of device addresses. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [5/6]
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
optimizedFreqHz | The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz. |
devices | Devices for which to optimize bus utilization, passed as a vector or initializer list of device addresses. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [6/6]
template<typename... Devices,
typename = std::enable_if_t<is_all_device_v<Devices...>>>
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
All status signals that have not been explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.
This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, call ResetSignalFrequenciesForAll. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
optimizedFreqHz | The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz. |
devices | Devices for which to optimize bus utilization, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ ResetSignalFrequencies()
ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::ResetSignalFrequencies |
( |
units::time::second_t | timeoutSeconds = 100_ms | ) |
|
Resets the update frequencies of all the device's status signals to the defaults.
This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency and status signals optimized out using OptimizeBusUtilization.
- Parameters
-
timeoutSeconds | Maximum amount of time to wait for each status frame when performing the action |
- Returns
- Status code of the first failed update frequency set call, or OK if all succeeded
◆ ResetSignalFrequenciesForAll() [1/3]
Resets the update frequencies of all the devices' status signals to the defaults.
This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency and status signals optimized out using OptimizeBusUtilizationForAll.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to restore default update frequencies, passed as an array of device addresses. |
- Returns
- Status code of the first failed restore call, or OK if all succeeded
◆ ResetSignalFrequenciesForAll() [2/3]
Resets the update frequencies of all the devices' status signals to the defaults.
This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency and status signals optimized out using OptimizeBusUtilizationForAll.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to restore default update frequencies, passed as a vector or initializer list of device addresses. |
- Returns
- Status code of the first failed restore call, or OK if all succeeded
◆ ResetSignalFrequenciesForAll() [3/3]
template<typename... Devices,
typename = std::enable_if_t<is_all_device_v<Devices...>>>
Resets the update frequencies of all the devices' status signals to the defaults.
This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal::SetUpdateFrequency and status signals optimized out using OptimizeBusUtilizationForAll.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
devices | Devices for which to restore default update frequencies, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed restore call, or OK if all succeeded
◆ SetControlPrivate()
◆ _emptyControl
◆ deviceIdentifier
◆ is_all_device_v
template<typename... Devices>
The documentation for this class was generated from the following file: