Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Quadcopter Dynamics, Simulation, and Control

Andrew Gibiansky andrew.gibiansky@gmail.com

November 29, 2012

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Helicopters

Helicopter

Swashplate

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Helicopter Thrusts

Swashplate mechanism provides control over extra degrees of freedom.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Quadcopters

Note the lack of swashplates!

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Quadcopter Thrusts

Degrees of freedom provided by extra motors.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Quadcopters vs. Helicopters

Quadcopters
Simpler mechanism: no swashplates. Can be very small, yet controllable. Very versatile. Cheap!

Helicopters
Much simpler to control (possible without electronic stabilization). Have been scaled up to large sizes.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Frames

Figure: Quadcopter Body Frame and Inertial Frame

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Forces and Torques


Thrust force: 0 TB = Ti = k 0 . i =1 i 2
4

Drag force: kd x FD = kd y kd z Motor torques: Lk (1 2 3 2 ) B = Lk (2 2 4 2 ) 2 2 2 2 b 1 2 + 3 4


Andrew Gibiansky andrew.gibiansky@gmail.com Quadcopter Dynamics, Simulation, and Control

Equations of Motion: Linear

Inertial Frame: 0 = 0 + RTB + FD mx mg Body Frame: 0 = R 1 0 + TB + R 1 FD (mx ) mx mg

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Equations of Motion: Rotational


Eulers Equations (Rigid Body Dynamics): + (I ) = I Body Frame Dynamics: Ixx I=0 0 0 Iyy 0 0 0 . Izz

Iyy Izz Ixx 1 Ixx y z Ixx x z = Iyy 1 IzzI yy Ixx Iyy Izz 1 x y
Izz

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Simulation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 % Simulation times, in seconds. start_time = 0; end_time = 10; dt = 0.005; times = start_time:dt:end_time; N = numel(times); % Initial simulation state. x = [0; 0; 10]; xdot = zeros(3, 1); theta = zeros(3, 1); % Simulate some disturbance in the angular velocity. % The magnitude of the deviation is in radians / second. deviation = 100; thetadot = deg2rad(2 * deviation * rand(3, 1) - deviation); % Step through the simulation, updating the state. for t = times i = input(t); % Get controller input , , ) omega = thetadot2omega(thetadot, theta); % Convert ( a = acceleration(i, theta, xdot, m, g, k, kd); % Compute linear acceleration omegadot = angular_acceleration(i, omega, I, L, b, k); % Compute angular acceleration omega = omega + dt * omegadot; % = + dt , , ) thetadot = omega2thetadot(omega, theta); % Convert ( , ) theta = theta + dt * thetadot; % = + dt (, = x + dt a xdot = xdot + dt * a; % x x = x + dt * xdot; % x = x + dt x end

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Visualization

YouTube Movie

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

PD Control
Control signal should be turned into a torque: = Iu (t ) = I We can set torques: + Kp I Kd xx + Kp = Iyy Kd + Kp Izz Kd

T 0 T 0 T 0

dt

dt dt

Our electronic gyro outputs angular velocities, so we integrate them to get the angle. This integral is multiplied by the proportional gain.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Motor Angular Velocities


We do not actually set torques, we set voltages over the motors. These correspond directly to the motor angular velocities i . We can solve for the inputs i = i 2 : + Kp I Kd Lk (1 3 ) xx + Kp = Lk (2 4 ) B = Iyy Kd b (1 2 + 3 4 ) + Kp Izz Kd

T 0 T 0 T 0

dt

dt dt

For the last constraint, choose one to keep the quadcopter aloft: mg T = cos cos

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

PD Control

Figure: Left: Angular velocities. Right: angular displacements. , , are coded as red, green, and blue. Note that there is some small steady-state error (approximately 0.3 ).

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

We can do better by adding an integral term to make this a PID controller. + Kp e = Kd + Kp e = Kd + Kp e = Kd


T 0 T 0 T 0

dt + Ki dt + Ki dt + Ki

T 0 T 0 T 0

T 0 T 0

dt dt dt dt dt dt

T 0

To avoid integral wind-up, only start integrating the double-integral once the angle deviation is relatively small.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Integral Windup

Figure: In some cases, integral wind-up can cause lengthy oscillations instead of settling. In other cases, wind-up may actually cause the system to become unstable, instead of taking longer to reach a steady state.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

PID Control

Figure: With a properly implemented PID, we achieve an error of approximately 0.06 after 10 seconds.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Automatic Gain Tuning

Tuning the PID gains (Ki , Kp , and Kd ) can be difcult. Quality of results depends on gain values and the ratios of the different gain values. Best gains might be different for different modes of operation. Requires expert intuition and a lot of time to tune them. We would like to do this automatically.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Extremum Seeking
Dene a cost function, dening the quality of a set of parameters: J ( ) = 1 tf to
tf t0

e ( t , ) 2 dt

Use gradient descent to minimize this cost function in parameter-space: (k + 1) = (k ) J ( ) Approximate gradient numerically:

J ( ) =

J ( ), J ( ), J ( ) . Kp Ki Kd

K ) J ( u K ) J ( + u J ( ) K 2
Andrew Gibiansky andrew.gibiansky@gmail.com Quadcopter Dynamics, Simulation, and Control

Gradient Descent Tricks

Adjust step size as we go along, to become more precise as time goes on. Computing e (t , ) means running a simulation with some random initial disturbance. Use many simulations, take the average. As we go along, average more simulations. Repeat many times to produce many local minima, then choose the best one and call it the global minimum. Automatically choose a time to stop iterating (when were no longer improving our average cost).

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Manual Gains vs. Automatically Tuned Gains

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

Questions?

Thank you to Professors Donatello Materassi and Rob Wood for their help.

Andrew Gibiansky andrew.gibiansky@gmail.com

Quadcopter Dynamics, Simulation, and Control

You might also like