# Finding the right PD values for a quadcopter simulator

I am working on this short assignment where I have to find the right PD values for a simulated quadcopter. I have to reach 0.9 meters under 1 second with an overshoot of less than 5%. This is my code:

function [ u ] = pd_controller(~, s, s_des, params)
%PD_CONTROLLER  PD controller for the height
%
%   s: 2x1 vector containing the current state [z; v_z]
%   s_des: 2x1 vector containing desired state [z; v_z]
%   params: robot parameters

% u = 0;

error = s_des - s;
z_des = 0.9;

Kp = 0.5;
Kv = 1.0;

u = params.mass*(z_des + Kp*error(1) + Kv*error(2) + params.gravity);

end


So far this is my output:

I've tried many different value combinations and so far this is the closest that I could get.

• Why are you adding z_des to the control? That looks wrong. – holmeski Aug 2 at 21:50
• @holmeski Initially it was in the starter code. Now that I removed it, the drone does not lift off at all. – oo92 Aug 2 at 21:52
• If you set the control to m*(g + I), what's the lowest I can be while still driving the vehicle upwards? – holmeski Aug 2 at 22:04