CTRE Phoenix 6 C++ 24.3.0
ctre::phoenix6::hardware::CANcoder Class Reference

Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity. More...

#include <ctre/phoenix6/CANcoder.hpp>

Inheritance diagram for ctre::phoenix6::hardware::CANcoder:
ctre::phoenix6::hardware::core::CoreCANcoder ctre::phoenix6::hardware::ParentDevice

Public Member Functions

 CANcoder (int deviceId, std::string canbus="")
 Constructs a new CANcoder object. More...
 
 ~CANcoder ()
 
 CANcoder (CANcoder &&)=default
 
CANcoderoperator= (CANcoder &&)=default
 
void InitSendable (wpi::SendableBuilder &builder) override
 
- Public Member Functions inherited from ctre::phoenix6::hardware::core::CoreCANcoder
 CoreCANcoder (int deviceId, std::string canbus="")
 Constructs a new CANcoder object. More...
 
 CoreCANcoder (CoreCANcoder &&)=default
 
CoreCANcoderoperator= (CoreCANcoder &&)=default
 
configs::CANcoderConfiguratorGetConfigurator ()
 Gets the configurator for this CANcoder. More...
 
configs::CANcoderConfigurator const & GetConfigurator () const
 Gets the configurator for this CANcoder. More...
 
sim::CANcoderSimStateGetSimState ()
 Get the simulation state for this device. More...
 
StatusSignal< int > & GetVersionMajor ()
 App Major Version number. More...
 
StatusSignal< int > & GetVersionMinor ()
 App Minor Version number. More...
 
StatusSignal< int > & GetVersionBugfix ()
 App Bugfix Version number. More...
 
StatusSignal< int > & GetVersionBuild ()
 App Build Version number. More...
 
StatusSignal< int > & GetVersion ()
 Full Version. More...
 
StatusSignal< int > & GetFaultField ()
 Integer representing all faults. More...
 
StatusSignal< int > & GetStickyFaultField ()
 Integer representing all sticky faults. More...
 
StatusSignal< units::angular_velocity::turns_per_second_t > & GetVelocity ()
 Velocity of the device. More...
 
StatusSignal< units::angle::turn_t > & GetPosition ()
 Position of the device. More...
 
StatusSignal< units::angle::turn_t > & GetAbsolutePosition ()
 Absolute Position of the device. More...
 
StatusSignal< units::angular_velocity::turns_per_second_t > & GetUnfilteredVelocity ()
 The unfiltered velocity reported by CANcoder. More...
 
StatusSignal< units::angle::turn_t > & GetPositionSinceBoot ()
 The relative position reported by the CANcoder since boot. More...
 
StatusSignal< units::voltage::volt_t > & GetSupplyVoltage ()
 Measured supply voltage to the CANcoder. More...
 
StatusSignal< signals::MagnetHealthValue > & GetMagnetHealth ()
 Magnet health as measured by CANcoder. More...
 
StatusSignal< bool > & GetIsProLicensed ()
 Whether the device is Phoenix Pro licensed. More...
 
StatusSignal< bool > & GetFault_Hardware ()
 Hardware fault occurred. More...
 
StatusSignal< bool > & GetStickyFault_Hardware ()
 Hardware fault occurred. More...
 
StatusSignal< bool > & GetFault_Undervoltage ()
 Device supply voltage dropped to near brownout levels. More...
 
StatusSignal< bool > & GetStickyFault_Undervoltage ()
 Device supply voltage dropped to near brownout levels. More...
 
StatusSignal< bool > & GetFault_BootDuringEnable ()
 Device boot while detecting the enable signal. More...
 
StatusSignal< bool > & GetStickyFault_BootDuringEnable ()
 Device boot while detecting the enable signal. More...
 
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse ()
 An unlicensed feature is in use, device may not behave as expected. More...
 
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse ()
 An unlicensed feature is in use, device may not behave as expected. More...
 
StatusSignal< bool > & GetFault_BadMagnet ()
 The magnet distance is not correct or magnet is missing. More...
 
StatusSignal< bool > & GetStickyFault_BadMagnet ()
 The magnet distance is not correct or magnet is missing. More...
 
ctre::phoenix::StatusCode SetControl (controls::ControlRequest &request)
 Control motor with generic control request object. More...
 
ctre::phoenix::StatusCode SetControl (controls::ControlRequest &&request)
 Control motor with generic control request object. More...
 
