Quadrotor Dynamics and Control Rev 0.1

Similar documents
UAV Coordinate Frames and Rigid Body Dynamics

Autonomous Fixed Wing Air Vehicles

Equations of Motion for Micro Air Vehicles

16.333: Lecture #3. Frame Rotations. Euler Angles. Quaternions

Lecture AC-1. Aircraft Dynamics. Copy right 2003 by Jon at h an H ow

Chapter 4 The Equations of Motion

Robot Dynamics - Rotary Wing UAS: Control of a Quadrotor

Robot Control Basics CS 685

Chapter 1. Introduction. 1.1 System Architecture

UAVBook Supplement Full State Direct and Indirect EKF

CHAPTER 1. Introduction

Problem 1: Ship Path-Following Control System (35%)

1 Kalman Filter Introduction

CS491/691: Introduction to Aerial Robotics

NONLINEAR CONTROL OF A HELICOPTER BASED UNMANNED AERIAL VEHICLE MODEL

Adaptive Trim and Trajectory Following for a Tilt-Rotor Tricopter Ahmad Ansari, Anna Prach, and Dennis S. Bernstein

Modeling and Sliding Mode Control of a Quadrotor Unmanned Aerial Vehicle

Optimization-Based Control

Dynamics and Control of Rotorcraft

Application of state observers in attitude estimation using low-cost sensors

c 2016 Jan Willem Vervoorst

Phys 7221 Homework # 8

Quadrotor Modeling and Control

UNCLASSIFIED. Control of Spinning Symmetric Airframes. Curtis P. Mracek Max Stafford and Mike Unger Raytheon Systems Company Tucson, AZ 85734

Applications Linear Control Design Techniques in Aircraft Control I

Flight Control Simulators for Unmanned Fixed-Wing and VTOL Aircraft

Trajectory-tracking control of a planar 3-RRR parallel manipulator

12. Rigid Body Dynamics I

Circumnavigation with a group of quadrotor helicopters

Translational and Rotational Dynamics!

Optimization-Based Control

Hamiltonian. March 30, 2013

Research Article Shorter Path Design and Control for an Underactuated Satellite

CP1 REVISION LECTURE 3 INTRODUCTION TO CLASSICAL MECHANICS. Prof. N. Harnew University of Oxford TT 2017

TTK4190 Guidance and Control Exam Suggested Solution Spring 2011

Department of Physics, Korea University Page 1 of 8

Chapter 9. Nonlinear Design Models. Beard & McLain, Small Unmanned Aircraft, Princeton University Press, 2012, Chapter 9, Slide 1

Rotational Kinematics. Description of attitude kinematics using reference frames, rotation matrices, Euler parameters, Euler angles, and quaternions

Fault Diagnosis and Fault-Tolerant Control of Quadrotor UAVs

Visual Servoing for a Quadrotor UAV in Target Tracking Applications. Marinela Georgieva Popova

A Blade Element Approach to Modeling Aerodynamic Flight of an Insect-scale Robot

2 Rotation Kinematics

CONTROL OF ROBOT CAMERA SYSTEM WITH ACTUATOR S DYNAMICS TO TRACK MOVING OBJECT

Simulation of Kinematic and Dynamic Models of an Underwater Remotely Operated Vehicle

MAE 142 Homework #5 Due Friday, March 13, 2009

3 Space curvilinear motion, motion in non-inertial frames

Lecture 11 Overview of Flight Dynamics I. Dr. Radhakant Padhi Asst. Professor Dept. of Aerospace Engineering Indian Institute of Science - Bangalore

EQUIVALENT SINGLE-DEGREE-OF-FREEDOM SYSTEM AND FREE VIBRATION

Two-Dimensional Rotational Dynamics

PLANAR KINETIC EQUATIONS OF MOTION (Section 17.2)

Optimization-Based Control

Adaptive State Estimation Robert Stengel Optimal Control and Estimation MAE 546 Princeton University, 2018

EE565:Mobile Robotics Lecture 6

ME 597: AUTONOMOUS MOBILE ROBOTICS SECTION 3 MOTION MODELING. Prof. Steven Waslander

Design and modelling of an airship station holding controller for low cost satellite operations

Chapter 1 Lecture 2. Introduction 2. Topics. Chapter-1

CALIFORNIA INSTITUTE OF TECHNOLOGY Control and Dynamical Systems. CDS 110b

Autopilot design for small fixed wing aerial vehicles. Randy Beard Brigham Young University

EE Homework 3 Due Date: 03 / 30 / Spring 2015

with Application to Autonomous Vehicles

Lab #4 - Gyroscopic Motion of a Rigid Body

Aerobatic Maneuvering of Miniature Air Vehicles Using Attitude Trajectories

FALL TERM EXAM, PHYS 1211, INTRODUCTORY PHYSICS I Saturday, 14 December 2013, 1PM to 4 PM, AT 1003

Robotics. Dynamics. Marc Toussaint U Stuttgart

Investigation of the Dynamics and Modeling of a Triangular Quadrotor Configuration

Rotational motion of a rigid body spinning around a rotational axis ˆn;

Physics 351, Spring 2015, Final Exam.

Autonomous Helicopter Landing A Nonlinear Output Regulation Perspective

Spacecraft Dynamics and Control

Lecture 9: Modeling and motion models

Attitude Regulation About a Fixed Rotation Axis

Artificial Intelligence & Neuro Cognitive Systems Fakultät für Informatik. Robot Dynamics. Dr.-Ing. John Nassour J.

A Comparison of Closed-Loop Performance of Multirotor Configurations Using Non-Linear Dynamic Inversion Control

Dynamics. 1 Copyright c 2015 Roderic Grupen

Chapter 6: Vector Analysis

Nonlinear and Neural Network-based Control of a Small Four-Rotor Aerial Robot

ECEn 483 / ME 431 Case Studies. Randal W. Beard Brigham Young University

Rotational Kinematics and Dynamics. UCVTS AIT Physics

Quadcopter Dynamics 1

QUADROTOR: FULL DYNAMIC MODELING, NONLINEAR SIMULATION AND CONTROL OF ATTITUDES

In the presence of viscous damping, a more generalized form of the Lagrange s equation of motion can be written as

A Crash Course on Kalman Filtering

ENHANCED PROPORTIONAL-DERIVATIVE CONTROL OF A MICRO QUADCOPTER

Evaluation of different wind estimation methods in flight tests with a fixed-wing UAV

MEMS Gyroscope Control Systems for Direct Angle Measurements

2.003 Engineering Dynamics Problem Set 4 (Solutions)

MODELING AND DYNAMIC ANALYSIS OF A MULTI-JOINT MORPHING AIRCRAFT

Topic # Feedback Control

ENGR352 Problem Set 02

EEL 5544 Noise in Linear Systems Lecture 30. X (s) = E [ e sx] f X (x)e sx dx. Moments can be found from the Laplace transform as

Computer Problem 1: SIE Guidance, Navigation, and Control

Chapter 8. Centripetal Force and The Law of Gravity

Flight Dynamics and Control

Position and orientation of rigid bodies

Mathematical Modelling and Dynamics Analysis of Flat Multirotor Configurations

= o + t = ot + ½ t 2 = o + 2

Physics 200 Lecture 4. Integration. Lecture 4. Physics 200 Laboratory

Lesson Rigid Body Dynamics

THE REACTION WHEEL PENDULUM

Nonlinear Landing Control for Quadrotor UAVs

Transcription:

