I'm working on a robot with differential drive (2 drive wheels equipped with rotary encoders and 4 free spinning omni wheels for stability) and each wheel is controlled via a separate arduino nano.

I have implemented two PID loops, one for position control and one for speed control (first one gets a position in number of pulses and second gets an RPM as their goals).

The position PID works fine by produces jerky motion and acts more like a "bang bang" control where it starts at full speed. I'm not sure how I can combine these to plan a move that reaches a certain number of pulses with a given maximum acceleration and / or velocity.

I know 3D printers for example, have settings for jerk,acceleration and velocity so I tried to go through marlin to see how that's implemented but I had no luck! Can anyone please provide examples or links to tutorials / papers regarding this?

I think an easy solution would be pre calculating the motion profile and then tracking it with the position PID, but I'm not sure if there are better solutions for this.

  • $\begingroup$ Check out articles on position control with via points. $\endgroup$
    – SteveO
    Mar 16, 2020 at 2:47
  • $\begingroup$ searching that doesn't find anything useful. can you please provide a few links? $\endgroup$
    – OM222O
    Mar 16, 2020 at 10:58

1 Answer 1


I believe the resource https://robotics.stackexchange.com/a/21571/6941 already pretty much answers your question.

In essence, both the following approaches are valuable and can be combined together:

  • A pre-calculated motion profile helps the system reduce the jerk.
  • Cascaded PID controllers allow for improving the system response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.