View Single Post
  #5   Spotlight this post!  
Unread 09-02-2014, 09:10
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 581
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: Autonomous java problems

A good mental model for programming the robot is that, each time your code executes, you should be answering the question "what should the robot be doing right now."

Consider the situation where you want to drive forward for a certain time. Each time the loop would execute, you'd ask the question "what should the robot be doing now.". In this case, you'd be examining your timer and saying something like this:

float elapsedtime = ...;
float timeToDriveForward = ...;
if (elapsedtime < timeToDriveForward)
{
// set motors to drive forward
}
else
{
// turn motors off
}

Note that each time this executes, you are either setting the motors to drive forward, or turning them off.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson