Closed Debbie386 closed 6 years ago
After having added the DisabledInit code to stop the current auto command we believe we had an instance in which the code continued to run after disabled. We need to see if we can duplicate that.
I'm fairly certain that happens when you run a command from the dashboard.
It should be noted that disabledInit() is not called between auto and teleop during competition
In teleopInit(), the running auto command is cancelled, so I think we're ok there. I believe the only problem is when we trigger commands through the dashboard and they don't complete properly before disabling.
I stumbled upon Scheduler#removeAll()
which removes all running commands from the scheduler. I've added this to the disabledInit: https://github.com/Team-Voltage-386/Software-Team/blob/master/TyRapXVIII/src/org/usfirst/frc/team386/robot/Robot.java#L141
Scheduler.getInstance().removeAll(); doesn't work.
Can you clarify what "doesn't work" mean? Are there a series of steps to reproduce?
Same steps as when I wrote it originally. Since I wasn't the one pushing the buttons, i can't 100% confirm that the steps aren't identical. We need to see if we can duplicate the problem. My original description is as follows: "If you interrupt an autonomous mode routine using the Enter key on the keyboard, then disable the robot on the drivers station and then switch to teleop, when you Enable the robot, it continues running the autonomous code that was interrupted. "
I suggest we attempt to reproduce it today (I can craft a terrible command that will never exit). If it occurs then I can revert this commit and see if that works.
@randomtree07 figured this out: whenever there is a loop inside a subsystem (such as a while loop for driving forward a certain distance, or turning a specific angle) we must include a clause to verify RobotState.isEnabled()
in the loop condition.
If you interrupt an autonomous mode routine using the Enter key on the keyboard, then disable the robot on the drivers station and then switch to teleop, when you Enable the robot, it continues running the autonomous code that was interrupted. We need to prevent this!