Team-Voltage-386 / Software-Team

DEPRECATED REPO (Use Individual Repos now)
3 stars 0 forks source link

Auto continues running in teleop #37

Closed Debbie386 closed 6 years ago

Debbie386 commented 6 years ago

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!

Debbie386 commented 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.

aeden commented 6 years ago

I'm fairly certain that happens when you run a command from the dashboard.

aetrisd commented 6 years ago

It should be noted that disabledInit() is not called between auto and teleop during competition

aeden commented 6 years ago

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.

aeden commented 6 years ago

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

Debbie386 commented 6 years ago

Scheduler.getInstance().removeAll(); doesn't work.

aeden commented 6 years ago

Can you clarify what "doesn't work" mean? Are there a series of steps to reproduce?

Debbie386 commented 6 years ago

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. "

aeden commented 6 years ago

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.

aeden commented 6 years ago

@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.