CTRE Phoenix 6 C++ 26.3.0
Loading...
Searching...
No Matches
ctre::phoenix6::hardware::CANrange Class Reference

Class for CANrange, a CAN based Time of Flight (ToF) sensor that measures the distance to the front of the device. More...

#include <ctre/phoenix6/CANrange.hpp>

Inheritance diagram for ctre::phoenix6::hardware::CANrange:
ctre::phoenix6::hardware::core::CoreCANrange ctre::phoenix6::hardware::ParentDevice ctre::phoenix6::hardware::traits::CommonDevice

Public Member Functions

 CANrange (int deviceId, CANBus canbus={})
 Constructs a new CANrange object.
 
 CANrange (int deviceId, std::string canbus)
 Constructs a new CANrange object.
 
 ~CANrange ()
 
void InitSendable (wpi::SendableBuilder &builder) override
 
- Public Member Functions inherited from ctre::phoenix6::hardware::core::CoreCANrange
 CoreCANrange (int deviceId, CANBus canbus={})
 Constructs a new CANrange object.
 
 CoreCANrange (int deviceId, std::string canbus)
 Constructs a new CANrange object.
 
configs::CANrangeConfiguratorGetConfigurator ()
 Gets the configurator for this CANrange.
 
configs::CANrangeConfigurator const & GetConfigurator () const
 Gets the configurator for this CANrange.
 
sim::CANrangeSimStateGetSimState ()
 Get the simulation state for this device.
 
StatusSignal< int > & GetVersionMajor (bool refresh=true)
 App Major Version number.
 
StatusSignal< int > & GetVersionMinor (bool refresh=true)
 App Minor Version number.
 
StatusSignal< int > & GetVersionBugfix (bool refresh=true)
 App Bugfix Version number.
 
StatusSignal< int > & GetVersionBuild (bool refresh=true)
 App Build Version number.
 
StatusSignal< int > & GetVersion (bool refresh=true)
 Full Version of firmware in device.
 
StatusSignal< int > & GetFaultField (bool refresh=true)
 Integer representing all fault flags reported by the device.
 
StatusSignal< int > & GetStickyFaultField (bool refresh=true)
 Integer representing all (persistent) sticky fault flags reported by the device.
 
StatusSignal< bool > & GetIsProLicensed (bool refresh=true)
 Whether the device is Phoenix Pro licensed.
 
StatusSignal< units::voltage::volt_t > & GetSupplyVoltage (bool refresh=true)
 Measured supply voltage to the CANrange.
 
StatusSignal< units::length::meter_t > & GetDistance (bool refresh=true)
 Distance to the nearest object in the configured field of view of the CANrange.
 
StatusSignal< units::time::second_t > & GetMeasurementTime (bool refresh=true)
 Timestamp of the most recent measurements.
 
StatusSignal< units::dimensionless::scalar_t > & GetSignalStrength (bool refresh=true)
 Approximate signal strength of the measurement.
 
StatusSignal< bool > & GetIsDetected (bool refresh=true)
 Whether the CANrange detects an object using the configured proximity parameters.
 
StatusSignal< signals::MeasurementHealthValue > & GetMeasurementHealth (bool refresh=true)
 Health of the distance measurement.
 
StatusSignal< units::dimensionless::scalar_t > & GetAmbientSignal (bool refresh=true)
 The amount of ambient infrared light that the sensor is detecting.
 
StatusSignal< units::length::meter_t > & GetDistanceStdDev (bool refresh=true)
 Standard Deviation of the distance measurement.
 
StatusSignal< units::angle::degree_t > & GetRealFOVCenterX (bool refresh=true)
 The actual center of the FOV in the X direction.
 
StatusSignal< units::angle::degree_t > & GetRealFOVCenterY (bool refresh=true)
 The actual center of the FOV in the Y direction.
 
StatusSignal< units::angle::degree_t > & GetRealFOVRangeX (bool refresh=true)
 The actual range of the FOV in the X direction.
 
StatusSignal< units::angle::degree_t > & GetRealFOVRangeY (bool refresh=true)
 The actual range of the FOV in the Y direction.
 
StatusSignal< bool > & GetFault_Hardware (bool refresh=true)
 Hardware fault occurred.
 
StatusSignal< bool > & GetStickyFault_Hardware (bool refresh=true)
 Hardware fault occurred.
 
StatusSignal< bool > & GetFault_Undervoltage (bool refresh=true)
 Device supply voltage dropped to near brownout levels.
 
StatusSignal< bool > & GetStickyFault_Undervoltage (bool refresh=true)
 Device supply voltage dropped to near brownout levels.
 
StatusSignal< bool > & GetFault_BootDuringEnable (bool refresh=true)
 Device boot while detecting the enable signal.
 
StatusSignal< bool > & GetStickyFault_BootDuringEnable (bool refresh=true)
 Device boot while detecting the enable signal.
 
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse (bool refresh=true)
 An unlicensed feature is in use, device may not behave as expected.
 
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse (bool refresh=true)
 An unlicensed feature is in use, device may not behave as expected.
 
ctre::phoenix::StatusCode ClearStickyFaults (units::time::second_t timeoutSeconds)
 Clear the sticky faults in the device.
 
ctre::phoenix::StatusCode ClearStickyFaults ()
 Clear the sticky faults in the device.
 
ctre::phoenix::StatusCode ClearStickyFault_Hardware (units::time::second_t timeoutSeconds)
 Clear sticky fault: Hardware fault occurred.
 