ctre::phoenix::StatusCode SetPosition (units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
 Sets the current position of the device. More...
 
ctre::phoenix::StatusCode SetPosition (units::angle::turn_t newValue)
 Sets the current position of the device. More...
 
ctre::phoenix::StatusCode ClearStickyFaults (units::time::second_t timeoutSeconds)
 Clear the sticky faults in the device. More...
 
ctre::phoenix::StatusCode ClearStickyFaults ()
 Clear the sticky faults in the device. More...
 
ctre::phoenix::StatusCode ClearStickyFault_Hardware (units::time::second_t timeoutSeconds)
 Clear sticky fault: Hardware fault occurred. More...
 
ctre::phoenix::StatusCode ClearStickyFault_Hardware ()
 Clear sticky fault: Hardware fault occurred. More...
 
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage (units::time::second_t timeoutSeconds)
 Clear sticky fault: Device supply voltage dropped to near brownout levels. More...
 
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage ()
 Clear sticky fault: Device supply voltage dropped to near brownout levels. More...
 
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable (units::time::second_t timeoutSeconds)
 Clear sticky fault: Device boot while detecting the enable signal. More...
 
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable ()
 Clear sticky fault: Device boot while detecting the enable signal. More...
 
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet (units::time::second_t timeoutSeconds)
 Clear sticky fault: The magnet distance is not correct or magnet is missing. More...
 
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet ()
 Clear sticky fault: The magnet distance is not correct or magnet is missing. More...
 
- Public Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
 ParentDevice (int deviceID, std::string model, std::string canbus)
 
virtual ~ParentDevice ()=default
 
 ParentDevice (ParentDevice &&)=default
 
ParentDeviceoperator= (ParentDevice &&)=default
 
int GetDeviceID () const
 
const std::string & GetNetwork () const
 
uint64_t GetDeviceHash () const
 Gets a number unique for this device's hardware type and ID. More...
 
std::shared_ptr< const controls::ControlRequestGetAppliedControl () const
 Get the latest applied control. More...
 
std::shared_ptr< controls::ControlRequestGetAppliedControl ()
 Get the latest applied control. More...
 
bool HasResetOccurred ()
 
std::function< bool()> GetResetOccurredChecker () const
 
StatusSignal< double > & GetGenericSignal (uint32_t signal)
 This is a reserved routine for internal testing. More...
 
ctre::phoenix::StatusCode OptimizeBusUtilization (units::frequency::hertz_t optimizedFreqHz=0_Hz, units::time::second_t timeoutSeconds=50_ms)
 Optimizes the device's bus utilization by reducing the update frequencies of its status signals. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
template<typename... Devices, typename = std::enable_if_t<is_all_device_v<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. More...
 
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (const std::vector< ParentDevice * > &devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals. More...
 
template<size_t N>
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (const std::array< ParentDevice *, N > &devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals. More...
 
template<typename... Devices, typename = std::enable_if_t<is_all_device_v<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. More...
 
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (units::frequency::hertz_t optimizedFreqHz, const std::vector< ParentDevice * > &devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals. More...
 
template<size_t N>
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll (units::frequency::hertz_t optimizedFreqHz, const std::array< ParentDevice *, N > &devices)
 Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals. More...
 
- Protected Member Functions inherited from ctre::phoenix6::hardware::ParentDevice
virtual ctre::phoenix::StatusCode SetControlPrivate (controls::ControlRequest &request)
 
template<typename T >
StatusSignal< T > & LookupStatusSignal (uint16_t spn, std::string signalName, bool reportOnConstruction)
 
template<typename T >
StatusSignal< T > & LookupStatusSignal (uint16_t spn, uint16_t mapper_iter, std::function< std::map< int, StatusSignal< T > >()> map_filler, std::string signalName, bool reportOnConstruction)
 
template<typename T , typename U >
StatusSignal< T > LookupDimensionlessStatusSignal (uint16_t spn, std::string signalName)
 Returns a unitless version of the StatusSignal by value. More...
 
- Protected Attributes inherited from ctre::phoenix6::hardware::ParentDevice
DeviceIdentifier deviceIdentifier
 
- Static Protected Attributes inherited from ctre::phoenix6::hardware::ParentDevice
static controls::EmptyControl _emptyControl {}
 
template<typename... Devices>
static constexpr bool is_all_device_v = is_all_device<Devices...>::value
 Whether all types passed in are subclasses of ParentDevice. More...
 

Detailed Description

Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity.

Constructor & Destructor Documentation

◆ CANcoder() [1/2]

ctre::phoenix6::hardware::CANcoder::CANcoder ( int  deviceId,
std::string  canbus = "" 
)

Constructs a new CANcoder 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

◆ ~CANcoder()

ctre::phoenix6::hardware::CANcoder::~CANcoder ( )

◆ CANcoder() [2/2]

ctre::phoenix6::hardware::CANcoder::CANcoder ( CANcoder &&  )
default

Member Function Documentation

◆ InitSendable()

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

◆ operator=()

CANcoder & ctre::phoenix6::hardware::CANcoder::operator= ( CANcoder &&  )
default

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