Well, it is not the best way especially on the Wait(3.0). The cRIO has a watchdog timer. You need to feed it periodically or your motors will be cut out. Waiting for 3 seconds will definitely starve your dog. So instead of a plain Wait(3.0) statement, you may want to read the timer in a loop. I beleive the WPI library this year will feed your watchdog for you when you call any of the Drive methods. If not add a feed watchdog statement in each of the loops. So something like this:
Code:
float targetAngle = gyro.GetAngle() + 45.0;
while (gyro.GetAngle() < targetAngle)
{
GetWatchdog().Feed();
//
// Turn the robot to the right at half speed.
//
myRobot.ArcadeDrive(0.0, 0.5);
Wait(0.1);
}
//
// Go straight at half speed for 3 seconds.
//
UINT32 targetTime = GetFPGATime()/1000 + 3000;
while (GetFPGATime()/1000 < targetTime)
{
GetWatchdog().Feed();
myRobot.ArcadeDrive(0.5, 0.0);
Wait(0.1);
}
//
// Stop.
//
myRobot.ArcadeDrive(0.0, 0.0);
And of course this is not the best way either, but it should work for your purpose. BTW, the rule of thumb is: never have a Wait statement in your code that's close to or greater than your watchdog timer interval.