I’m having trouble developing a code in which the robot will simply drive forward until it reaches the center peg during autonomous. I currently have two options but this is mostly due to me trying different code. I have rewritten the values but cannot figure out how to make the robot drive straight! This seems to be a simple task but no one on the team has much experience with programming. With what I have now, choosing option 1 in the SmartDashboard results in the robot spinning in one place while option 2 does nothing. Here is what I have written thus far for autonomous:
void RobotInit()
{
SmartDashboard::PutNumber("auton", 2);
}
void Autonomous()
{
autonomous = SmartDashboard::GetNumber("auton", 0);
if(autonomous == 1)
{
cout << "ONE!";
left_0.Set(leftPolarity*LinearValueEstimator(-0.5, 0.0));
right_0.Set(leftPolarity*LinearValueEstimator(0.5, 0.0));
left_1.Set(leftPolarity*LinearValueEstimator(-0.5, 0.0));
right_1.Set(leftPolarity*LinearValueEstimator(0.5, 0.0));
Wait(2);
left_0.StopMotor();
left_1.StopMotor();
right_0.StopMotor();
right_1.StopMotor();
}
else if(autonomous == 2)
{
cout << "TWO!";
left_0.Set(leftPolarity*LinearValueEstimator(-0.50, 0.0));
right_0.Set(leftPolarity*LinearValueEstimator(0.50, 0.0));
left_1.Set(leftPolarity*LinearValueEstimator(-0.50, 0.0));
right_1.Set(leftPolarity*LinearValueEstimator(0.50, 0.0));
Wait(2.2);
left_0.StopMotor();
left_1.StopMotor();
right_0.StopMotor();
right_1.StopMotor();
}
else{cout << "NONE!";}
}
Please let me know what can be done to fix this code!