ctre::phoenix::StatusCode ClearStickyFault_Hardware ()
 Clear sticky fault: Hardware fault occurred.
 
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage (units::time::second_t timeoutSeconds)
 Clear sticky fault: Device supply voltage dropped to near brownout levels.
 
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage ()
 Clear sticky fault: Device supply voltage dropped to near brownout levels.
 
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable (units::time::second_t timeoutSeconds)
 Clear sticky fault: Device boot while detecting the enable signal.
 
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable ()
 Clear sticky fault: Device boot while detecting the enable signal.
 
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse (units::time::second_t timeoutSeconds)
 Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
 
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse ()
 Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
 
- Public Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
 ParentDevice (int deviceID, std::string model, CANBus canbus)
 
virtual ~ParentDevice ()=0
 
 ParentDevice (ParentDevice const &)=delete
 
ParentDeviceoperator= (ParentDevice const &)=delete
 
int GetDeviceID () const final
 
CANBus GetNetwork () const final
 
uint64_t GetDeviceHash () const final
 Gets a number unique for this device's hardware type and ID.
 
std::shared_ptr< controls::ControlRequest const > GetAppliedControl () const final
 Get the latest applied control.
 
std::shared_ptr< controls::ControlRequestGetAppliedControl () final
 Get the latest applied control.
 
bool HasResetOccurred () final
 
std::function< bool()> GetResetOccurredChecker () const final
 
bool IsConnected (units::second_t maxLatencySeconds=500_ms) final
 Returns whether the device is still connected to the robot.
 
StatusSignal< double > & GetGenericSignal (uint32_t signal, bool refresh=true)
 This is a reserved routine for internal testing.
 
ctre::phoenix::StatusCode OptimizeBusUtilization (units::frequency::hertz_t optimizedFreqHz=4_Hz, units::time::second_t timeoutSeconds=100_ms) final
 Optimizes the device's bus utilization by reducing the update frequencies of its status signals.
 
ctre::phoenix::StatusCode ResetSignalFrequencies (units::time::second_t timeoutSeconds=100_ms) final
 Resets the update frequencies of all the device's status signals to the defaults.
 
- Public Member Functions inherited from ctre::phoenix6::hardware::traits::CommonDevice
virtual ~CommonDevice ()=default
 

Static Public Member Functions

static CANrange None ()
 Constructs a stubbed-out CANrange, where all status signals, controls, configs, etc.
 
- Static Public Member Functions inherited from ctre::phoenix6::hardware::core::CoreCANrange
static CoreCANrange None ()
 Constructs a stubbed-out CoreCANrange, where all status signals, controls, configs, etc.
 
- Static Public Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
template<std::derived_from< traits::CommonDevice >... Devices>
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (Devices &... devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
 
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (std::span< traits::CommonDevice *const > devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
 
template<std::derived_from< traits::CommonDevice >... Devices>
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (units::frequency::hertz_t optimizedFreqHz, Devices &... devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
 
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (units::frequency::hertz_t optimizedFreqHz, std::span< traits::CommonDevice *const > devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.
 
template<std::derived_from< traits::CommonDevice >... Devices>
static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll (Devices &... devices)
 Resets the update frequencies of all the devices' status signals to the defaults.
 
static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll (std::span< traits::CommonDevice *const > devices)
 Resets the update frequencies of all the devices' status signals to the defaults.
 

Additional Inherited Members

- Public Types inherited from ctre::phoenix6::hardware::core::CoreCANrange
using Configuration = configs::CANrangeConfiguration
 The configuration class for this device.
 
- Protected Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
virtual ctre::phoenix::StatusCode SetControlPrivate (controls::ControlRequest const &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::string signalName, std::function< std::map< uint16_t, std::string >()> mapFiller, bool reportOnConstruction, bool refresh)
 
- Protected Attributes inherited from ctre::phoenix6::hardware::ParentDevice
DeviceIdentifier deviceIdentifier
 
- Static Protected Attributes inherited from ctre::phoenix6::hardware::ParentDevice
static constexpr controls::EmptyControl _emptyControl {}
 

Detailed Description

Class for CANrange, a CAN based Time of Flight (ToF) sensor that measures the distance to the front of the device.

Constructor & Destructor Documentation

◆ CANrange() [1/2]

ctre::phoenix6::hardware::CANrange::CANrange ( int deviceId,
CANBus canbus = {} )

Constructs a new CANrange object.

Parameters
deviceIdID of the device, as configured in Phoenix Tuner
canbusThe CAN bus this device is on

◆ CANrange() [2/2]

ctre::phoenix6::hardware::CANrange::CANrange ( int deviceId,
std::string canbus )

Constructs a new CANrange object.

Parameters
deviceIdID of the device, as configured in Phoenix Tuner
canbusName of the CAN bus this device is on. Possible CAN bus strings are:
  • "rio" for the native roboRIO CAN bus
  • CANivore name or serial number
  • SocketCAN interface (non-FRC Linux only)
  • "*" for any CANivore seen by the program
  • empty string (default) to select the default for the system:
    • "rio" on roboRIO
    • "can0" on Linux
    • "*" on Windows
Deprecated
Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead.

◆ ~CANrange()

ctre::phoenix6::hardware::CANrange::~CANrange ( )

Member Function Documentation

◆ InitSendable()

void ctre::phoenix6::hardware::CANrange::InitSendable ( wpi::SendableBuilder & builder)
override

◆ None()

static CANrange ctre::phoenix6::hardware::CANrange::None ( )
inlinestatic

Constructs a stubbed-out CANrange, where all status signals, controls, configs, etc.

perform no action and immediately return OK. This can be used to silence error messages for devices that have been completely removed from the robot.

Returns
Stubbed-out CANrange

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