I’ve gotten a PID loop to work, but I realized that the loop only slows down the robot as it reaches its target. So in light of that discovery, I developed a movement algorithm that accelerates and decelerates the robot using absolute value equations. The algorithm also automatically straightens the robot if it were to drift off course. Is this technically better than PID?

Link to code running:https: //youtu.be/ByDsDm8nkPI

```
int absFwd(double value){
resetTrack();
while(1){
double averagePosition = (trackLeft + trackRight)/2;
double distance1 = ((averagePosition/360)*2.75*pi);
double a =1/value;
double equation = -fabs((21*a*distance1)-9)+13;
if (equation>10){
equation = 10;
}
if (trackLeft > trackRight){
FR.spin(forward, equation , voltageUnits::volt);
BR.spin(forward, equation , voltageUnits::volt);
FL.spin(forward, 0.95*equation , voltageUnits::volt);
BL.spin(forward, 0.95*equation , voltageUnits::volt);
}
else if (trackLeft < trackRight){
FR.spin(forward, 0.95*equation , voltageUnits::volt);
BR.spin(forward, 0.95*equation , voltageUnits::volt);
FL.spin(forward, equation , voltageUnits::volt);
BL.spin(forward, equation , voltageUnits::volt);
}
else if (trackLeft == trackRight) {
FR.spin(forward, equation , voltageUnits::volt);
BL.spin(forward, equation , voltageUnits::volt);
FL.spin(forward, equation , voltageUnits::volt);
BL.spin(forward, equation , voltageUnits::volt);
}
if(5>(value+2) - distance1>0){
FL.stop(vex::brakeType::brake);
BL.stop(vex::brakeType::brake);
FR.stop(vex::brakeType::brake);
BR.stop(vex::brakeType::brake);
break;
}
vex::task::sleep(20);
}
return 1;
}
```

Picture of graphed equation: