MotorSafety

class wpilib.MotorSafety[source]

Bases: builtins.object

Provides mechanisms to safely shutdown motors if they aren’t updated often enough.

The MotorSafety object is constructed for every object that wants to implement the Motor Safety protocol. The helper object has the code to actually do the timing and call the motors stop() method when the timeout expires. The motor object is expected to call the feed() method whenever the motors value is updated.

The constructor for a MotorSafety object. The helper object is constructed for every object that wants to implement the Motor Safety protocol. The helper object has the code to actually do the timing and call the motors stop() method when the timeout expires. The motor object is expected to call the feed() method whenever the motors value is updated.

DEFAULT_SAFETY_EXPIRATION = 0.1
check()[source]

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 checkMotors()[source]

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()[source]

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

getExpiration()[source]

Retrieve the timeout value for the corresponding motor safety object.

Returns:the timeout value in seconds.
Return type:float
helpers = <_weakrefset.WeakSet object at 0x7f5514ce4400>
isAlive()[source]

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

Returns:True if the motor is still operating normally and hasn’t timed out.
Return type:float
isSafetyEnabled()[source]

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
Return type:bool
setExpiration(expirationTime)[source]

Set the expiration time for the corresponding motor safety object.

Parameters:expirationTime (float) – The timeout value in seconds.
setSafetyEnabled(enabled)[source]

Enable/disable motor safety for this device. Turn on and off the motor safety option for this PWM object.

Parameters:enabled (bool) – True if motor safety is enforced for this object