|
Infinite loop means no control
Our regional finished up yesterday. Python worked out very well for us, but I just now realized that the autonomous code I wrote was causing us a serious problem.
Thursday and Friday, everything was working fine. On Saturday, one of our mechanisms that was used during autonomous mode broke down. In order to keep our thrower motor from running continuously during the match we just tied down the limit switch that normally stopped and started the motor.
The problem was that the autonomous code watched for that switch to be toggled twice -- once for each ball thrown. No toggle meant that the autonomous code just kept on running in a loop waiting for the switch to toggle.
The moral of the story is:
You absolutely must check which mode you are in during every loop. Failure to do so may mean that your program will not change modes when the field changes mode.
I think this is an issue no matter which programming method is used, but I'm not really sure. I know it caught me in python.
|