henrik

best I have come up with is assuming your time intervals are constant :-
distance is the lessor of (normal full accel ramp ) or travel /2
max velocity is the lessor of sqr( 2*accel*distance/2) or vmax

next position = (current velocity + accel/2)+current position .
while pos+next position<= dist/2 . from then on either constant v or decelerate mode
I'm assuming pid routine can limit vel to vmax

question here is what to do with the error and what is the error is it failure to reach next position or failure to achieve target velocity ?.

it must fit into a lookup table somehow that way you could compensate for errors

still thinking