|
Re: Basic Autonomous Structures
One suggestion, for the code on the left is to consider using a For loop for things that run a computed number of iterations. It is less flexible than a while loop, but takes less code and is more obvious that it runs four iterations. I don't believe you need the delay in the loop. Each movement will take far longer than 50ms, so the delay is doing no harm, but having no effect but to generate a bit more scheduling code.
The code on the right seems to assume that it takes 20ms for the Tank RobotDrive icon to return, when in reality, it is closer to 1ms. That means your loop will finish really quickly and not do what you want. Place a 20ms delay into your loop, similar to how you did the code on the left.
As for the error messages, that is most likely because you have already opened the RobotDrive with PWM 1 and 2 elsewhere in your program, such as in Begin.
While it is possible to open and close the autonomous resources directly like this, it is more common to open them all in Begin and store them in a named registry. Then in autonomous and elsewhere, you retrieve them by name. Those icons are next to the Open in the palette.
Greg McKaskle
|