Quote:
Originally Posted by DomenicR
I'm assuming the code you posted here was copied from inside a class that inherits from the SimpleRobot class?
|
This is an important distinction. A description of SimpleRobot and IterativeRobot is available here:
http://wpilib.screenstepslive.com/s/...g-a-base-class
Code:
public void autonomous() { //checks code every 50 seconds
By having an autonomous method, it appears to inherit from SimpleRobot, rather then IterativeRobot. However, the comment appears to be based on IterativeRobot. In SimpleRobot, the autonomous method is called once. In IterativeRobot, the autonomousInit method is called once at the beginning of Autonomous, and the autonomousPeriodic method is called ever 1/50th of a second.
If you use SimpleRobot, you want to make sure your code in the autonomous method takes less then 15 seconds to run (if you want it to work on the real field). Alternately you can check isAutonomous() and isEnabled() methods and return if you are no longer in autonomous or no longer enabled). Your code right now should take less then 15 seconds, but you might run into issues later.
If you use IterativeRobot, you can't use a Timer.delay in the autonomousPeriodic method. It needs to return quickly so that new driver station data is read. Instead, you can check a timestamp and only do something when a certain amount of time has elapsed.