CTRE Phoenix C++ 5.33.0
ctre::phoenix::sensors::WPI_CANCoder Class Reference

CTRE CANCoder. More...

#include <ctre/phoenix/sensors/WPI_CANCoder.h>

Inheritance diagram for ctre::phoenix::sensors::WPI_CANCoder:
ctre::phoenix::sensors::CANCoder ctre::phoenix::CANBusAddressable

Public Member Functions

 WPI_CANCoder (int deviceNumber, std::string const &canbus="")
 Construtor for CANCoder. More...
 
 ~WPI_CANCoder ()
 
 WPI_CANCoder ()=delete
 
 WPI_CANCoder (WPI_CANCoder const &)=delete
 
WPI_CANCoderoperator= (WPI_CANCoder const &)=delete
 
void InitSendable (wpi::SendableBuilder &builder) override
 
- Public Member Functions inherited from ctre::phoenix::sensors::CANCoder
 CANCoder (int deviceNumber, std::string const &canbus="")
 Constructor. More...
 
 ~CANCoder ()
 
double GetPosition ()
 Gets the position of the sensor. More...
 
double GetVelocity ()
 Sets the position of the sensor. More...
 
ErrorCode SetPosition (double newPosition, int timeoutMs=0)
 Sets the position of the sensor. More...
 
ErrorCode SetPositionToAbsolute (int timeoutMs=0)
 Sets the position of the sensor to match the magnet's "Absolute Sensor". More...
 
double GetAbsolutePosition ()
 Gets the absolute position of the sensor. More...
 
ErrorCode ConfigVelocityMeasurementPeriod (SensorVelocityMeasPeriod period, int timeoutMs=0)
 Configures the period of each velocity sample. More...
 
ErrorCode ConfigVelocityMeasurementWindow (int windowSize, int timeoutMs=0)
 Sets the number of velocity samples used in the rolling average velocity measurement. More...
 
ErrorCode ConfigAbsoluteSensorRange (ctre::phoenix::sensors::AbsoluteSensorRange absoluteSensorRange, int timeoutMs=0)
 Sets the signage and range of the "Absolute Position" signal. More...
 
ErrorCode ConfigMagnetOffset (double offsetDegrees, int timeoutMs=0)
 Adjusts the zero point for the absolute position register. More...
 
ErrorCode ConfigSensorInitializationStrategy (ctre::phoenix::sensors::SensorInitializationStrategy initializationStrategy, int timeoutMs=0)
 Pick the strategy on how to initialize the CANCoder's "Position" register. More...
 
ErrorCode ConfigFeedbackCoefficient (double sensorCoefficient, const std::string &unitString, ctre::phoenix::sensors::SensorTimeBase sensortimeBase, int timeoutMs=0)
 Choose what units you want the API to get/set. More...
 
double GetBusVoltage ()
 Gets the bus voltage seen by the device. More...
 
ctre::phoenix::sensors::MagnetFieldStrength GetMagnetFieldStrength ()
 Gets the magnet's health. More...
 
ErrorCode ConfigSensorDirection (bool bSensorDirection, int timeoutMs=0)
 Choose which direction is interpreted as positive displacement. More...
 
ErrorCode GetLastError ()
 Call GetLastError() generated by this object. More...
 
std::string GetLastUnitString ()
 Get the units for the signal retrieved in the last called get routine. More...
 
double GetLastTimestamp ()
 Get the timestamp of the CAN frame retrieved in the last called get routine. More...
 
ErrorCode ConfigSetCustomParam (int newValue, int paramIndex, int timeoutMs=0)
 Sets the value of a custom parameter. More...
 
int ConfigGetCustomParam (int paramIndex, int timeoutMs=0)
 Gets the value of a custom parameter. More...
 
ErrorCode ConfigSetParameter (ParamEnum param, double value, uint8_t subValue, int ordinal, int timeoutMs=0)
 Sets a parameter. More...
 
double ConfigGetParameter (ParamEnum param, int ordinal, int timeoutMs=0)
 Gets a parameter. More...
 
ErrorCode ConfigGetParameter (ParamEnum param, int32_t valueToSend, int32_t &valueReceived, uint8_t &subValue, int32_t ordinal, int32_t timeoutMs)
 Gets a parameter by passing an int by reference. More...
 
ErrorCode SetStatusFramePeriod (CANCoderStatusFrame statusFrame, uint8_t periodMs, int timeoutMs=0)
 Sets the period of the given status frame. More...
 
int GetStatusFramePeriod (CANCoderStatusFrame frame, int timeoutMs=0)
 Gets the period of the given status frame. More...
 
int GetFirmwareVersion ()
 Gets the firmware version of the device. More...
 
bool HasResetOccurred ()
 Returns true if the device has reset since last call. More...
 
ErrorCode GetFaults (CANCoderFaults &toFill)
 Gets the CANCoder fault status. More...
 
ErrorCode GetStickyFaults (CANCoderStickyFaults &toFill)
 Gets the CANCoder sticky fault status. More...
 
ErrorCode ClearStickyFaults (int timeoutMs=0)
 Clears the Sticky Faults. More...
 
ctre::phoenix::ErrorCode ConfigAllSettings (const CANCoderConfiguration &allConfigs, int timeoutMs=50)
 Configures all persistent settings. More...
 
ErrorCode GetAllConfigs (CANCoderConfiguration &allConfigs, int timeoutMs=50)
 Gets all persistant settings. More...
 
ErrorCode ConfigFactoryDefault (int timeoutMs=50)
 Configures all persistent settings to defaults (overloaded so timeoutMs is 50 ms). More...
 
CANCoderSimCollectionGetSimCollection ()
 
- Public Member Functions inherited from ctre::phoenix::CANBusAddressable
 CANBusAddressable (int deviceNumber)
 Constructor for a CANBusAddressable device. More...
 
int GetDeviceNumber ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ctre::phoenix::sensors::CANCoder
static void DestroyAllCANCoders ()
 Destructs all CANCoder objects. More...
 

Detailed Description

CTRE CANCoder.

Deprecated:
This device's Phoenix 5 API is deprecated for removal in the 2025 season. Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API. A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.

If the Phoenix 5 API must be used for this device, the device must have 22.X firmware. This firmware is available in Tuner X after selecting Phoenix 5 in the firmware year dropdown.

Constructor & Destructor Documentation

◆ WPI_CANCoder() [1/3]

ctre::phoenix::sensors::WPI_CANCoder::WPI_CANCoder ( int  deviceNumber,
std::string const &  canbus = "" 
)

Construtor for CANCoder.

Parameters
deviceNumberCAN Device ID of the CANCoder.
canbusName of the CANbus; can be a CANivore device name or serial number. Pass in nothing or "rio" to use the roboRIO.

◆ ~WPI_CANCoder()

ctre::phoenix::sensors::WPI_CANCoder::~WPI_CANCoder ( )

◆ WPI_CANCoder() [2/3]

ctre::phoenix::sensors::WPI_CANCoder::WPI_CANCoder ( )
delete

◆ WPI_CANCoder() [3/3]

ctre::phoenix::sensors::WPI_CANCoder::WPI_CANCoder ( WPI_CANCoder const &  )
delete

Member Function Documentation

◆ InitSendable()

void ctre::phoenix::sensors::WPI_CANCoder::InitSendable ( wpi::SendableBuilder &  builder)
override

◆ operator=()

WPI_CANCoder & ctre::phoenix::sensors::WPI_CANCoder::operator= ( WPI_CANCoder const &  )
delete

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