Drivetrain accerleration code not working

I am trying to make code for auton that allows my drivetrain to smoothly accelerate instead of being at the same velocity throughout the distance.

I wrote some testing code and tried it in VexVR which worked perfectly. But when testing on my actual bot it seems to have some issues.

#-------------------
def driveFor(dire, dist, units, startVel, endVel, inc):
    drive.set_drive_velocity(startVel, PERCENT)
    drive.drive_for(dire, dist, units, wait=False)
    vel = startVel
    while drive.is_moving():
        vel = min((vel+inc), endVel)
        drive.set_drive_velocity(vel)
        wait(100, MSEC)
#-------------------

When i call this from auton it sets the initial velocity as given with the function’s inputs, but once the while driving loop starts it
doesn’t set the velocity but it sets the vel variable correctly.

Use a PID System Control. That will solve what you need, it will change the speed according to the distance it has to travel to get there smoothly and exactly. If you go to the search bar and search PID up, you should be able to find a few examples. It does take time and tuning, but it will enhance your autonomous driving !

I do have some PID code written a little while ago, but, unless I’m not remembering correctly, PID loops decelerate as you get closer to the target. I have never written PID code for a drivetrain specifically so I could be misunderstanding.

Maybe it is the wait part. It might be glitching and just waiting too long.