# Control: control action of a PID controller with feedback

I'm programming the controller for a drone and I've got a question that may be basic, but I need to understand this perfectly to continue with the most interesting part of the project.

The sensors of my drone give me the position (x,y,z) and orientation (quaternion: x,y,z,w) of the drone, and I need to control the altitude of the drone, so I need to control the velocity in the z coordinate because that velocity is send to a topic of my drone (for those who use ROS, to the cmd_vel topic) and changing the velocity I can control the altitude.

So, basically the input of the controller is the desired position of the drone, then I have a PID controller and the plant (unknown model, so I have to "guess" the parameters of the PID), and the feedback is the current position.

Which would be the output of the controller (I mean, the $$u_k$$, with the discrete model of the PID that is the input of the plant)? Is it a position or a velocity? If it is a position, then I can do something like: (position_current - position_before)/timestep. But I don't know what is theoretically correct, because maybe I can find some $$k_p$$, $$k_i$$ and $$k_d$$ to have the desired velocity as the output.

Thanks :D

Edit: this is basically the model I'm using

• If that's the interface to your drone, there's a good chance there's already a PID controller wrapped around the velocity. In that case, there's absolutely no reason to have a PID controller of your own -- you just want a proportional controller. – TimWescott Dec 13 '19 at 21:45
• Supposing that you measure the position of your plant (drone) and feeding a desired position as a reference signal, you can control the position and not the velocity. So, the output of the controller is based on the position error. The control signal indicates the input voltage to the motors. If, for example, you have servo motors attached to the drone, then the control signal would be the duty cycle for the pwm signals. Same would be with dc motors. – Teo Protoulis Apr 12 at 14:10

## 1 Answer

Normally PID or any feedback control has a controller which outputs a signal that is passed to the actuators of the system. In your case the actuators would be the propeller motors of the drone. So the output would have the units volts.

But for systems you could also use sequential loop closing, where the output of the controller in the outer loops would have the units of the reference of the inner loop. For drones you sometimes have a separate loop for the angular speed for each propellor, such that the outer loop PID would have the controller output units of angular velocity. It is also possible that actual output of the outer loop is the square of the angular velocity, since that is proportional to the amount of thrust that a propellor generates.

• OK, but the output of the controller ($u_k$) is what feeds the plant (remember that the model of the plant is unknown). Imagine that I only want to control the velocity of the z coordinate of the drone. The control action $u_k$ would be the new z velocity or the new z position or what? – Unnamed Nov 18 '18 at 18:32
• I added an image in the main post with the controller model that I'm using. So what is $u_k$? Can I search for $k_p$, $k_i$ and $k_d$ like $u_k$ is the new z velocity or is it a position? – Unnamed Nov 18 '18 at 18:59
• Or is there a node that is subscribed to that topic actually also implement a control loop? Which nodes are subscribed to that topic? – fibonatic Nov 18 '18 at 20:52
• (wanted to fix a typo in my last comment, but accidentally deleted my comment before that) If $u_k$ would be a position then that would imply that the plant is a gain of one. If $u_k$ would be a velocity then that would imply that the plant is an integrator. Both of these imply knowing what the plant, but you claim that the plant is unknown, which is a contradiction. – fibonatic Nov 18 '18 at 20:57
• The plant is a quadcopter, but the mathematical model is really hard and all the thesis and projects that I read only give a mathematical description of the situation but then the exact plant is not given. I understand what you say, and I think that knowing if the plant acts as an integrator or as a gain of 1 can be known, but I don't know how. Do you? – Unnamed Nov 18 '18 at 23:13