Motors stop running in autonomous

We ran into a little issue with running motors in autonomous at the Palmetto regional. We know about the watchdog for the robot and the motor safetly timers. We disabled the watchdog and set the expiration timeout for the motors, but still sometimes the motors would shut off before the time was up. It seems to happen more on the fields than in the pits, but it did happen in the pit when tethered as well. Our code is similiar to this. I don’t have access to it, the laptop is locked up at the school.

My question is if we set the expiration, can’t the code delay that long before updating the drive setting? That is before the “drive isn’t updated often enough” message?

This didn’t always run the full 2 seconds:


myRobot.SetExpiration(6); // set MotorSafety expiration
myRobot.Drive(0.6, 0.0); 
Wait(2.0); // wait 2 seconds while driving
myRobot.Drive(0.0, 0.0);

To get around this we implemented a loop that keept calling myRobot.Drive() for the time required. Something like:

Timer timer;
timer.Reset();
timer.Start();
while (timer.Get() < 2.0)
{
myRobot.Drive(0.6, 0.0);
}
myRobot.Drive(0.0, 0.0);

Yea - you may be getting bit by the automatic expiration.

Your re-vamp code looks better, but I’d suggest during your ‘while()’ that you also put a “Wait(0.1)” so that you’re not in a total tight-loop situation which might cause other issues with other tasks on the cRio. I don’t know of any such issues, but a tight loop isn’t a good thing either.


Timer timer;
timer.Reset();
timer.Start();

while (timer.Get() < 2.0)
{
  myRobot.Drive(0.6, 0.0);
  Wait(0.1);
}
 
myRobot.Drive(0.0, 0.0);

Thanks, we did have the Wait() in the while loop, I just didn’t remember to type it in when I was making the post.