Brigham Young University BYU ScholarsArchive All Faculty Publications 28-5-5 Quadrotor Dynamics and Control Rev.1 Randal Beard beard@byu.edu Follow this and additional works at: https://scholarsarchive.byu.edu/facpub Part of the Electrical and Computer Engineering Commons Original Publication Citation null BYU ScholarsArchive Citation Beard, Randal, "Quadrotor Dynamics and Control Rev.1" (28). All Faculty Publications. 1325. https://scholarsarchive.byu.edu/facpub/1325 This Report is brought to you for free and open access by BYU ScholarsArchive. It has been accepted for inclusion in All Faculty Publications by an authorized administrator of BYU ScholarsArchive. For more information, please contact scholarsarchive@byu.edu.

Quadrotor Dynamics and Control Randal W. Beard Brigham Young University February 19, 28 1 Reference Frames This section describes the various reference frames and coordinate systems that are used to describe the position of orientation of aircraft, and the transformation between these coordinate systems. It is necessary to use several different coordinate systems for the following reasons: Newton s equations of motion are given the coordinate frame attached to the quadrotor. Aerodynamics forces and torques are applied in the body frame. On-board sensors like accelerometers and rate gyros measure information with respect to the body frame. Alternatively, GPS measures position, ground speed, and course angle with respect to the inertial frame. Most mission requirements like loiter points and flight trajectories, are specified in the inertial frame. In addition, map information is also given in an inertial frame. One coordinate frame is transformed into another through two basic operations: rotations and translations. Section 1.1 develops describes rotation matrices and their use in transforming between coordinate frames. Section 1.2 describes the specific coordinate frames used for micro air vehicle systems. In Section 1.3 we derive the Coriolis formula which is the basis for transformations between between between translating and rotating frames. 1

1.1 Rotation Matrices We begin by considering the two coordinate systems shown in Figure 1. The Figure 1: Rotation in 2D vector p can be expressed in both the F frame (specified by (î, ĵ, ˆk )) and in the F 1 frame (specified by (î 1, ĵ 1, ˆk 1 )). In the F frame we have Alternatively in the F 1 frame we have p = p xî + p yĵ + p zˆk. p = p 1 xî1 + p 1 yĵ1 + p 1 zˆk 1. Setting these two expressions equal to each other gives p 1 xî1 + p 1 yĵ1 + p 1 zˆk 1 = p xî + p yĵ + p zˆk. Taking the dot product of both sides with î 1, ĵ 1, and ˆk 1 respectively, and stacking the result into matrix form gives p 1 p 1 = x î 1 î î 1 ĵ î 1 ˆk p p 1 y = ĵ 1 î ĵ 1 ĵ ĵ 1 ˆk x p p 1 z ˆk 1 î ˆk1 ĵ ˆk1 ˆk y. p z From the geometry of Figure 1 we get p 1 = R 1 p, (1) 2

where R 1 = cos(θ) sin(θ) sin(θ) cos(θ). 1 The notation R 1 is used to denote a rotation matrix from coordinate frame F to coordinate frame F 1. Proceeding in a similar way, a right-handed rotation of the coordinate system about the y-axis gives R 1 = cos(θ) sin(θ) 1, sin(θ) cos(θ) and a right-handed rotation of the coordinate system about the x-axis resultes in 1 R 1 = cos(θ) sin(θ). sin(θ) cos(θ) As pointed out in [1], the negative sign on the sin term appears above the line with only ones and zeros. The matrix R 1 in the above equations are examples of a more general class of rotation matrices that have the following properties: P.1. (R b a) 1 = (R b a) T = R a b. P.2. R c b Rb a = R c a. P.3. det R b a = 1. In the derivation of Equation (1) note that the vector p remains constant and the new coordinate frame F 1 was obtained by rotating F through a rightedhanded rotation of angle θ. We will now derive a formula, called the rotation formula that performs a left-handed rotation of a vector p about another vector ˆn by an angle of µ. Our derivation follows that given in [1]. Consider Figure 2 which is similar to Figure 1.2-2 in [1]. The vector p is rotated, in a left-handed sense, about a unit vector ˆn by an angle of µ to produce the vector q. The angle between p and ˆn is φ. By geometry we have that q = ON + NW + 3 W Q. (2)

Figure 2: Left-handed rotation of a vector p about the unit vector ˆn by an angle of µ to obtain the vector q. The vector the direction of ˆn: ON can be found by taking the projection of p on the unit vector ˆn in ON = (p ˆn) ˆn. The vector NW is in the direction of p ON with a length of N Q cos µ. Noting that the length NQ equals the length NP which is equal to p ON we get that NW p (p ˆn) ˆn = NQ cos µ p (p ˆn) ˆn = (p (p ˆn) ˆn) cos µ. The vector W Q is perpendicular to both p and ˆn and has length NQ sin µ. Noting that NQ = p sin φ we get Therefore Equation (2) becomes W Q = p ˆn NQ sin µ p sin φ = ˆn p sin µ. q = (1 cos µ) (p ˆn) ˆn + cos µp sin µ (ˆn p), (3) 4

Figure 3: Rotation of p about the z-axis. which is called the rotation formula. As an example of the application of Equation (3) consider a left handed rotation of a vector p in frame F about the z-axis as shown in Figure 3. Using the rotation formula we get q = (1 cos θ)(p ˆn)ˆn + cos φp sin φˆn p p = (1 cos φ)p x z + cos φ p y sin φ 1 p z cos φ sin φ = sin φ cos φ p 1 = R 1 p. Note that the rotation matrix R 1 can be interpreted in two different ways. The first interpretation is that it transforms the fixed vector p from an expression in frame F to an expression in frame F 1 where F 1 has been obtained from F by a right-handed rotation. The second interpretation is that it rotates a vector p though a left-handed rotation to a new vector q in the same reference frame. Right-handed rotations of vectors are obtained by using (R 1 ) T. p y p x 5

1.2 Quadrotor Coordinate Frames For quadrotors there are several coordinate systems that are of interest. In this section we will define and describe the following coordinate frames: the inertial frame, the vehicle frame, the vehicle-1 frame, the vehicle-2 frame, and the body frame. Throughout the book we assume a flat, non-rotating earth: a valid assumption for quadrotors. 1.2.1 The inertial frame F i. The inertial coordinate system is an earth fixed coordinate system with origin at the defined home location. As shown in Figure 4, the unit vector î i is directed North, ĵ i is directed East, and ˆk i is directed toward the center of the earth. Figure 4: The inertial coordinate frame. The x-axis points North, the y-axis points East, and the z-axis points into the Earth. 1.2.2 The vehicle frame F v. The origin of the vehicle frame is at the center of mass of the quadrotor. However, the axes of F v are aligned with the axis of the inertial frame F i. In other words, the unit vector î v points North, ĵ v points East, and ˆk v points toward the center of the earth, as shown in Figure 5. 1.2.3 The vehicle-1 frame F v1. The origin of the vehicle-1 frame is identical to the vehicle frame, i.e, the the center of gravity. However, F v1 is positively rotated about ˆk v by the yaw angle ψ so that if the airframe is not rolling or pitching, then î v1 would point out the nose 6

Figure 5: The vehicle coordinate frame. The x-axis points North, the y-axis points East, and the z-axis points into the Earth. Figure 6: The vehicle-1 frame. If the roll and pitch angels are zero, then the x-axis points out the nose of the airframe, the y-axis points out the right wing, and the z-axis points into the Earth. of the airframe, ĵ v1 points out the right wing, and ˆk v1 is aligned with ˆk v and points into the earth. The vehicle-1 frame is shown in Figure 6. The transformation from F v to F v1 is given by p v1 = R v1 v (ψ)p v, where R v1 v (ψ) = cos ψ sin ψ sin ψ cos ψ. 1 7

