wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.05k stars 612 forks source link

Add a function to disable the robot in code. #6448

Closed Narnillian closed 5 months ago

Narnillian commented 6 months ago

Seeing that the new A-stop feature can be used to stop an Autonomous routine in case of unexpected behavior, it would seem to make sense to be able to do something similar with either on-robot sensors or a driver controller.

My team and I have found that in certain situations, it can be hard to reach over to the DS to press the Disable button quickly, and for testing it would be nice to be able to have a Disable button on the controller. As well, unexpected behavior could be avoided quickly by calling this function when a sensor gives a certain output.

This function would have the same functionality as the Disable button on DS, possibly with an argument Boolean isEmergencyStop. It could be part of edu.wpi.first.wpilibj.DriverStation in Java, <frc/DriverStation.h> in C++, and wpilib.DriverStation in Python.

PeterJohnson commented 6 months ago

While we could add a global boolean, it would only have effect on software state in the robot code, and not on any motors/actuators--PWM signals would stay active, CAN motor controllers would still be enabled, etc. This is probably less safe than the current situation. We have no way to force a hardware disable/estop, that can only be directed by the DS application.