View Single Post
  #4   Spotlight this post!  
Unread 19-09-2013, 11:14
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: First Year Java Autonomous Help

When you set up a project in Java, you choose what base class to use, Simple Robot or Iterative Robot (or command, which is based on iterative). There are descriptions of each here: http://wpilib.screenstepslive.com/s/...g-a-base-class

In LabVIEW, autonomous is called at the start of autonomous and stopped at the end of autonomous. You can put delays in autonomous in LabVIEW. Teleop, on the other hand, is called every 20ms. You can't put any delays in teleop or you will shut down communication.

In Java (and C++), Simple Robot behaves like LabVIEW's autonomous, for both teleop and autonomous. Iterative Robot behaves like LabVIEW's teleop, for both teleop and autonomous.

If you are using iterative robot, you can't use the long delay or cgmv123's while loop. Instead use an if statement that checks the time and either turns on or off the motor and doesn't do anything that takes a long time.

If you are using the command templates, it's very easy to make a command that sets a timeout in init, runs the motor and checks the time in execute, and stops the motor in finish.



Another possible problem is the motor safety. By default, robotDrive needs to be called every 0.1 seconds or else it will shut off the motor. This is important because if your code crashes, it makes sure the robot stops, rather then keep running the last speed. In your code, robotDrive wouldn't get called for the length of your delay. cgmv123's code works around this by calling very often in the while loop.
Reply With Quote