WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
frc::MotorSafety Class Referenceabstract

This base class runs a watchdog timer and calls the subclass's StopMotor() function if the timeout expires. More...

#include <MotorSafety.h>

Inheritance diagram for frc::MotorSafety:
frc::ErrorBase frc::NidecBrushless frc::PWM frc::Relay frc::RobotDrive frc::RobotDriveBase frc::PWMSpeedController frc::Servo frc::DifferentialDrive frc::KilloughDrive frc::MecanumDrive frc::DMC60 frc::Jaguar frc::PWMTalonSRX frc::PWMVictorSPX frc::SD540 frc::Spark frc::Talon frc::Victor frc::VictorSP

Public Member Functions

 MotorSafety (MotorSafety &&rhs)
 
MotorSafetyoperator= (MotorSafety &&rhs)
 
void Feed ()
 Feed the motor safety object. More...
 
void SetExpiration (double expirationTime)
 Set the expiration time for the corresponding motor safety object. More...
 
double 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 void GetDescription (wpi::raw_ostream &desc) const =0
 
- Public Member Functions inherited from frc::ErrorBase
 ErrorBase (ErrorBase &&)=default
 
ErrorBaseoperator= (ErrorBase &&)=default
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 Retrieve the current error. More...
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual void SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Static Public Member Functions

static void CheckMotors ()
 Check the motors to see if any have timed out. More...
 
- Static Public Member Functions inherited from frc::ErrorBase
static void SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static void SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static const ErrorGetGlobalError ()
 Retrieve the current global error.
 

Additional Inherited Members

- Protected Attributes inherited from frc::ErrorBase
Error m_error
 

Detailed Description

This base class runs a watchdog timer and calls the subclass's StopMotor() function if the timeout expires.

The subclass should call Feed() whenever the motor value is updated.

Member Function Documentation

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 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.

void frc::MotorSafety::Feed ( )

Feed the motor safety object.

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

double frc::MotorSafety::GetExpiration ( ) const

Retrieve the timeout value for the corresponding motor safety object.

Returns
the timeout value in seconds.
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.
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.
void frc::MotorSafety::SetExpiration ( double  expirationTime)

Set the expiration time for the corresponding motor safety object.

Parameters
expirationTimeThe timeout value in seconds.
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.

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