Hi.
We are having an issue where our 2-line drive code is causing our auton drive straight code (PID or normal ones) to twitch. Below is our drive code in the MAIN section.
leftDrive.spin(forward,Controller1.Axis3.position(),pct);
rightDrive.spin(forward,Controller1.Axis2.position(),pct);
We are using a 6-motor drive, so can’t just set the drive on the controller on set up, the left and right drives are manually defined at the start of the code.
Then this is our most basic Auton drive straight function. which is placed at the top of the code.
void driveStraight(int driveDistance, int maxSpeed)
{
LT.setStopping(coast);
RT.setStopping(coast);
LB.setStopping(coast);
RB.setStopping(coast);
LF.setStopping(coast);
RF.setStopping(coast);
LT.setPosition(0,degrees);
driveDistance = driveDistance * 2.5;
leftDrive.setVelocity(maxSpeed,percent);
rightDrive.setVelocity(maxSpeed,percent);
while (LT.position(degrees) < driveDistance){
robotDrive.drive(forward);
}
LT.stop();
RT.stop();
LB.stop();
RB.stop();
LF.stop();
RF.stop();
}
Not the tidies code as we’d been messing with it trying different things to get it to go straight.
However, it does go straight as long as we remove the drive code from the main, all of our functions work if that is commented out. when the drive code is present the auton jerks off in different directions. We’ve never noticed this before.