[examples] Zero motors on disabledInit() in sim physics examples (#2906)

This ensures that mechanisms will stop moving if the robot is disabled while motors are in motion
This commit is contained in:
Prateek Machiraju
2020-12-04 20:34:16 -05:00
committed by GitHub
parent 2a5ca77454
commit b3deda38c9
5 changed files with 12 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
*/
void Robot::DisabledInit() {
frc2::CommandScheduler::GetInstance().CancelAll();
m_container.ZeroAllOutputs();
}
void Robot::DisabledPeriodic() {}

View File

@@ -36,6 +36,8 @@ RobotContainer::RobotContainer() {
{&m_drive}));
}
void RobotContainer::ZeroAllOutputs() { m_drive.TankDriveVolts(0_V, 0_V); }
const DriveSubsystem& RobotContainer::GetRobotDrive() const { return m_drive; }
void RobotContainer::ConfigureButtonBindings() {

View File

@@ -30,6 +30,7 @@ class RobotContainer {
public:
RobotContainer();
void ZeroAllOutputs();
frc2::Command* GetAutonomousCommand();
const DriveSubsystem& GetRobotDrive() const;