CTRE Phoenix Pro C++ 23.0.12
|
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity. More...
#include <ctre/phoenixpro/core/CoreCANcoder.hpp>
Public Member Functions | |
CoreCANcoder (int deviceId, std::string canbus="") | |
Constructs a new CANcoder object. More... | |
CoreCANcoder (CoreCANcoder const &)=delete | |
CoreCANcoder & | operator= (CoreCANcoder const &)=delete |
bool | HasResetOccurred () |
configs::CANcoderConfigurator & | GetConfigurator () |
Gets the configurator for this CANcoder. More... | |
configs::CANcoderConfigurator const & | GetConfigurator () const |
Gets the configurator for this CANcoder. More... | |
sim::CANcoderSimState & | GetSimState () |
Get the simulation state for this device. More... | |
StatusSignalValue< int > & | GetVersionMajor () |
App Major Version number. More... | |
StatusSignalValue< int > & | GetVersionMinor () |
App Minor Version number. More... | |
StatusSignalValue< int > & | GetVersionBugfix () |
App Bugfix Version number. More... | |
StatusSignalValue< int > & | GetVersionBuild () |
App Build Version number. More... | |
StatusSignalValue< int > & | GetVersion () |
Full Version. More... | |
StatusSignalValue< int > & | GetFaultField () |
Integer representing all faults. More... | |
StatusSignalValue< int > & | GetStickyFaultField () |
Integer representing all sticky faults. More... | |
StatusSignalValue< units::angular_velocity::turns_per_second_t > & | GetVelocity () |
Velocity of device. More... | |
StatusSignalValue< units::angle::turn_t > & | GetPosition () |
Position of device. More... | |
StatusSignalValue< units::angle::turn_t > & | GetAbsolutePosition () |
Absolute Position of device. More... | |
StatusSignalValue< units::angular_velocity::turns_per_second_t > & | GetUnfilteredVelocity () |
The unfiltered velocity reported by CANcoder. More... | |
StatusSignalValue< units::angle::turn_t > & | GetPositionSinceBoot () |
The relative position reported by the CANcoder since boot. More... | |
StatusSignalValue< units::voltage::volt_t > & | GetSupplyVoltage () |
Measured supply voltage to the CANcoder. More... | |
StatusSignalValue< signals::MagnetHealthValue > & | GetMagnetHealth () |
Magnet health as measured by CANcoder. More... | |
StatusSignalValue< bool > & | GetFault_Hardware () |
Hardware fault occurred. More... | |
StatusSignalValue< bool > & | GetStickyFault_Hardware () |
Hardware fault occurred. More... | |
StatusSignalValue< bool > & | GetFault_Undervoltage () |
Device supply voltage dropped to near brownout levels. More... | |
StatusSignalValue< bool > & | GetStickyFault_Undervoltage () |
Device supply voltage dropped to near brownout levels. More... | |
StatusSignalValue< bool > & | GetFault_BootDuringEnable () |
Device boot while detecting the enable signal. More... | |
StatusSignalValue< bool > & | GetStickyFault_BootDuringEnable () |
Device boot while detecting the enable signal. More... | |
StatusSignalValue< bool > & | GetFault_BadMagnet () |
The magnet distance is not correct or magnet is missing. More... | |
StatusSignalValue< 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) |
The position to set the sensor position to right now. More... | |
ctre::phoenix::StatusCode | SetPosition (units::angle::turn_t newValue) |
The position to set the sensor position to right now. 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... | |
Public Member Functions inherited from ctre::phoenixpro::hardware::ParentDevice | |
ParentDevice (int deviceID, std::string model, std::string canbus) | |
int | GetDeviceID () const |
const std::string & | GetCANBus () const |
std::shared_ptr< const controls::ControlRequest > | GetAppliedControl () const |
Get the latest applied control. More... | |
std::shared_ptr< controls::ControlRequest > | GetAppliedControl () |
Get the latest applied control. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from ctre::phoenixpro::hardware::ParentDevice | |
static constexpr double | kDefaultControlRatePeriodsSec = 0.010 |
Protected Member Functions inherited from ctre::phoenixpro::hardware::ParentDevice | |
virtual void | ReportIfTooOld ()=0 |
virtual ctre::phoenix::StatusCode | SetControlPrivate (controls::ControlRequest &request) |
template<typename T > | |
StatusSignalValue< T > & | LookupStatusSignalValue (uint16_t spn, std::string signalName, bool reportOnConstruction) |
template<typename T > | |
StatusSignalValue< T > & | LookupStatusSignalValue (uint16_t spn, uint16_t mapper_iter, std::function< std::map< int, StatusSignalValue< T > >()> map_filler, std::string signalName, bool reportOnConstruction) |
template<typename T , typename U > | |
StatusSignalValue< T > | LookupDimensionlessStatusSignalValue (uint16_t spn, std::string signalName) |
Returns a unitless version of the StatusSignalValue by value. More... | |
void | ReportIfTooOld (int minMajor, int minMinor, int minBugfix, int minBuild) |
Protected Attributes inherited from ctre::phoenixpro::hardware::ParentDevice | |
DeviceIdentifier | deviceIdentifier |
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity.
ctre::phoenixpro::hardware::core::CoreCANcoder::CoreCANcoder | ( | int | deviceId, |
std::string | canbus = "" |
||
) |
Constructs a new CANcoder object.
deviceId | ID of the device, as configured in Phoenix Tuner. |
canbus | Name of the CAN bus this device is on. Possible CAN bus strings are:
|
|
delete |
|
inline |
Clear the sticky faults in the device.
This typically has no impact on the device functionality. Instead, it just clears telemetry faults that are accessible via API and Tuner Self-Test.
This will wait up to 0.050 seconds (50ms) by default.
|
inline |
Clear the sticky faults in the device.
This typically has no impact on the device functionality. Instead, it just clears telemetry faults that are accessible via API and Tuner Self-Test.
timeoutSeconds | Maximum time to wait up to in seconds. |
StatusSignalValue< units::angle::turn_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetAbsolutePosition | ( | ) |
Absolute Position of device.
The possible range is documented below, however the exact expected range is determined by the AbsoluteSensorRange.
Minimum Value: -0.5 Maximum Value: 0.999755859375 Default Value: 0 Units: rotations
Default Rates: CAN: 100.0 Hz
|
inline |
|
inline |
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetFault_BadMagnet | ( | ) |
The magnet distance is not correct or magnet is missing.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetFault_BootDuringEnable | ( | ) |
Device boot while detecting the enable signal.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetFault_Hardware | ( | ) |
Hardware fault occurred.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetFault_Undervoltage | ( | ) |
Device supply voltage dropped to near brownout levels.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetFaultField | ( | ) |
Integer representing all faults.
This returns the fault flags reported by the device. These are device specific and are not used directly in typical applications. Use the signal specific GetFault_*() methods instead.
Minimum Value: 0 Maximum Value: 1048575 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< signals::MagnetHealthValue > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetMagnetHealth | ( | ) |
Magnet health as measured by CANcoder.
Magnet health as measured by CANcoder. Red indicates too close or too far, Orange is adequate but with reduced accuracy, green is ideal. Invalid means the accuracy cannot be determined.
Default Rates: CAN 2.0: 10.0 Hz CAN FD: 100.0 Hz
StatusSignalValue< units::angle::turn_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetPosition | ( | ) |
Position of device.
Minimum Value: -16384.0 Maximum Value: 16383.999755859375 Default Value: 0 Units: rotations
Default Rates: CAN: 100.0 Hz
StatusSignalValue< units::angle::turn_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetPositionSinceBoot | ( | ) |
The relative position reported by the CANcoder since boot.
This is the total displacement reported by CANcoder since power up. This signal is relative and is not influenced by the fusing algorithm. It is also not timesynced. If you wish to use a signal with timesync, use Position.
Minimum Value: -16384.0 Maximum Value: 16383.999755859375 Default Value: 0 Units: rotations
Default Rates: CAN 2.0: 10.0 Hz CAN FD: 100.0 Hz
|
inline |
Get the simulation state for this device.
This function reuses an allocated simulation state object, so it is safe to call this function multiple times in a robot loop.
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetStickyFault_BadMagnet | ( | ) |
The magnet distance is not correct or magnet is missing.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetStickyFault_BootDuringEnable | ( | ) |
Device boot while detecting the enable signal.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetStickyFault_Hardware | ( | ) |
Hardware fault occurred.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< bool > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetStickyFault_Undervoltage | ( | ) |
Device supply voltage dropped to near brownout levels.
Default Value: False
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetStickyFaultField | ( | ) |
Integer representing all sticky faults.
This returns the persistent "sticky" fault flags reported by the device. These are device specific and are not used directly in typical applications. Use the signal specific GetStickyFault_*() methods instead.
Minimum Value: 0 Maximum Value: 1048575 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< units::voltage::volt_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetSupplyVoltage | ( | ) |
Measured supply voltage to the CANcoder.
Minimum Value: 4 Maximum Value: 16.75 Default Value: 4 Units: V
Default Rates: CAN 2.0: 10.0 Hz CAN FD: 100.0 Hz
StatusSignalValue< units::angular_velocity::turns_per_second_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetUnfilteredVelocity | ( | ) |
The unfiltered velocity reported by CANcoder.
This is the unfiltered velocity reported by CANcoder. This signal does not use the fusing algorithm. It is also not timesynced. If you wish to use a signal with timesync, use Velocity.
Minimum Value: -8000.0 Maximum Value: 7999.755859375 Default Value: 0 Units: rotations per second
Default Rates: CAN 2.0: 10.0 Hz CAN FD: 100.0 Hz
StatusSignalValue< units::angular_velocity::turns_per_second_t > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVelocity | ( | ) |
Velocity of device.
Minimum Value: -512.0 Maximum Value: 511.998046875 Default Value: 0 Units: rotations per second
Default Rates: CAN: 100.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVersion | ( | ) |
Full Version.
The format is a four byte value.
Full Version of firmware in device. The format is a four byte value.
Minimum Value: 0 Maximum Value: 4294967295 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVersionBugfix | ( | ) |
App Bugfix Version number.
Minimum Value: 0 Maximum Value: 255 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVersionBuild | ( | ) |
App Build Version number.
Minimum Value: 0 Maximum Value: 255 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVersionMajor | ( | ) |
App Major Version number.
Minimum Value: 0 Maximum Value: 255 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
StatusSignalValue< int > & ctre::phoenixpro::hardware::core::CoreCANcoder::GetVersionMinor | ( | ) |
App Minor Version number.
Minimum Value: 0 Maximum Value: 255 Default Value: 0 Units:
Default Rates: CAN: 4.0 Hz
bool ctre::phoenixpro::hardware::core::CoreCANcoder::HasResetOccurred | ( | ) |
|
delete |
|
inline |
Control motor with generic control request object.
User must make sure the specified object is castable to a valid control request, otherwise this function will fail at run-time and return the corresponding StatusCode
request | Control object to request of the device |
|
inline |
Control motor with generic control request object.
User must make sure the specified object is castable to a valid control request, otherwise this function will fail at run-time and return the NotSupported StatusCode
request | Control object to request of the device |
|
inline |
The position to set the sensor position to right now.
This will wait up to 0.050 seconds (50ms) by default.
newValue | Value to set to. |
|
inline |
The position to set the sensor position to right now.
newValue | Value to set to. |
timeoutSeconds | Maximum time to wait up to in seconds. |