# PID controller for trajectory with mutliple setpoints

We implemented a PID controller for our quadcopter which allows us to fly from point A to B. The precise position of the quadcopter is measured using an external tracking system.

Now that we can fly from A to B, we would like to implement a controller to fly more complex trajectories with multiple set points. E.g. from A to B to C or flying in a circle using sample points.

We tried to use our regular PID controller for this but this of course doesn't work well since the PID controller forces the quadcopter to stabalize at any set point. We would like to have a controller that allows the quadcopter to fly a trajectory fairly smoothly. I think this has to be a controller that takes into account multiple set points in the trajectory at the same time so that it can already slow down/speed up based on the trajectory that is ahead.

Can someone point me to some controllers / algorithms that I can look at to realize this? Do I need a completely different controller to do this or will it be an adapted version of the PID controller that I have now?

The most common way to address this is to actually change the setpoint sent to the controller over time. For example, to get from point A to point B in T seconds, you would do \begin{align} x^d(t) &= t p_B + (T-t) p_A \end{align} where $x^d$ is the desired position sent to the controller, $p_A$ and $p_B$ are the two setpoints, and $t$ is time (assume $t=0$ at the start of the maneuver). For best control it is also good to define a desired velocity: \begin{align} v^d &= \frac{||p_B - p_A||}{T} \end{align}