# Optimal-Time Trajectory Planning in 1D

I have been searching for a solution to the mentioned above problem, but nothing was accurate enough.

I am trying to find the optimal-time trajectory for an object from initial point A to final point B.

The velocity at those points is 0, and the max velocity and acceleration are v_max and a_max

How can i solve this?

• I think this problem is best solved by bang-bang control: accelerate as fast aspossible to the maximum velocity until just the right point where you decelerate as much as possible so that you just barely hit zero velocity at your desired endpoint.
– Paul
Oct 22, 2017 at 23:13
• You can check this out. Oct 23, 2017 at 0:11

Hi usually the time optimal solution of a motion not having specific constraints is know as 'bang-bang'. Where you let you system accelerate and decelerate at the maximum rate possible. In your case, you command a_max until v_max is reached then you stay at this speed until you need to break at -a_max to reach zero velocity.

I also suggest to look at Pontryagin's maximum principle

How to do that in practice, i.e. how to find the profiles of the position/velocity/acceleration ? This is the solution that is usually described, when the dynamic of the object is not considered, that means when control authority is unlimited.

1. keep in mind that the problem is symmetric, i.e. you need as much time to accelerate then to decelerate;
2. start from position, velocity and acceleration at zero (or higher derivative);
3. apply a discontinuous acceleration from 0 to a_max until v_max is reached, check the time and the distance (you will need the same to brake);
4. apply a discontinuous acceleration from a_max to 0, this keep the velocity at v_max do that until you arrive at half the distance (this will also be half the time);
5. apply a discontinuous acceleration from 0 to -a_max until the velocity is zero, you should have reached the goal (this is the inverse of 2) ) set acceleration to 0.

Note that if you goal is "close" you might not need to reach v_max and should start to break before, hence the checks in time and distance. Also the best to visualize that is to draw the profile one below the other on a sheet of paper.

To the best of my knowledge this case without the dynamics is considered as simple and I don't know a solver for that, as coding the above algorithm reasonably easy. The assumption of neglecting the object dynamics is usually good enough for simple robots and brings to feasible motion for simple robots. If you want to be more gentle for the system considering higher order derivatives (jerk, snap) is possible but there maximal values are usually not intuitive to set/find, another solution is to take the position profile and feed it to a 5/6th oder filter, to get a smooth trajectory for all derivatives considered. The literature for 'bang-bang' controller considering dynamics and actuation constraints is vast and encompass different cases that might fit you.

In short if you are an hobbyist or undergrad try this method out, if you want more advanced stuff you will need to dig the literature to find something close to your issue.

• What if Jerk is involved too? I mean jerk can be either 0 or Jmax. Oct 23, 2017 at 9:52
• Then you go at max jerk until max acceleration and so on .... The idea of 'bang-bang' method is always go maximum either "accelerating" or "decelerating" Oct 23, 2017 at 9:59
• Thank you so much. I’m asked to implement an algorithm too. Is the algorithm simply to implement the bang-bang method? Oct 23, 2017 at 10:22
• My pleasure,if you are good with the answer accept it so you question will appear as answered on the website Oct 23, 2017 at 10:31