I am new to P.I.D control and I’m trying to use it to program my robot. I found some some tutorial videos on how to use it but I got stuck at a certain point.

In the past, I have been using the Drivetrain function instead of a left_motor and right_motor for programming. However, I can’t figure out how to use P.I.D with it. Can I use the Drivetrain function with P.I.D at all, and if so, how would I measure position of the Drivetrain?

Here is the code that I’m working on and the link to the tutorial where I got it from…

I’m assuming that your PID function is somewhere else. Once you’ve added proportional, integral and derivative, lets say to a variable called power, you would pass power as a parameter in your drive function. Here’s what the end of the pid loop and the drive function would look something like:

//pid function ^^
double power = proportional + integral + derivative;
driveFunction(power);
vex::task::sleep(20);
}
driveMotors.stop();
}
//end PID function
void driveFunction(double power){
driveMotors.spin(directionType::yourChoice, power, velocityUnits::yourChoice);
}

Yes, I was talking about the baked-in drivetrain function but how would I create my own drivetrain function if that’s what I need to do? Thanks for the help!