14#include <units/angle.h>
15#include <units/angular_velocity.h>
16#include <units/dimensionless.h>
17#include <units/voltage.h>
86 ctre::phoenix::StatusCode
Deserialize(
const std::string& to_deserialize)
251 ctre::phoenix::StatusCode
SetPosition(units::angle::turn_t newValue)
268 ctre::phoenix::StatusCode
SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
270 std::stringstream ss;
313 std::stringstream ss;
348 std::stringstream ss;
385 std::stringstream ss;
422 std::stringstream ss;
459 std::stringstream ss;
480 bool _isInitialized =
false;
481 bool _isVersionOk =
false;
482 StatusSignal<int> &_compliancy{LookupStatusSignal<int>(ctre::phoenix6::spns::SpnValue::Compliancy_Version,
"Compliancy",
false)};
485 StatusSignal<int> &_resetSignal{LookupStatusSignal<int>(ctre::phoenix6::spns::SpnValue::Startup_ResetFlags,
"ResetFlags",
false)};
489 void ReportIfTooOld()
override;
525 return [resetSignal=_resetSignal]()
mutable {
526 return resetSignal.Refresh(
false).HasUpdated();
556 std::unique_ptr<sim::CANcoderSimState> _simState{};
569 if (_simState ==
nullptr)
570 _simState = std::make_unique<sim::CANcoderSimState>(*
this);
988 ctre::phoenix::StatusCode
SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
ii that the Software will be uninterrupted or error free
Definition: CTRE_LICENSE.txt:191
CTREXPORT int c_ctre_phoenix6_serialize_double(int spn, double value, char **str)
@ OK
No Error.
Definition: StatusCodes.h:1169
@ NotSupported
This is not supported.
Definition: StatusCodes.h:1780
bool HasUpdated()
Check whether the signal has been updated since the last check.
Definition: StatusSignal.hpp:577
StatusSignal< T > & Refresh(bool ReportOnError=true)
Refreshes the value of this status signal.
Definition: StatusSignal.hpp:821
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:37
MagnetSensorConfigs MagnetSensor
Configs that affect the magnet sensor and how to interpret it.
Definition: CoreCANcoder.hpp:61
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
Take a string and deserialize it to this configuration.
Definition: CoreCANcoder.hpp:86
bool FutureProofConfigs
True if we should factory default newer unsupported configs, false to leave newer unsupported configs...
Definition: CoreCANcoder.hpp:52
std::string ToString() const
Get the string representation of this configuration.
Definition: CoreCANcoder.hpp:66
std::string Serialize() const
Get the serialized form of this configuration.
Definition: CoreCANcoder.hpp:76
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:101
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:186
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition: CoreCANcoder.hpp:441
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition: CoreCANcoder.hpp:457
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition: CoreCANcoder.hpp:367
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition: CoreCANcoder.hpp:404
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition: CoreCANcoder.hpp:420
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
Sets the current position of the device.
Definition: CoreCANcoder.hpp:251
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:292
ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:156
ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:170
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:138
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition: CoreCANcoder.hpp:383
ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:231
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition: CoreCANcoder.hpp:331
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:124
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition: CoreCANcoder.hpp:346
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:311
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:199
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the current position of the device.
Definition: CoreCANcoder.hpp:268
CANcoderConfigurator(const CANcoderConfigurator &)=delete
Delete the copy constructor, we can only pass by reference.
ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:217
Configs that affect the magnet sensor and how to interpret it.
Definition: Configs.hpp:46
std::string Serialize() const override
Definition: Configs.hpp:87
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:97
std::string ToString() const override
Definition: Configs.hpp:75
Definition: Configs.hpp:27
Definition: Configurator.hpp:21
units::time::second_t defaultTimeoutSeconds
The default amount of time to wait for a config.
Definition: Configurator.hpp:26
ctre::phoenix::StatusCode SetConfigsPrivate(const std::string &serializedString, units::time::second_t timeoutSeconds, bool futureProofConfigs, bool overrideIfDuplicate)
Definition: Configurator.hpp:37
ctre::phoenix::StatusCode GetConfigsPrivate(std::string &serializedString, units::time::second_t timeoutSeconds) const
Definition: Configurator.hpp:61
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:28
Definition: DeviceIdentifier.hpp:19
Parent class for all devices.
Definition: ParentDevice.hpp:30
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:476
std::function< bool()> GetResetOccurredChecker() const
Definition: CoreCANcoder.hpp:523
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse()
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.
Definition: CoreCANcoder.hpp:1014
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition: CoreCANcoder.hpp:1070
StatusSignal< int > & GetVersionBugfix()
App Bugfix Version number.
StatusSignal< bool > & GetStickyFault_Hardware()
Hardware fault occurred.
StatusSignal< units::angular_velocity::turns_per_second_t > & GetUnfilteredVelocity()
The unfiltered velocity reported by CANcoder.
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:1028
configs::CANcoderConfigurator & GetConfigurator()
Gets the configurator for this CANcoder.
Definition: CoreCANcoder.hpp:537
CoreCANcoder(int deviceId, std::string canbus="")
Constructs a new CANcoder object.
StatusSignal< int > & GetStickyFaultField()
Integer representing all sticky faults.
StatusSignal< bool > & GetFault_BadMagnet()
The magnet distance is not correct or magnet is missing.
StatusSignal< units::angle::turn_t > & GetPosition()
Position of the device.
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition: CoreCANcoder.hpp:1038
StatusSignal< int > & GetVersionBuild()
App Build Version number.
StatusSignal< bool > & GetFault_Undervoltage()
Device supply voltage dropped to near brownout levels.
StatusSignal< int > & GetVersionMinor()
App Minor Version number.
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition: CoreCANcoder.hpp:1059
CoreCANcoder & operator=(CoreCANcoder const &)=delete
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
Sets the current position of the device.
Definition: CoreCANcoder.hpp:1000
StatusSignal< units::angular_velocity::turns_per_second_t > & GetVelocity()
Velocity of the device.
sim::CANcoderSimState & GetSimState()
Get the simulation state for this device.
Definition: CoreCANcoder.hpp:567
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition: CoreCANcoder.hpp:1114
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:959
CoreCANcoder(CoreCANcoder const &)=delete
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition: CoreCANcoder.hpp:1081
StatusSignal< bool > & GetIsProLicensed()
Whether the device is Phoenix Pro licensed.
bool HasResetOccurred()
Definition: CoreCANcoder.hpp:515
StatusSignal< signals::MagnetHealthValue > & GetMagnetHealth()
Magnet health as measured by CANcoder.
StatusSignal< bool > & GetStickyFault_BadMagnet()
The magnet distance is not correct or magnet is missing.
StatusSignal< int > & GetVersion()
Full Version.
StatusSignal< units::voltage::volt_t > & GetSupplyVoltage()
Measured supply voltage to the CANcoder.
StatusSignal< units::angle::turn_t > & GetPositionSinceBoot()
The relative position reported by the CANcoder since boot.
StatusSignal< int > & GetFaultField()
Integer representing all faults.
StatusSignal< bool > & GetStickyFault_BootDuringEnable()
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition: CoreCANcoder.hpp:1103
StatusSignal< bool > & GetFault_BootDuringEnable()
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &&request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:975
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the current position of the device.
Definition: CoreCANcoder.hpp:988
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse()
An unlicensed feature is in use, device may not behave as expected.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition: CoreCANcoder.hpp:1048
StatusSignal< units::angle::turn_t > & GetAbsolutePosition()
Absolute Position of the device.
StatusSignal< int > & GetVersionMajor()
App Major Version number.
StatusSignal< bool > & GetFault_Hardware()
Hardware fault occurred.
configs::CANcoderConfigurator const & GetConfigurator() const
Gets the configurator for this CANcoder.
Definition: CoreCANcoder.hpp:549
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition: CoreCANcoder.hpp:1092
StatusSignal< bool > & GetStickyFault_Undervoltage()
Device supply voltage dropped to near brownout levels.
Class to control the state of a simulated hardware::CANcoder.
Definition: CANcoderSimState.hpp:31
CTREXPORT double GetCurrentTimeSeconds()
Get the current timestamp in seconds.
Definition: ManualEvent.hpp:12