View Single Post
  #5   Spotlight this post!  
Unread 11-12-2013, 13:47
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Beginner FRC Java Programmer - Help

Quote:
Originally Posted by DomenicR View Post
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.
Reply With Quote