1.2.4 The vehicle-2 frame F v2. The origin of the vehicle-2 frame is again the center of gravity and is obtained by rotating the vehicle-1 frame in a right-handed rotation about the ĵ v1 axis by the pitch angle θ. If the roll angle is zero, then î v2 points out the nose of the airframe, ĵ v2 points out the right wing, and ˆk v2 points out the belly, a shown in Figure 7. Figure 7: The vehicle-2 frame. If the roll angel is zero, then the x-axis points out the nose of the airframe, the y-axis points out the right wing, and the z-axis points out the belly. The transformation from F v1 to F v2 is given by p v2 = R v2 v1(θ)p v1, where cos θ sin θ Rv1(θ) v2 = 1. sin θ cos θ 1.2.5 The body frame F b. The body frame is obtained by rotating the vehicle-2 frame in a right handed rotation about î v2 by the roll angle φ. Therefore, the origin is the center-of-gravity, î b points out the nose of the airframe, ĵ b points out the right wing, and ˆk b points out the belly. The body frame is shown in Figure 8. The transformation from F v2 to F b is given by p b = R b v2(φ)p v2, 8

Figure 8: The body frame. The x-axis points out the nose of the airframe, the y-axis points out the right wing, and the z-axis points out the belly. where 1 Rv2(φ) b = cos φ sin φ. sin φ cos φ The transformation from the vehicle frame to the body frame is given by Rv(φ, b θ, ψ) = Rv2(φ)R b v1(θ)r v2 v v1 (ψ) 1 cos θ sin θ cos ψ sin ψ = cos φ sin φ 1 sin ψ cos ψ sin φ cos φ sin θ cos θ 1 cθcψ cθsψ sθ = sφsθcψ cφsψ sφsθsψ + cφcψ sφcθ, cφsθcψ + sφsψ cφsθsψ sφcψ cφcθ where cφ = cos φ and sφ = sin φ. 1.3 Equation of Coriolis In this section we provide a simple derivation of the famous equation of Coriolis. We will again follow the derivation given in [1]. Suppose that we are given two coordinate frames F i and F b as shown in Figure 9. For example, F i might represent the inertial frame and F b might represent the body frame of a quadrotor. Suppose that the vector p is moving in F b and that F b is rotating and translating with respect to F i. Our objective is to find the time derivative of p as seen from frame F i. We will derive the appropriate equation through two steps. Assume first that F b is not rotating with respect to F i. Denoting the time derivative of p in frame 9

Figure 9: Derivation of the equation of Coriolis. F i as d dt i p we get d p = d p. (4) dt i dt b On the other hand, assume that p is fixed in F b but that F b is rotating with respect to F i, and let ŝ be the instantaneous axis of rotation and δφ the (right-handed) rotation angle. Then the rotation formula (3) gives p + δp = (1 cos( δφ))ŝ(ŝ p) + cos( δφ)p sin( δφ)ŝ p. Using a small angle approximation and dividing both sides by δt gives δp δt δφ δt ŝ p. Taking the limit as δt and defining the angular velocity of F b with respect to F i as ω b/i = ŝ φ we get d dt i p = ω b/i p. (5) Since differentiation is a linear operator we can combine Equations (4) and (5) to obtain d p = d p + ω b/i p, (6) dt i dt b which is the equation of Coriolis. 1

2 Kinematics and Dynamics In this chapter we derive the expressions for the kinematics and the dynamics of a rigid body. While the expressions derived in this chapter are general to any rigid body, we will use notation and coordinate frames that are typical in the aeronautics literature. In particular, in Section 2.1 we define the notation that will be used for the state variables of a quadrotor. In Section 2.2 we derive the expressions for the kinematics, and in Section 2.3 we derive the dynamics. 2.1 Quadrotor State Variables The state variables of the quadrotor are the following twelve quantities p n = the inertial (north) position of the quadrotor along î i in F i, p e = the inertial (east) position of the quadrotor along ĵ i in F i, h = the altitude of the aircraft measured along ˆk i in F i, u = the body frame velocity measured along î b in F b, v = the body frame velocity measured along ĵ b in F b, w = the body frame velocity measured along ˆk b in F b, φ = the roll angle defined with respect to F v2, θ = the pitch angle defined with respect to F v1, ψ = the yaw angle defined with respect to F v, p = the roll rate measured along î b in F b, q = the pitch rate measured along ĵ b in F b, r = the yaw rate measured along ˆk b in F b. The state variables are shown schematically in Figure 1. The position (p n, p e, h) of the quadrotor is given in the inertial frame, with positive h defined along the negative Z axis in the inertial frame. The velocity (u, v, w) and the angular velocity (p, q, r) of the quadrotor are given with respect to the body frame. The Euler angles (roll φ, pitch θ, and yaw χ) are given with respect to the vehicle 2-frame, the vehicle 1-frame, and the vehicle frame respectively. 11

2.2 Quadrotor Kinematics Figure 1: Definition of Axes The state variables p n, p e, and h are inertial frame quantities, whereas the velocities u, v, and w are body frame quantities. Therefore the relationship between position and velocities is given by d dt p n u p e = Rb v v h w u = (Rv) b T v w cθcψ sφsθcψ cφsψ cφsθcψ + sφsψ u = cθsψ sφsθsψ + cφcψ cφsθsψ sφcψ v. sθ sφcθ cφcθ w The relationship between absolute angles φ, θ, and ψ, and the angular rates p, q, and r is also complicated by the fact that these quantities are defined in different coordinate frames. The angular rates are defined in the body frame F b, whereas the roll angle φ is defined in F v2, the pitch angle θ is defined in F v1, and the yaw angle ψ is defined in the vehicle frame F v. We need to relate p, q, and r to φ, θ, and ψ. Since φ, θ, ψ are small and noting that Rv2( b φ) = Rv1( v2 θ) = Rv v1 ( ψ) = I, 12

we get p φ q = Rv2( b φ) + Rv2(φ)R b v1( v2 θ) θ + Rv2(φ)R b v1(θ)r v2 v v1 ( ψ) r ψ φ 1 1 cos θ sin θ = + cos φ sin φ θ + cos φ sin φ 1 sin φ cos φ sin φ cos φ sin θ cos θ ψ 1 sθ φ = cφ sφcθ θ. (7) sφ cφcθ ψ Inverting we get φ 1 sin(φ) tan(θ) cos(φ) tan(θ) p θ = cos(φ) sin(φ) q. (8) ψ sin(φ) sec(θ) cos(φ) sec(θ) r 2.3 Rigid Body Dynamics Let v be the velocity vector of the quadrotor. Newton s laws only hold in inertial frames, therefore Newton s law applied to the translational motion is m dv dt i = f, where m is the mass of the quadrotor, f is the total applied to the quadrotor, and d dt i is the time derivative in the inertial frame. From the equation of Coriolis we have m dv ( ) dv = m + ω b/i v = f, (9) dt i dt b where ω b/i is the angular velocity of the airframe with respect to the inertial frame. Since the control force is computed and applied in the body coordinate system, and since ω is measured in body coordinates, we will express Eq (9) in body coordinates, where v b = (u, v, w) T, and ωb/i b = (p, q, r) T. Therefore, in body coordinates, Eq. (9) becomes u rv qw v = pw ru + 1 m ẇ qu pv 13 f x f y f z, (1)

