PROS 4 Motor Turn Function

Hi, So I’m currently very stuck on using a turn function for a 4 motor drivetrain in PROS and am unable to find any examples. If anyone has any 4 motor turnToAngle functions in PROS would be great!

I’m not quite sure how complex your code is… however IIRC, okapilib has turnToangle functions. You could always come your own function. For example you could, with some quick math, write a function that spins one side of the drive train the opposite of the other.

So I currently am using odom in my driveStraight function, but in my turnToAngle function, when I implement it I seem to have an issue where the robot starts to turn, but doesn’t stop. I haven’t been able to fix it and wanted an example on a simple function where you can tell a four motor drive to turn an amount of degrees. If you see anything wrong with my current turn function, or if you have any examples as to how I would write a standard turn function without odom or inertial sensors.

void Drivetrain::turnToAngle(QAngle iangle, PID ipid)
{
    enable(); // make sure the action can run
    while (menabled && !ipid.isSettled())
    {
        double angleError = util::wrapDeg180((iangle - Drivetrain::getTheta()).convert(degree)); // calculates the angle the robot needs to turn

        Drivetrain::moveArcade(0, -ipid.iterate(angleError), false);
        master.print(0,0,"Error: %d", angleError);
        pros::delay(20);
    }
    Drivetrain::moveArcade(0, 0, false);
    def::controller.rumble("-");
}