WPILibC++ 2023.4.3
frc::MotorSafety Class Referenceabstract

The Motor Safety feature acts as a watchdog timer for an individual motor. More...

#include <frc/MotorSafety.h>

Inheritance diagram for frc::MotorSafety:
frc::NidecBrushless frc::PWMMotorController frc::Relay frc::RobotDriveBase frc::DMC60 frc::Jaguar frc::PWMSparkMax frc::PWMTalonFX frc::PWMTalonSRX frc::PWMVenom frc::PWMVictorSPX frc::SD540 frc::Spark frc::Talon frc::Victor frc::VictorSP frc::DifferentialDrive frc::MecanumDrive

Public Member Functions

 MotorSafety ()
 
virtual ~MotorSafety ()
 
 MotorSafety (MotorSafety &&rhs)
 
MotorSafetyoperator= (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
 
virtual std::string GetDescription () const =0
 The return value from this method is printed out when an error occurs. More...
 

Static Public Member Functions

static void CheckMotors ()
 Check the motors to see if any have timed out. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MotorSafety() [1/2]

frc::MotorSafety::MotorSafety ( )

◆ ~MotorSafety()

virtual frc::MotorSafety::~MotorSafety ( )
virtual

◆ MotorSafety() [2/2]

frc::MotorSafety::MotorSafety ( MotorSafety &&  rhs)

Member Function Documentation

◆ Check()

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.

◆ CheckMotors()

static void frc::MotorSafety::CheckMotors ( )
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.

◆ Feed()

void frc::MotorSafety::Feed ( )

Feed the motor safety object.

Resets the timer on this object that is used to do the timeouts.

◆ GetDescription()

virtual std::string frc::MotorSafety::GetDescription ( ) const
pure virtual

The return value from this method is printed out when an error occurs.

This method must not throw!

Implemented in frc::DifferentialDrive, frc::MecanumDrive, frc::NidecBrushless, frc::PWMMotorController, frc::Relay, and frc::RobotDriveBase.

◆ GetExpiration()

units::second_t frc::MotorSafety::GetExpiration ( ) const

Retrieve the timeout value for the corresponding motor safety object.

Returns
the timeout value.

◆ IsAlive()

bool frc::MotorSafety::IsAlive ( ) const

Determine if the motor is still operating or has timed out.

Returns
true if the motor is still operating normally and hasn't timed out.

◆ IsSafetyEnabled()

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.

Returns
True if motor safety is enforced for this device.

◆ operator=()

MotorSafety & frc::MotorSafety::operator= ( MotorSafety &&  rhs)

◆ SetExpiration()

void frc::MotorSafety::SetExpiration ( units::second_t  expirationTime)

Set the expiration time for the corresponding motor safety object.

Parameters
expirationTimeThe timeout value.

◆ SetSafetyEnabled()

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.

Parameters
enabledTrue if motor safety is enforced for this object.

◆ StopMotor()

virtual void frc::MotorSafety::StopMotor ( )
pure virtual

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