where f b = (f x, f y, f z ) T. For rotational motion, Newton s second law states that dh b dt i = m, where h is the angular momentum and m is the applied torque. Using the equation of Coriolis we have dh = dh + ω b/i h = m. (11) dt i dt b Again, Eq. (11) is most easily resolved in body coordinates where h b = Jω b b/i where J is the constant inertia matrix given by (y 2 + z 2 ) dm xy dm xz dm J = xy dm (x 2 + z 2 ) dm yz dm xz dm yz dm (x 2 + y 2 ) dm J x J xy J xz = J xy J y J yz. J xz J yz J z Figure 11: The moments of inertia for the quadrotor are calculated assuming a spherical dense center with mass M and radius R, and point masses of mass m located at a distance of l from the center. As shown in Figure 11, the quadrotor is essentially symmetric about all three axes, therefore J xy = J xz = J yz = which implies that J x J = J y. J z 14

Therefore 1 J 1 J x = 1 J y. 1 J z The inertia for a solid sphere is given by J = 2MR 2 /5[2]. Therefore J x = 2MR2 5 J y = 2MR2 5 J z = 2MR2 5 + 2l 2 m + 2l 2 m + 4l 2 m. Defining m b = (τ φ, τ θ, τ ψ ) T we can write Eq. (11) in body coordinates as 1 ṗ J x r q J x p τ φ q = 1 J y r p J y q + τ θ ṙ 1 q p J J z r τ ψ z J y J z 1 J x qr J J = z J x J y pr x τ φ + 1 J y τ θ. 1 pq J z τ ψ J x J y J z The six degree of freedom model for the quadrotor kinematics and dynamics can be summarized as follows: ṗ n cθcψ sφsθcψ cφsψ cφsθcψ + sφsψ u ṗ e = cθsψ sφsθsψ + cφcψ cφsθsψ sφcψ v (12) ḣ sθ sφcθ cφcθ w u rv qw v = pw ru + 1 f x f y, (13) m ẇ qu pv f z φ 1 sin φ tan θ cos φ tan θ p θ = cos φ sin φ q (14) sin φ cos φ ψ r cos θ cos θ J y J z 1 ṗ J q x qr J J = z J x J y pr x τ φ + 1 J y τ θ. (15) ṙ 1 pq J z τ ψ J x J y J z 15

3 Forces and Moments The objective of this section is to describe the forces and torques that act on the quadrotor. Since there are no aerodynamic lifting surfaces, we will assume that the aerodynamic forces and moments are negligible. The forces and moments are primarily due to gravity and the four propellers. front left right back Figure 12: The top view of the quadrotor. Each motor produces an upward force F and a torque τ. The front and back motors spin clockwise and the right and left motors spin counterclockwise. Figure 13: Definition of the forces and torques acting on the quadrotor. Figure 12 shows a top view of the quadrotor systems. As shown in Figure 13, each motor produces a force F and a torque τ. The total force acting on the 16

quadrotor is given by F = F f + F r + F b + F l. The rolling torque is produced by the forces of the right and left motors as τ φ = l(f l F r ). Similarly, the pitching torque is produced by the forces of the front and back motors as τ θ = l(f f F b ). Due to Newton s third law, the drag of the propellers produces a yawing torque on the body of the quadrotor. The direction of the torque will be in the oppositive direction of the motion of the propeller. Therefore the total yawing torque is given by τ ψ = τ r + τ l τ f τ b. The lift and drag produced by the propellers is proportional to the square of the angular velocity. We will assume that the angular velocity is directly proportional to the pulse width modulation commend sent to the motor. Therefore, the force and torque of each motor can be expressed as F = k 1 δ τ = k 2 δ, where k 1 and k 2 are constants that need to be determined experimentally, δ is the motor command signal, and represents f, r, b, and l. Therefore, the forces and torques on the quadrotor can be written in matrix form as F k 1 k 1 k 1 k 1 δ f δ f τ φ τ θ = lk 1 lk 1 δ r lk 1 lk 1 δ b = M δ r δ b. τ ψ k 2 k 2 k 2 k 2 δ l δ l The control strategies derived in subsequent sections will specify forces and torques. The actual motors commands can be found as δ f F δ r δ b = M 1 τ φ τ θ. δ l τ ψ 17

Note that the pulse width modulation commands are required to be between zero and one. In addition to the force exerted by the motor, gravity also exerts a force on the quadrotor. In the vehicle frame F v, the gravity force acting on the center of mass is given by fg v =. mg However, since v in Equation (13) is expressed in F b, we must transform to the body frame to give fg b = Rv b mg mg sin θ = mg cos θ sin φ. mg cos θ cos φ Therefore, equations (12) (15) become ṗ n cθcψ sφsθcψ cφsψ cφsθcψ + sφsψ u ṗ e = cθsψ sφsθsψ + cφcψ cφsθsψ sφcψ v (16) ḣ sθ sφcθ cφcθ w u rv qw g sin θ v = pw ru + g cos θ sin φ + 1, (17) m ẇ qu pv g cos θ cos φ F φ 1 sin φ tan θ cos φ tan θ p θ = cos φ sin φ q, (18) sin φ cos φ ψ r cos θ cos θ J y J z 1 ṗ J q x qr J J = z J x J y pr x τ φ + 1 J y τ θ. (19) ṙ 1 pq J z τ ψ J x J y J z 4 Simplified Models Equations (16) (19) are the equations of motion to be used in our six degreeof-freedom simulator. However, they are not appropriate for control design for 18

several reasons. The first reason is that they are too complicated to gain significant insight into the motion. The second reason is that the position and orientation are relative to the inertial world fixed frame, whereas camera measurements will measure position and orientation of the target with respect to the camera frame. 4.1 Model for estimation For the quadrotor, we are not able to estimate the inertial position or the heading angle ψ. Rather, we will be interested in the relative position and heading of the quadrotor with respect to a ground target. The relative position of the quadrotor will be measured in the vehicle-1 frame, i.e., the vehicle frame after it has been rotated by the heading vector ψ. The vehicle-1 frame is convenient since x, y, and z positions are still measured relative to a flat earth, but they are vehicle centered quantities as opposed to inertial quantities. Let p x, p y, and p z denote the relative position vector between the target and the vehicle resolved in the v1 frame. Therefore Eq (16) becomes ṗ x cθ sφsθ cφsθ u ṗ y = cφ sφ v. (2) ṗ z sθ sφcθ cφcθ w 4.2 Model for control design Assuming that φ and θ are small, Equation (18) can be simplified as φ p θ = q. (21) ψ r Similarly, Equation (19) is simplified by assuming that the Coriolis terms qr, pr, and pq, are small to obtain 1 ṗ J x τ φ q = 1 J y τ θ. (22) ṙ 1 J z τ ψ Combining Eq. (21) and (22) we get φ θ = ψ 19 1 J x τ φ 1 J y τ θ 1 J z τ ψ. (23)

