while(true) {
setMotorBrakeMode(LeftDrive, motorCoast); //Motor Coast
setMotorBrakeMode(RightDrive, motorCoast);
distanceMoved = getMotorEncoder(LeftDrive); // Left P Control
error = distanceSet - distanceMoved;
SpeedLeft = error*kP;
distanceMoved1 = getMotorEncoder(RightDrive); // Right P Control
error1 = distanceSet1 - distanceMoved1;
SpeedRight = error1*kP1;
if (abs(SpeedRight)<2){SpeedRight = 0;}
if (abs(SpeedLeft)<2){SpeedRight = 0;}
/*angleMoved = gyroValue // changes speed according to Gyro Value
angleError = (angleSet - angleMoved)*3 */
setMotorSpeed(LeftDrive, SpeedLeft - angleError);
setMotorSpeed(RightDrive,SpeedRight + angleError);
}}
Hey I was wondering if anyone had any ideas to drive straight at a fast pace. Both of our wheel drives work virtually same the however we are having trouble due to inertia at the end of our command. Weâre using a P control loop for each wheel side and as you can see above have also tryed using the gyro error to keep us straight (commented out). However due to the sudden brake mode of vex iq motors their is still inertia at the end which is not accounted for by the encoders. Weâve tryed using the motorCoast command but for some reason it doesânt seem to be working as both drives are still stiff at the end of the task.
Any help would be appreciated, Thank you!
Arav