WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::MotorSafety Class Referenceabstract

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

#include <wpi/hardware/motor/MotorSafety.hpp>

Inheritance diagram for wpi::MotorSafety:
wpi::PWMMotorController wpi::RobotDriveBase wpi::xrp::XRPMotor wpi::Koors40 wpi::PWMSparkFlex wpi::PWMSparkMax wpi::PWMTalonFX wpi::PWMTalonSRX wpi::PWMVenom wpi::PWMVictorSPX wpi::Spark wpi::SparkMini wpi::Talon wpi::VictorSP wpi::romi::RomiMotor wpi::DifferentialDrive wpi::MecanumDrive

Public Member Functions

 MotorSafety ()
virtual ~MotorSafety ()
 MotorSafety (MotorSafety &&rhs)
MotorSafetyoperator= (MotorSafety &&rhs)
void Feed ()
 Feed the motor safety object.
void SetExpiration (wpi::units::second_t expirationTime)
 Set the expiration time for the corresponding motor safety object.
wpi::units::second_t GetExpiration () const
 Retrieve the timeout value for the corresponding motor safety object.
bool IsAlive () const
 Determine if the motor is still operating or has timed out.
void SetSafetyEnabled (bool enabled)
 Enable/disable motor safety for this device.
bool IsSafetyEnabled () const
 Return the state of the motor safety enabled flag.
void Check ()
 Check if this motor has exceeded its timeout.
virtual void StopMotor ()=0
 Called to stop the motor when the timeout expires.
virtual std::string GetDescription () const =0
 Returns a description to print when an error occurs.

Static Public Member Functions

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

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]

wpi::MotorSafety::MotorSafety ( )

◆ ~MotorSafety()

virtual wpi::MotorSafety::~MotorSafety ( )
virtual

◆ MotorSafety() [2/2]

wpi::MotorSafety::MotorSafety ( MotorSafety && rhs)

Member Function Documentation

◆ Check()

void wpi::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()

void wpi::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 wpi::MotorSafety::Feed ( )

Feed the motor safety object.

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

◆ GetDescription()

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

Returns a description to print when an error occurs.

Returns
Description to print when an error occurs.

Implemented in wpi::DifferentialDrive, wpi::MecanumDrive, wpi::PWMMotorController, wpi::RobotDriveBase, and wpi::xrp::XRPMotor.

◆ GetExpiration()

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

Retrieve the timeout value for the corresponding motor safety object.

Returns
the timeout value.

◆ IsAlive()

bool wpi::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 wpi::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 & wpi::MotorSafety::operator= ( MotorSafety && rhs)

◆ SetExpiration()

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

Set the expiration time for the corresponding motor safety object.

Parameters
expirationTimeThe timeout value.

◆ SetSafetyEnabled()

void wpi::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 wpi::MotorSafety::StopMotor ( )
pure virtual

Called to stop the motor when the timeout expires.

Implemented in wpi::DifferentialDrive, wpi::MecanumDrive, wpi::PWMMotorController, wpi::RobotDriveBase, and wpi::xrp::XRPMotor.


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