WPILibC++ 2024.3.2
|
The Motor Safety feature acts as a watchdog timer for an individual motor. More...
#include <frc/MotorSafety.h>
Public Member Functions | |
MotorSafety () | |
virtual | ~MotorSafety () |
MotorSafety (MotorSafety &&rhs) | |
MotorSafety & | operator= (MotorSafety &&rhs) |
void | Feed () |
Feed the motor safety object. More... | |
void | SetExpiration (units::second_t expirationTime) |
Set the expiration time for the corresponding motor safety object. More... | |
units::second_t | GetExpiration () const |
Retrieve the timeout value for the corresponding motor safety object. More... | |
bool | IsAlive () const |
Determine if the motor is still operating or has timed out. More... | |
void | SetSafetyEnabled (bool enabled) |
Enable/disable motor safety for this device. More... | |
bool | IsSafetyEnabled () const |
Return the state of the motor safety enabled flag. More... | |
void | Check () |
Check if this motor has exceeded its timeout. More... | |
virtual void | StopMotor ()=0 |
Called to stop the motor when the timeout expires. More... | |
virtual std::string | GetDescription () const =0 |
Returns a description to print when an error occurs. More... | |
Static Public Member Functions | |
static void | CheckMotors () |
Check the motors to see if any have timed out. More... | |
The Motor Safety feature acts as a watchdog timer for an individual motor.
It operates by maintaining a timer that tracks how long it has been since the feed() method has been called for that actuator. Code in the Driver Station class initiates a comparison of these timers to the timeout values for any actuator with safety enabled every 5 received packets (100ms nominal).
The subclass should call Feed() whenever the motor value is updated.
frc::MotorSafety::MotorSafety | ( | ) |
|
virtual |
frc::MotorSafety::MotorSafety | ( | MotorSafety && | rhs | ) |
void frc::MotorSafety::Check | ( | ) |
Check if this motor has exceeded its timeout.
This method is called periodically to determine if this motor has exceeded its timeout value. If it has, the stop method is called, and the motor is shut down until its value is updated again.
|
static |
Check the motors to see if any have timed out.
This static method is called periodically to poll all the motors and stop any that have timed out.
void frc::MotorSafety::Feed | ( | ) |
Feed the motor safety object.
Resets the timer on this object that is used to do the timeouts.
|
pure virtual |
Returns a description to print when an error occurs.
Implemented in frc::DifferentialDrive, frc::MecanumDrive, frc::NidecBrushless, frc::PWMMotorController, frc::Relay, and frc::RobotDriveBase.
units::second_t frc::MotorSafety::GetExpiration | ( | ) | const |
Retrieve the timeout value for the corresponding motor safety object.
bool frc::MotorSafety::IsAlive | ( | ) | const |
Determine if the motor is still operating or has timed out.
bool frc::MotorSafety::IsSafetyEnabled | ( | ) | const |
Return the state of the motor safety enabled flag.
Return if the motor safety is currently enabled for this device.
MotorSafety & frc::MotorSafety::operator= | ( | MotorSafety && | rhs | ) |
void frc::MotorSafety::SetExpiration | ( | units::second_t | expirationTime | ) |
Set the expiration time for the corresponding motor safety object.
expirationTime | The timeout value. |
void frc::MotorSafety::SetSafetyEnabled | ( | bool | enabled | ) |
Enable/disable motor safety for this device.
Turn on and off the motor safety option for this PWM object.
enabled | True if motor safety is enforced for this object. |
|
pure virtual |
Called to stop the motor when the timeout expires.
Implemented in frc::DifferentialDrive, frc::MecanumDrive, frc::NidecBrushless, frc::PWMMotorController, frc::Relay, and frc::RobotDriveBase.