Differentiating Eq. (16) and neglecting Ṙv b gives p n cθcψ sφsθcψ cφsψ cφsθcψ + sφsψ u p e = cθsψ sφsθsψ + cφcψ cφsθsψ sφcψ v. (24) p d sθ sφcθ cφcθ ẇ Neglecting the Coriolis terms and plugging Eq. (17) into Eq. (24) and simplifying gives p n cφsθcψ sφsψ p e = + cφsθsψ + sφcψ F m. (25) p d g cφcθ Therefore, the simplified inertial model is given by p n = ( cos φ sin θ cos ψ sin φ sin ψ) F m p e = ( cos φ sin θ sin ψ + sin φ cos ψ) F m p d = g (cos φ cos θ) F m (26) (27) (28) φ = 1 J x τ φ (29) θ = 1 J y τ θ (3) ψ = 1 J z τ ψ. (31) (32) The dynamics given in Equations (26) (31) are expressed in the inertial frame. This is necessary for the simulator. However, we will be controlling position, altitude, and heading using camera frame measurements of a target position. In this setting heading is irrelevant. Therefore, instead of expressing the translational dynamics in the inertial frame, we will express them in the vehicle-1 frame F v1, which is equivalent to the inertial frame after rotating by the heading angle. Differentiating Eq. (2) and neglecting Ṙv1 b gives p x p y = p z cθ sφsθ cφsθ u cφ sφ v. (33) sθ sφcθ cφcθ ẇ 2

Neglecting the Coriolis terms and plugging Eq. (17) into Eq. (33) and simplifying gives p x cφsθ p y = + sφ F m. (34) p z g cφcθ Therefore, the simplified model in the vehicle-1 frame is given by p x = cos φ sin θ F m p y = sin φ F m p z = g cos φ cos θ F m (35) (36) (37) φ = 1 J x τ φ (38) θ = 1 J y τ θ (39) ψ = 1 J z τ ψ. (4) (41) 5 Sensors 5.1 Rate Gyros A MEMS rate gyro contains a small vibrating lever. When the lever undergoes an angular rotation, Coriolis effects change the frequency of the vibration, thus detecting the rotation. A brief description of the physics of rate gyros can be found at RateSensorAppNote.pdf. The output of the rate gyro is given by y gyro = k gyro Ω + β gyro + η gyro, where y gyro is in Volts, k gyro is a gain, Ω is the angular rate in radians per second, β gyro is a bias term, and η gyro is zero mean white noise. The gain k gyro should be given on the spec sheet of the sensor. However, due to variations in manufacturing it is imprecisely known. The bias term β gyro is strongly dependent on temperature and should be calibrated prior to each flight. 21

If three rate gyros are aligned along the x, y, and z axes of the quadrotor, then the rate gyros measure the angular body rates p, q, and r as follows: y gyro,x = k gyro,x p + β gyro,x + η gyro,x y gyro,y = k gyro,y q + β gyro,y + η gyro,y y gyro,z = k gyro,z r + β gyro,z + η gyro,z. MEMS gyros are analog devices that are sampled by the on-board processer. We will assume that the sample rate is given by T s. The Kestrel autopilot samples the gyros at approximately 12 Hz. 5.2 Accelerometers A MEMS accelerometer contains a small plate attached to torsion levers. The plate rotates under acceleration and changes the capacitance between the plate and the surrounding walls [3]. The output of the accelerometers is given by y acc = k acc A + β acc + η acc, where y acc is in Volts, k acc is a gain, A is the acceleration in meters per second, β acc is a bias term, and η acc is zero mean white noise. The gain k acc should be given on the spec sheet of the sensor. However, due to variations in manufacturing it is imprecisely known. The bias term β acc is strongly dependent on temperature and should be calibrated prior to each flight. Accelerometers measure the specific force in the body frame of the vehicle. A physically intuitive explanation is given in [1, p. 13-15]. Additional explanation is given in [4, p. 27]. Mathematically we have a x In component form we have a y = 1 m (F F gravity) a z = v + ω b b/i v 1 m F gravity. a x = u + qw rv + g sin θ a y = v + ru pw g cos θ sin φ a z = ẇ + pv qu g cos θ cos φ. 22

Using Eq (17) we get a x = a y = a z = F/m, where F is the total thrust produced by the four motors. It is important to note that for the quadrotor, the output of the accelerometers is independent of angle. This is in contrast to the unaccelerated flight for fixed wing vehicles where the accelerometers are used to measure the gravity vector and thereby extract roll and pitch angles. MEMS accelerometers are analog devices that are sampled by the on-board processer. We will assume that the sample rate is given by T s. The Kestrel autopilot samples the accelerometers at approximately 12 Hz. 5.3 Camera The control objective is to hold the position of the quadrotor over a ground based target that is detected using the vision sensor. In this section we will briefly describe how to estimate p x and p y in the vehicle 1-frame. We will assume that the camera is mounted so that the optical axis of the camera is aligned with the body frame z-axis and so that the x-axis of the camera points out the right of the quadrotor and the y-axis of the camera points to the back of the quadrotor. The camera model is shown in Figure 14. The position of the target in the vehicle-1 frame is (p x, p y, p z ). The pixel location of the target in the image is (ɛ x, ɛ y ). The geometry for p y is shown in Figure 15. From the geometry shown in Figure 15, we can see that ( p y = p z tan φ ɛ x η M y ), (42) where η is the camera field-of-view, and M y is the number of pixels along the camera y-axis. In Figure 15, both p y and ɛ x are negative. Positive values are toward the right rotor. A similar equation can be derived for p x as ( ) η p x = p z tan θ ɛ y. (43) M y 23

6 State Estimation Figure 14: Camera model for the quadrotor. The objective of this section is to describe techniques for estimating the state of the quadrotor from sensor measurements. We need to estimate the following states: p x, p y, p z, u, v, w, φ, θ, ψ, p, q, r. The angular rates p, q, and r can be obtained by low pass filtering the rate gyros. The remain states require a Kalman filter. Both are discussed below. 6.1 Low Pass Filters The Laplace transforms representation of a simple low-pass filter is given by Y (s) = a s + a U(s), 24

Optical Axis Target Figure 15: The geometry introduced by the vision system. The height above ground is given by p z, the lateral position error is p y, the roll angle is φ, the field-of-view of the camera is η, the lateral pixel location of the target in the image is ɛ x, and the total number of pixels along the lateral axis of the camera is M x. were u(t) is the input of the filter and y(t) is the output. Inverse Laplace transforming we get ẏ = ay + au. (44) Using a zeroth order approximation of the derivative we get y(t + T ) y(t) = ay(t) + au(t), T where T is the sample rate. Solving for y(t + T ) we get y(t + T ) = (1 at )y(t) + at u(t). For the zeroth order approximation to be valid we need at 1. If we let α = at then we get the simple form y(t + T ) = (1 α)y(t) + αu(t). 25

Note that this equation has a nice physical interpretation: the new value of y (filtered value) is a weighted average of the old value of y and u (unfiltered value). If u is noisy, then α [, 1] should be set to a small value. However, if u is relatively noise free, then α should be close to unity. In the derivation of the discrete-time implementation of the low-pass filter, it is possible to be more precise. In particular, returning to Equation (44), from linear systems theory, it is well known that the solution is given by T y(t + T ) = e at y(t) + a e a(t τ) u(τ) dτ. Assuming that u(t) is constant between sample periods results in the expression T y(t + T ) = e at y(t) + a e a(t τ) dτu(t)y(t + T ) = e at y(t) + (1 e at )u(t). (45) Note that since e x = 1+x+ x2 2! +... we have that e at 1 at and 1 e at at. Therefore, if the sample rate is not fixed (common for micro controllers), and it is desired to have a fixed cut-off frequency, then Equation (45) is the preferable way to implement a low-pass filter in digital hardware. We will use the notation LP F ( ) to represent the low-pass filter operator. Therefore ˆx = LP F (x) is the low-pass filtered version of x. 6.2 Angular Rates p, q, and r. The angular rates p, q, and r can be estimated by low-pass filtering the rate gyro signals: ˆp = LP F (y gyro,x ) (46) ˆq = LP F (y gyro,y ) (47) ˆr = LP F (y gyro,z ). (48) 6.3 Dynamic Observer Theory The objective of this section is to briefly review observer theory. 26

