CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
ctre::phoenix6::hardware::traits::CommonDevice Class Referenceabstract

Contains everything common between Phoenix 6 devices. More...

#include <ctre/phoenix6/hardware/traits/CommonDevice.hpp>

Inheritance diagram for ctre::phoenix6::hardware::traits::CommonDevice:
ctre::phoenix6::hardware::ParentDevice ctre::phoenix6::hardware::traits::HasExternalMotor ctre::phoenix6::hardware::traits::HasTalonControls ctre::phoenix6::hardware::traits::HasTalonSignals ctre::phoenix6::hardware::traits::SupportsFOC ctre::phoenix6::hardware::traits::SupportsMusic ctre::phoenix6::hardware::core::CoreCANcoder ctre::phoenix6::hardware::core::CoreCANdi ctre::phoenix6::hardware::core::CoreCANdle ctre::phoenix6::hardware::core::CoreCANrange ctre::phoenix6::hardware::core::CorePigeon2 ctre::phoenix6::hardware::core::CoreTalonFX ctre::phoenix6::hardware::core::CoreTalonFXS ctre::phoenix6::hardware::traits::CommonTalonWithExternalMotor ctre::phoenix6::hardware::traits::CommonTalon ctre::phoenix6::hardware::traits::CommonTalon ctre::phoenix6::hardware::traits::CommonTalonWithFOC ctre::phoenix6::hardware::traits::CommonTalonWithFOC

Public Member Functions

virtual ~CommonDevice ()=default
 
virtual int GetDeviceID () const =0
 
virtual CANBus GetNetwork () const =0
 
virtual uint64_t GetDeviceHash () const =0
 Gets a number unique for this device's hardware type and ID.
 
virtual std::shared_ptr< controls::ControlRequest const > GetAppliedControl () const =0
 Get the latest applied control.
 
virtual std::shared_ptr< controls::ControlRequestGetAppliedControl ()=0
 Get the latest applied control.
 
virtual bool HasResetOccurred ()=0
 
virtual std::function< bool()> GetResetOccurredChecker () const =0
 
virtual bool IsConnected (units::second_t maxLatencySeconds=500_ms)=0
 Returns whether the device is still connected to the robot.
 
virtual ctre::phoenix::StatusCode OptimizeBusUtilization (units::frequency::hertz_t optimizedFreqHz=4_Hz, units::time::second_t timeoutSeconds=100_ms)=0
 Optimizes the device's bus utilization by reducing the update frequencies of its status signals.
 
virtual ctre::phoenix::StatusCode ResetSignalFrequencies (units::time::second_t timeoutSeconds=100_ms)=0
 Resets the update frequencies of all the device's status signals to the defaults.
 

Detailed Description

Contains everything common between Phoenix 6 devices.

Constructor & Destructor Documentation

◆ ~CommonDevice()

virtual ctre::phoenix6::hardware::traits::CommonDevice::~CommonDevice ( )
virtualdefault

Member Function Documentation

◆ GetAppliedControl() [1/2]

virtual std::shared_ptr< controls::ControlRequest const > ctre::phoenix6::hardware::traits::CommonDevice::GetAppliedControl ( ) const
pure virtual

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

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ GetAppliedControl() [2/2]

virtual std::shared_ptr< controls::ControlRequest > ctre::phoenix6::hardware::traits::CommonDevice::GetAppliedControl ( )
pure virtual

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

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ GetDeviceHash()

virtual uint64_t ctre::phoenix6::hardware::traits::CommonDevice::GetDeviceHash ( ) const
pure virtual

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.

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ GetDeviceID()

virtual int ctre::phoenix6::hardware::traits::CommonDevice::GetDeviceID ( ) const
pure virtual
Returns
The device ID of this device [0,62].

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ GetNetwork()

virtual CANBus ctre::phoenix6::hardware::traits::CommonDevice::GetNetwork ( ) const
pure virtual
Returns
The network this device is on.

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ GetResetOccurredChecker()

virtual std::function< bool()> ctre::phoenix6::hardware::traits::CommonDevice::GetResetOccurredChecker ( ) const
pure virtual
Returns
a function that checks for device resets.

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ HasResetOccurred()

virtual bool ctre::phoenix6::hardware::traits::CommonDevice::HasResetOccurred ( )
pure virtual
Returns
true if device has reset since the previous call of this routine.

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ IsConnected()

virtual bool ctre::phoenix6::hardware::traits::CommonDevice::IsConnected ( units::second_t maxLatencySeconds = 500_ms)
pure virtual

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
maxLatencySecondsThe maximum latency of the Version status signal before the device is reported as disconnected
Returns
true if the device is connected

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ OptimizeBusUtilization()

virtual ctre::phoenix::StatusCode ctre::phoenix6::hardware::traits::CommonDevice::OptimizeBusUtilization ( units::frequency::hertz_t optimizedFreqHz = 4_Hz,
units::time::second_t timeoutSeconds = 100_ms )
pure virtual

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 slowed down. 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
optimizedFreqHzThe update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).
timeoutSecondsMaximum 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

Implemented in ctre::phoenix6::hardware::ParentDevice.

◆ ResetSignalFrequencies()

virtual ctre::phoenix::StatusCode ctre::phoenix6::hardware::traits::CommonDevice::ResetSignalFrequencies ( units::time::second_t timeoutSeconds = 100_ms)
pure virtual

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
timeoutSecondsMaximum 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

Implemented in ctre::phoenix6::hardware::ParentDevice.


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