View Single Post
  #5   Spotlight this post!  
Unread 03-04-2016, 11:29 PM
chesterm chesterm is offline
Registered User
FRC #6055
 
Join Date: Mar 2016
Location: Batesville, AR
Posts: 1
chesterm is an unknown quantity at this point
Re: Autonomous Example

try this for a simple straight ahead run in SampleRobot:

class declarations:
uint64_t autoTime = 0;
uint64_t testTime = 0;

void Autonomous()
{
if (IsAutonomous() && IsEnabled())
{
std::cout << "AutoMode START" << std::endl;
driveTrain.SetSafetyEnabled(true);
autoTime = GetFPGATime();
}
while (IsAutonomous() && IsEnabled())
{
testTime = GetFPGATime();
testTime = (testTime - autoTime) / 1000; //get milliseconds
if (testTime < 3250) //want to travel 11 feet in straight line
driveTrain.TankDrive(-0.65,-0.65); //drive forward
else
driveTrain.TankDrive(0.0,0.0); //stop
}
driveTrain.StopMotor();
std::cout << "AutoMode STOP" << std::endl;
}
Reply With Quote