|
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;
}
|