I am using VexCode V5 text 1.0.3. Our robot is using an inertial sensor. It is programmed to turn 90 degrees to the left. It is turning, but too far. Looking for some advice.
//The robot turns to face the goal.
FL.spin(directionType::rev, 20,velocityUnits::pct);
BL.spin(directionType::rev, 20,velocityUnits::pct);
FR.spin(directionType::fwd, 20,velocityUnits::pct);
BR.spin(directionType::fwd, 20,velocityUnits::pct);
waitUntil((Inertial6.rotation(degrees) <= -90.0));
task::sleep(5);
FL.stop(brakeType::brake);
BL.stop(brakeType::brake);
FR.stop(brakeType::brake);
BR.stop(brakeType::brake);
This is expected behavior to some extent, since the motors take some distance to stop, and take longer to stop the faster they’re spinning. So, if you go from full speed to 0% speed when the robot has turned the target distance, the motors with “coast” quite a bit, and the robot will overshoot its target.
Some things you can try to mitigate this:
Turn slower, so the robot “coasts” for a shorter distance
Setting the motors’ brake type to “stop” or “hold”, which will help to reduce the stopping distance.
Initializing a drivetrain object and using its turnFor function
Implementing your own PID (search the forum for lots of info about how to do this)
Thanks for the input, but we did try most of this. It only turns at 20%, we are using brake, not coast, and had the same problem with the drivetrain. It is not slight overshooting either, it is about 45 degrees too far. We did not try a PID though. We will look into that. Thanks.