Suppose that we have a linear time-invariant system modeled by the equations ẋ = Ax + Bu y = Cx. A continuous-time observer for this system is given by the equation ˆx = Aˆx + Bu }{{} copy of the model + L (y C ˆx) }{{}, (49) correction due to sensor reading where ˆx is the estimated value of x. Letting x = x ˆx we observer that x = (A LC) x which implies that the observation error decays exponentially to zero if L is chosen such that the eigenvalues of A LC are in the open left half of the complex plane. In practice, the sensors are usually sampled and processed in digital hardware at some sample rate T s. How do we modify the observer equation shown in Equation (49) to account for sampled sensor readings? The typical approach is to propagate the system model between samples using the equation ˆx = Aˆx + Bu (5) and then to update the estimate when a measurement is received using the equation ˆx + = ˆx + L(y(t k ) C ˆx ), where t k is the instant in time that the measurement is received and ˆx is the state estimate produced by Equation (5) at time t k. Equation (5) is then reinstantiated with initial conditions given by ˆx +. The continuous-discrete observer is summarized in Table 6.3. The observation process is shown graphically in Figure 16. Note that it is not necessary to have a fixed sample rate. The continuous-discrete observer can be implemented using Algorithm 1. Note that we did not use the fact that the process was linear. Suppose instead that we have a nonlinear system of the form ẋ = f(x, u) (51) y = c(x) (52), then the continuous discrete observer is given in table 6.3. The real question is how to pick the observer gain L. 27

Figure 16: sdf Algorithm 1 Continuous-Discrete Observer 1: Initialize: ˆx =. 2: Pick an output sample rate T out which is much less than the sample rates of the sensors. 3: At each sample time T out : 4: for i = 1 to N do {Prediction: Propagate the state equation.} 5: ˆx = ˆx + ( T out ) N (Aˆx + Bu) 6: end for 7: if A measurement has been received from sensor i then {Correction: Measurement Update} 8: ˆx = ˆx + L i (y i C iˆx) 9: end if 28

System model: ẋ = Ax + Bu y(t k ) = Cx(t k ) Initial Condition x(). Assumptions: Knowledge of A, B, C, u(t). No measurement noise. Prediction: In between measurements (t [t k 1, t k )): Propagate ˆx = Aˆx + Bu. Initial condition is ˆx + (t k 1 ). Label the estimate at time t k as ˆx (t k ). Correction: At sensor measurement (t = t k ): ˆx + (t k ) = ˆx (t k ) + L (y(t k ) C ˆx (t k )). Table 1: Continuous-Discrete Linear Observer. 6.4 Essentials from Probability Theory Let X = (x 1,..., x n ) T be a random vector whose elements are random variables. The mean, or expected value of X is denoted by µ 1 E{x 1 } µ =. =. = E{X}, E{x n } µ n where E{x i } = ξf i (ξ) dξ, and f( ) is the probability density function for x i. Given any pair of components x i and x j of X, we denote their covariance as cov(x i, x j ) = Σ ij = E{(x i µ i )(x j µ j )}. The covariance of any component with itself is the variance, i.e., var(x i ) = cov(x i, x i ) = Σ ii = E{(x i µ i )(ξ µ i )}. The standard deviation of x i is the square root of the variance: stdev(x i ) = σ i = Σ ii. 29

System model: ẋ = f(x, u) y(t k ) = c(x(t k )) Initial Condition x(). Assumptions: Knowledge of f, c, u(t). No measurement noise. Prediction: In between measurements (t [t k 1, t k )): Propagate ˆx = f(ˆx, u). Initial condition is ˆx + (t k 1 ). Label the estimate at time t k as ˆx (t k ). Correction: At sensor measurement (t = t k ): ˆx + (t k ) = ˆx (t k ) + L (y(t k ) c(ˆx (t k ))). Table 2: Continuous-Discrete Nonlinear Observer. The covariances associated with a random vector X can be grouped into a matrix known as the covariance matrix: Σ 11 Σ 12 Σ 1n Σ 21 Σ 22 Σ 2n Σ =..... = E{(X µ)(x µ)t } = E{XX T } µµ T. Σ n1 Σ n2 Σ nn Note that Σ = Σ T so that Σ is both symmetric and positive semi-definite, which implies that its eigenvalues are real and nonnegative. The probability density function for a Gaussian random variable is given by f x (x) = 1 e (x µ x) 2πσx 2 σx 2, where µ x is the mean of x and σ x is the standard deviation. The vector equivalent is given by [ 1 f X (X) = exp 1 ] 2π det Σ 2 (X µ)t Σ 1 (X µ), in which case we write X N (µ, Σ), 3

Figure 17: Level curves for the pdf of a 2D Gaussian random variable. and say that X is normally distributed with mean µ and covariance Σ. Figure 17 shows the level curves for a 2D Gaussian random variable with different covariance matrices. 6.5 Derivation of the Kalman Filter In this section we assume the following state model: ẋ = Ax + Bu + Gξ y k = Cx k + η k, where y k = y(t k ) is the k th sample of y, x k = x(t k ) is the k th sample of x, η k is the measurement noise at time t k, ξ is a zero-mean Gaussian random process with covariance Q, and η k is a zero-mean Gaussian random variable with covariance R. Note that the sample rate does not need to be be fixed. The observer will therefore have the following form: 31

Prediction: In between measurements: (t [t k 1, t k ]) Propagate ˆx = Aˆx + Bu. Initial condition is ˆx + (t k 1 ). Label the estimate at time t k as ˆx (t k ). Correction: At sensor measurement (t = t k ): ˆx + (t k ) = ˆx (t k ) + L (y(t k ) C ˆx (t k )). Our objective is to pick L to minimize tr(p (t)). 6.5.1 Between Measurements. Differentiating x we get Therefore we have that x = ẋ ˆx = Ax + Bu + Gξ Aˆx Bu = A x + Gξ. x(t) = e At x + t We can therefore compute the evolution for P as P = d dt E{ x xt } e A(t τ) Gξ(τ) dτ. = E{ x x T + x x T } = E { A x x T + Gξ x T + x x T A T + xξ T G T } = AP + P A T + GE{ξ x T } T + E{ xξ T }G T. As in the previous section we get { E{ξ x T } = E ξ(t) x e AT t + = 1 2 QGT, t } ξ(t)ξ T (τ)g T e AT (t τ) dτ which implies that P = AP + P A T + GQG T. 32

6.5.2 At Measurements. At a measurement we have that Therefore x + = x ˆx + = x ˆx L ( Cx + η C ˆx ) = x LC x Lη. P + = E{ x + x +T } { = E ( x LC x Lη ) ( x LC x Lη ) } T = E { x x T x x T C T L T x η T L T LC x x T + LC x x T C T L T + LC x η T L T = Lη x T + Lη x T C T L T + Lηη T L T } = P P C T L T LCP + LCP C T L T + LRL T. (53) Our objective is to pick L to minimize tr(p + ). A necessary condition is L tr(p + ) = P C T P C T + 2LCP C T + 2LR = = 2L(R + CP C T ) = 2P C T = L = P C T (R + CP C T ) 1. Plugging back into Equation (53) give P + = P + P C T (R + CP C T ) 1 CP P C T (R + CP C T ) 1 CP + P C T (R + CP C T ) 1 (CP C T + R)(R + CP C T ) 1 CP = P P C T (R + CP C T ) 1 CP = (I P C T (R + CP C T ) 1 C)P = (I LC)P. For linear systems, the continuous-discrete Kalman filter is summarized in Table 6.5.2 If the system is nonlinear, then the Kalman filter can still be applied but we need to linearize the nonlinear equations in order to compute the error covariance matrix P and the Kalman gain L. The extended Kalman filter (EKF) is given in Table 6.5.2, and an algorithm to implement the EKF is given in Algorithm 2. 33

System model: ẋ = Ax + Bu + ξ y i (t k ) = C i x(t k ) + η k Initial Condition x(). Assumptions: Knowledge of A, B, C i, u(t). Process noise satisfies ξ N (, Q). Measurement noise satisfies η k N (, R). Prediction: In between measurements (t [t k 1, t k )): Propagate ˆx = Aˆx + Bu. Propagate P = AP + P A T + Q. Correction: At the i th sensor measurement (t = t k ): L i = P C T i (R i + C i P C T i ) 1, P + = (I L i C i )P, ˆx + (t k ) = ˆx (t k ) + L (y(t k ) C ˆx (t k )). Table 3: Continuous-Discrete Kalman Filter. 6.6 Application to the quadrotor In this section we will discuss the application of Algorithm 2 to the quadrotor. We would like to estimate the state ˆp x ˆp y ˆp z ˆp x ˆx = ˆp y, ˆp zˆφ ˆθ ˆψ where the rate gyros and accelerometers will be used to drive the prediction step, and an ultrasonic altimeter and camera will be used in the correction step. 34

System model: ẋ = f(x, u) + ξ y i (t k ) = c i (x(t k )) + η k Initial Condition x(). Assumptions: Knowledge of f, c i, u(t). Process noise satisfies ξ N (, Q). Measurement noise satisfies η k N (, R). Prediction: In between measurements (t [t k 1, t k )): Propagate ˆx = f(ˆx, u), Compute A = f x x=ˆx(t), Propagate P = AP + P A T + Q. Correction: At the i th sensor measurement (t = t k ): C i = c i x x=ˆx L i = P Ci T (R i + C i P Ci T ) 1, P + = (I L i C i )P, ˆx + (t k ) = ˆx (t k ) + L (y(t k ) c i (ˆx (t k ))). Table 4: Continuous-Discrete Extended Kalman Filter. The propagation model is obtained from Equations (35) (37), and (18) as ṗ x ṗ y ṗ z cos φ sin θa z f(x, u) = sinφa z, g + cos φ cos θa z p + q sin φ tan θ + r cos φ tan θ q cos φ r sin φ q sin φ + r cos φ cos θ cos θ where we have used the fact that the z-axis of the accelerometer measures a z = 35

Algorithm 2 Continuous-Discrete Extended Kalman Filter 1: Initialize: ˆx =. 2: Pick an output sample rate T out which is much less than the sample rates of the sensors. 3: At each sample time T out : 4: for i = 1 to N do {Prediction: Propagate the equations.} 5: ˆx = ˆx + ( T out ) N (f(ˆx, u)) 6: A = f x 7: P = P + ( T out ) ( AP + P A T + GQG ) T N 8: end for 9: if A measurement has been received from sensor i then {Correction: Measurement Update} 1: C i = c i x 11: L i = P C T i (R i + C i P C T i ) 1 12: P = (I L i C i )P 13: ˆx = ˆx + L i (y i c i (ˆx)). 14: end if F/m. Differentiating we obtain 1 1 1 s φ s θ a z c φ c θ a z A = c φ a z s φ c θ a z c φ s θ a z qcφtθ rsφtθ (qsφ + rcφ)/c 2 θ qsφ rcφ qcφ rsφ (qsφ + rcφ) tθ cθ cθ Note that it may be adequate (not sure) to use a small angle approximation in 36

the model resulting in and ṗ x ṗ y ṗ z θa z f(x, u) = φa z, g + a z p q r 1 1 1 a z A = a z. If this form works, then the update equation for P can be coded by hand, significantly reducing the computational burden. Note also that f(x, u) does not take into account the motion of the target. A feedforward term can be added to f to account for the target motion as ṗ x ṁ x ṗ y ṁ y ṗ z θa z m x f(x, u) = φa z m y, g + a z p q r where (ṁ x, ṁ y ) is the velocity of the target in the vehicle-1 frame, and ( m x, m y ) is the acceleration of the target in the vehicle-1 frame. 37

Let the relative position between the quadrotor and the target be denoted by p v1 = (p x, p y, p z ) T. We can tranform to the camera frame as where p c = R c gr g b Rb v1p v1, 1 Rg c = 1 1 is the rotation matrix from gimbal coordinates to camera coordinates, 1 R g b = 1 1 transforms body coordinates to gimbal coordinates, and cθcψ sφsθcψ cφsψ cφsθcψ + sφsψ Rv1 b = cθsψ sφsθsψ + cφcψ cφsθsψ sφcψ sθ sφcθ cφcθ transforms vehicle-1 coordinates to body coordinates. Using the small angle approximation for φ and θ we get φθp x + p y + φp z p c = p x + θp z θp x φp y + p z. The model for the pixel coordinates are therefore computed as ɛ x = c ɛx (x) = f φθp x + p y + φp z θp x φp y + p z ɛ 2 = c ɛy (x) = p x + θp z f. θp x φp y + p z We therefore have the following sensors available to correct the state estimate: sensor 1: altimeter y 1 = c alt (x) = p z + η 1 [k] (54) sensor 2: vision x-pixel y 2 = c ɛx (x) + η 2 [k]. (55) sensor 3: vision y-pixel y 3 = c ɛy (x) + η 3 [k] (56) sensor 4: vision heading y 4 = c ɛψ (x) = π/2 + ψ + η 4 [k]. (57) 38

The linearization of the first and fourth output functions are given by C 1 = ( 1 ) (58) C 4 = ( 1 ). (59) The linearization of the expression for the pixel coordinates is messy and can easily be computed numerically using the approximation f(x 1,, x i,..., x n ) f(x 1,, x i +,, x n ) f(x 1,, x i,, x n ), x i where is a small constant. 7 Control Design Equa- The control design will be derived directly from Equations (35) (4). tions (38) (4) are already linear. To simplify Equations (35) (37) define to obtain F u x = cosφ sin θ m (6) F u y = sin φ m (61) F u z = g cos φ cos θ m, (62) p x = u x (63) p y = u y (64) p z = u z. (65) The control design proceeds by developing PID control strategies for u x, u y, and u z. After u x, u y, and u z have been computed, we can compute the desired force F, and the commanded roll angle φ c and the commanded pitch angle θ c from Equations (6) (62) as follows. From Equation (62) solve for F/m as F m = g u z cos φ cos θ. (66) 39

Substituting (66) into (61) gives u y = g u z tan φ. cos θ Solving for φ and letting this be the commanded roll angle gives φ c = tan 1 ( uy cos θ g u z ). (67) Similarly, we can solve for the commanded pitch angle as ( ) θ c = tan 1 ux. (68) u z g 7.1 Vision Based Altitude Hold For the altitude hold we need to develop an expression for u z to drive p z to a desired altitude based on the size of the object in the image. We will assume that the camera returns the size of the object in the image plane in pixels, which is denoted by ɛ s. Figure 18 shows the geometry of the quadrotor hovering over a Target Figure 18: The size of the target is S in meters, and the size of the target in the image plane is denoted by ɛ s in pixels. The focal length is f, and the height above the target is p z. target of size S. From similar triangles we have that p z S = f ɛ s. 4

Solving for p z an differentiating we obtain Differentiating again gives ṗ z = fs ɛ s. (69) ɛ 2 s p z = fs ɛ s ɛ 2 s 2fS ɛ2 s. ɛ 3 s Substituting u z = p z and solving for ɛ s gives ( ) ɛ 2 ɛ s = s u z + 2 ɛ2 s. fs ɛ s Defining we get ( ) ɛ 2 u s = s u z + 2 ɛ2 s, (7) fs ɛ s ɛ s = u s. We can now derive a PID controller to drive ɛ s ɛ d s as Solving (7) for u z we get u z = fs k ɛ 2 ps (ɛ d s ɛ s ) s t u s = k ps (ɛ d s ɛ s ) k ds ɛ s + k is (ɛ d s ɛ s ) dτ. ( k ds fs ɛ 2 s + 2 fs ɛ ) s fs ɛ ɛ 3 s + k is s ɛ 2 s t (ɛ d s ɛ s ) dτ. (71) The downside to this equation is that it requires knowledge of the target size S and the focal length f. This requirement can be removed by incorporating fs into the PID gains by defining ˆk ps = fskps ˆk is = fskis ˆk ds = fskds, fs ɛs ɛ 2 s and by noting from Equation (69) that = w. Therefore Equation (71) becomes ( ) u z = ˆk (ɛ d s ɛ s ) ˆkds ps + 2 w ɛ ɛ 2 s ɛ 2 s + ˆk t is (ɛ d s ɛ s ɛ 2 s ɛ s ) dτ. (72) s 41

7.2 Roll Attitude Hold The equation of motion for roll is given by Eq. (38) as φ = τ p /J x. We will use a PID controller to regulate the roll attitude as t τ p = k pφ (φ c φ) k dφ p + k iφ (φ c φ) dτ. A block diagram of the control structure is shown in Figure 19. Figure 19: A block diagram of the roll attitude hold loop. The gains k pφ, k iφ, and k dφ are selected one at a time using a method called successive loop closure. To pick k pφ note that if the input command φ c is a step of value A, then at time t =, before the integrator has time to begin winding up, τ x is given by τ x () = k pφ A. Therefore, setting k pφ = M/A will just saturate the actuators when a step value of A is placed on φ c. To select k dφ, let k pφ be fixed and let k iφ =, and solve for the characteristic equation in Evan s form verses k dφ to obtain 1 J 1 + k x s dφ =. s 2 + k p φ J x The derivative gain k dφ is selected to achieve a damping ratio of ζ =.9. The characteristic equation including k iφ in Evan s form verses k iφ is given by 1 + k iφ 1 J x s 3 + k d φ J x s 2 + kp φ J x s 42 =.

The integral gain k iφ can be selected so that damping ratio is not significantly changed. 7.3 Pitch Attitude Hold The equation of motion for pitch is given by Eq. (39) as θ = τ q /J y. Similar to the roll attitude hold, we will use a PID controller to regulate pitch as t τ q = k pθ (θ c θ) k dθ q + k iθ (θ c θ) dτ. 7.4 Vision Based Position Tracking From Equation 64 the lateral dynamics are given by p y = u y, where p y is the relative lateral position which we drive to zero using the PID strategy t u y = k py p y k dy v + k iy p y dτ. The relative position error p y is given by Equation (42). From Equation 63 the longitudinal dynamics are given by p x = u x, where p x is the relative lateral position which we drive to zero using the PID strategy t u x = k px p x k dx u + k ix p x dτ. The relative position error p x is given by Equation (43). 7.5 Relative Heading Hold The heading dynamics are given in Equation (4) as ψ = τ r /J z. Define ψ d as the inertial heading of the target, and define ψ = ψ ψ d as the relative heading. The camera directly measures ψ. Assuming that ψ d is constant we get ψ = τr /J z. We regulate the relative heading with the PID strategy t τ r = k pψ ψ k dψ r k iψ ψ dτ. 43

7.6 Feedforward When the quadrotor is tracking a ground robot, the motion of the robot will cause tracking errors due to the delayed response of the PID controller. If we can communicate with the robot, and we know its intended motion, we should be able to use that information to help the quadrotor predict where the robot is moving. To motivate our approach, lets consider a simple example to gain intuition. Consider the double integrator system ÿ = u, where y is position, and u is commanded acceleration. If r is the reference signal then the standard PD loop is shown in Figure 2. Figure 2: Standard PD loop Let e = r y, then ë = r ÿ = r u = r k p e + k d ẏ = r k p e k d ė + k d ṙ. In other words we have ë + k d ė + k p e = r + k d ṙ. 1 Therefore, the signal r + k d ṙ drives the error transfer function is not zero, the tracking error will not go to zero. s 2 +k d s+kp and if w 44

From the expression ë = r u we see that if instead of u = k p e k d ẏ, we instead use u = r + k p e + k d ė, then we get ë + k d ė + k p e =, which ensures that e(t) independent of r(t). The associated block diagram is shown in Figure 21. Figure 21: Feedforward term is added to a standard PD loop. Now consider the lateral motion of the quadrotor in the cage where ÿ = g tan φ, where y is the position of the quadrotor, g is the gravity constant, and φ is the roll angle. Let m(t) be the position of the target and define y = m r as the relative position. Then ÿ = m r = m g tan φ. If by some means we know the target velocity ṁ and the target acceleration m, then we should pick φ such that g tan φ = m + k p y + k d ẏ, or ( ) m + φ = tan 1 kp y + k d ẏ. g 45

Given the decoupling terms described at the beginning of this section, the motion model for the quadrotor in the vehicle-1 frame is given by p x = u x p y = u y ψ = u ψ. Let the position of the target in the vehicle-1 frame be given by (m x, m y ) and let it orientation be given by ψ t, and define Differentiating twice we get p x = m x p x p y = m y p y ψ = ψ t ψ. p x = m x u x p y = m y u y ψ = ψ t u ψ. Therefore, adding a feedforward term we have u x = m x + P ID x u y = m y + P ID y u ψ = ψ t + P ID ψ where P ID are the PID controllers derived earlier in this chapter. The motion model for the target is given by ṁ n = V t cos ψ t ṁ e = V t sin ψ t V t = u 1 ψ t = u 2, where (m n, m e ) is the inertial position of the target, V t is the ground speed of the target, and u 1 and u 2 are robot control signals. In the vehicle-1 frame we have ) ( ) ( ) ( (ṁx cos ψ sin ψ Vt cos ψ = t Vt cos = ψ ) sin ψ cos ψ V t sin ψ t V t sin ψ, ṁ y 46

where the camera measures the relative heading ψ = ψ ψ t. Differentiating we obtain ( ) ( ) ( ) mx cos ψ sin ψ u1 = m y sin ψ cos ψ u 2 ψ. To implement feedforward on the quadrotors, we must communicate with the robot to obtain V t, u 1, and u 2. References [1] B. L. Stevens and F. L. Lewis, Aircraft Control and Simulation. Hoboken, New Jersey: John Wiley & Sons, Inc., 2nd ed., 23. [2] D. Halliday and R. Resnick, Fundamentals of Physics. John Wiley & Sons, 3rd ed., 1988. [3] http://www.silicondesigns.com/tech.html. [4] M. Rauw, FDC 1.2 - A SIMULINK Toolbox for Flight Dynamics and Control Analysis, February 1998. Available at http://www.mathworks.com/. 47