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.