|
Re: Leaving Autonomous
To answer your question about switching from Autonomous to OperatorControl, here's what happens:
When you put the robot on the field and turn it on (or anytime you reset it), your Initialize() function runs from the start to completion. If there are sensors like gyros that are initialized in the Initialize function, they will completely initialize. This can take a few seconds to complete, so if you reset the robot in the middle of a match you might see this delay before the robot starts driving again.
When the match starts and hybrid mode starts, your Autonomous() function will start running. Your Autonomous() function will either run to completion or...
When the field switches to tele-operation, your Autonomous() function will be interrupted (stopped), and the OperatorControl() function starts executing. As was said, you would typically put a while (1) loop in there to repeatitively read controls and send values to motors.
The switching from Autonomous to OperatorControl is automatic and you don't have to do anything to make it happen. Any background processing of sensors that you start in Autonomous or Initialize will continue until you explicitly stop it. Background processing starts whenever you do a Startxxx function on a sensor. For example StartGyro causes the code for the Gyro to automatically start polling it and computing headings in the background. You don't have to do anything else to make it work. The reason the background stuff doesn't stop between Autonomous and OperatorControl is so teams that want to use the Gyros and Cameras in their operator control programs won't have to wait for them to reinitialize at the start of the OperatorControl() function.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
|