acebulla_BachelorThesis

download acebulla_BachelorThesis

of 61

Transcript of acebulla_BachelorThesis

  • 8/12/2019 acebulla_BachelorThesis

    1/61

    Preparing a Quadrotor for Following aHuman Being Indoors While Avoiding

    Obstacles

    Alexander Cebulla

    Bachelor Thesis

    April 2014

    Supervisors:

    Tobias Ngeli

    Prof. Dr. Otmar Hilliges

  • 8/12/2019 acebulla_BachelorThesis

    2/61

  • 8/12/2019 acebulla_BachelorThesis

    3/61

    Abstract

    Smartphones are widely used throughout the society. Providing them with the ability of au-tonomous motion would lead to many interesting new uses, for example, taking images of one-self while exercising. A possible way to achieve this is through utilizing a quadrotor. Therefore,this thesis discusses the preparation of one, such that it is able to follow a human being indoors

    while avoiding obstacles.An existing marker detection system was extended with a lightweight rc servo-based pan/tiltplatform, which allows the quadrotor to keep track of a human carrying the marker withoutan immediate need to move itself. The design of the platform and the implementation of thenecessary driver and controller to use it are presented.Ultrasonic distance sensors were used to detect and avoid obstacles. To read them out an exist-ing driver was extended such that it works with multiple sensors. Ultrasonic distance sensorscan influence the measurements of each other when they are used at the same time and it wasinvestigated how this could be reduced through attaching funnels to them.An extension of an existing quadrotor position controller was devised, which can navigate thequadrotor to a predefined position relative to the marker while avoiding obstacles. The func-tionality of this extension was tested through a simulation.

    i

  • 8/12/2019 acebulla_BachelorThesis

    4/61

    ii

  • 8/12/2019 acebulla_BachelorThesis

    5/61

    Acknowledgments

    I want to thank Prof. Dr. Hilliges for providing me with the opportunity to do this thesis and mysupervisor Tobias Ngeli, who always supported me with encouragements and helpful sugges-tions.Furthermore, I want to thank my family and my friends for their moral support.

    Finally, I extend my gratitude to the members of the Bastli

    1

    , the electronic laboratory of theAMIV students union, for the many insightful discussions.

    1http://bastli.ethz.ch/

    iii

    http://bastli.ethz.ch/http://bastli.ethz.ch/
  • 8/12/2019 acebulla_BachelorThesis

    6/61

    iv

  • 8/12/2019 acebulla_BachelorThesis

    7/61

    E11IEidgenossische Technische Hochschule ZurichSwiss Federal Institute of Technology Zurich

    igenstandigkeitserklarungDie unterzeichnete Eigenstandigkeitserklarung ist Bestandteil jeder wahrend des Studiums verfasstenSemester-, Bachelor- und Master-Arbeit oder anderen Abschlussarbeit (auch der jeweils elektronischenVersion).Die Dozentinnen und Dozenten konnen auch fOr and ere bei ihnen verfasste schriftliche Arbeiten eineEigenstandigkeitserklarung verlangen.

    lch bestatige, die vor liegende Arbeit selbstandig und in eigenen Worten verfasst zu haben. avonausgenommen sind sprachliche und inhaltliche Korrekturvorschlage durch die Betreuer und Betreuerinnender Arbeit.Titel der Arbeit (in Druckschrift) :

    '-'par/n J a Guaalrof 'r { 'r Fo-{lo.yillJ r 1utnQA9ein.,9 Jndoor.s Wh;(e, AvoirfinJ Ob rf qc {e.JVerfasst von (in Druckschrift) :Bei Gruppenarbeiten sind di Namen al/erVerfasserinnen und Verfasser erforderlichName(n):

    ~ ~ b u { ( q

    lch bestatige mil meiner Unterschrift:

    Vorname n):A(exa11Jec

    - lch habe keine im Merkblatt .Zit1er-Knigqe besch riebene Form des Plagiats begangen.- lch habe alle Methoden, Oaten und Arbeitsablaufe wa hrheitsgetreu dokumentiert.- lch habe keine Oaten manipuliert.- lch habe alle Personen erwahnt, welche die Arbeit wesen tli ch unterstUtzt haben.

    lch nehme zur Kenntnis , dass die Arbeit mil elektronischen Hilfsmitteln au f Plagiate uberpruft werden kann .Ort, Datum

    ~ q r i ~ b 3Q.Qf ~ ~ ~ 4 : Unterschrift en)

    Bei Gruppenarbeiten sind die Namen al/er Verfasserinnen undVerfasser erforder/ich Durch die Unterschriften bUrgen siegemeinsam far den gesamten lnhalt dieser schriftlichen Arbeit

    -

  • 8/12/2019 acebulla_BachelorThesis

    8/61

    vi

  • 8/12/2019 acebulla_BachelorThesis

    9/61

    Contents

    List of Figures ix

    1 Introduction 1

    1.1 Motivation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.2 Problems and Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Thesis Outline. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 Related Work 5

    2.1 Tracking Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Collision Avoidance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    3 Mathematical Representation 7

    3.1 Preliminary: Position and Attitude of a Quadrotor . . . . . . . . . . . . . . . . 73.2 Pan/tilt Platform Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    3.3 Distance Sensor Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    4 Controller 15

    4.1 Pan/tilt Platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2 Extension of a Quadrotors Position Controller: Following a Leader While

    Avoiding Obstacles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    5 Hardware and Implementation 21

    5.1 Pixhawk 4 Flight Management Unit (PX4FMU) . . . . . . . . . . . . . . . . . 215.2 Pan/tilt platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    5.3 Distance sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    vii

  • 8/12/2019 acebulla_BachelorThesis

    10/61

    Contents

    6 Experiment Setup and Simulation 27

    6.1 Investigating the Influence Ultrasonic Distance Sensor Might Have on the Mea-surements of Each Other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    6.2 Servo Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.3 Testing the Functionality of the Pan/tilt Platforms Position Controller . . . . . 296.4 Simulating the Quadrotor System. . . . . . . . . . . . . . . . . . . . . . . . . 30

    7 Results and Discussion 337.1 Influence Ultrasonic Distance Sensor Might Have on the Measurements of Each

    Other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2 Functionality of the Pan/tilt Platforms Position Controller . . . . . . . . . . . 377.3 Simulation of the Quadrotor System . . . . . . . . . . . . . . . . . . . . . . . 39

    8 Conclusion and Outlook 478.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    8.2 Future Work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    Bibliography 49

    viii

  • 8/12/2019 acebulla_BachelorThesis

    11/61

    List of Figures

    3.1 Position and attitude of the modelled quadrotor. . . . . . . . . . . . . . . . . . 83.2 Outline of the pan/tilt platform model. . . . . . . . . . . . . . . . . . . . . . . 93.3 Step response of a servo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.4 Field of view of the camera. . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    3.5 Overview over the distance sensor model. . . . . . . . . . . . . . . . . . . . . 12

    4.1 Controlled system of the pan/tilt platform. . . . . . . . . . . . . . . . . . . . . 154.2 Calculation of the anglesC andCfromrCM.. . . . . . . . . . . . . . . . . . 184.3 Display of the vectors involved in calculating the position set pointp for the

    quadrotors position controller. . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    5.1 3D models of the pan/tilt platform. . . . . . . . . . . . . . . . . . . . . . . . . 225.2 Marker detection system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.3 MB1222 ultrasonic distance sensor. . . . . . . . . . . . . . . . . . . . . . . . 26

    6.1 Experiment setup for testing the distance sensors. . . . . . . . . . . . . . . . . 286.2 Modification of a servo.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.3 Experiment setup for testing the functionality of the pan/tilt platforms position

    controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    7.1 Experiment results: Influence ultrasonic distance sensors have on each other at1 m. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    7.3 Experiment results: Influence ultrasonic distance sensors have on each other at70 cm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    7.5 Experiment results: Comparison between three executions of the pan/tilt plat-

    forms position controller.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    ix

  • 8/12/2019 acebulla_BachelorThesis

    12/61

  • 8/12/2019 acebulla_BachelorThesis

    13/61

    1Introduction

    In this chapter we first explain our motivation for choosing this topic. After that we describethe problems faced during this work and the goals derived from them. Finally, an outline of thisthesis is presented.

    1.1 Motivation

    In 2013 more than a third of the Swiss population had a smartphone1 2. Such a device alreadyoffers a range of possibilities for simplifying our daily lives, for example, it can manage ourappointments, guide us through a foreign town and, with the help of specialized applications,even track how much we exercise. Furthermore, almost all smartphones have a camera andthere are attempts to add a picoprojector to them. Nonetheless, these devices are limited bytheir inability to move autonomously and it is interesting to think about the possibilities whichstem from providing them with this ability. Imagine you want to take an image of yourselfor use the projector to give a presentation. As it is today, you either need somebody to holdyour phone or find a suitable place where you can place it. However, we believe it would bemuch more convenient if the phone could assume a favourable position on its own. Anotherpotential use for autonomous motion might be that the phone really guides you through a townas opposed to only displaying the correct way.

    Encouraged by these possibilities, we thought about the requirements which an autonomousmoving smartphone should meet. Clearly, it must be able to keep track of and follow its owner

    1http://en.comparis.ch/telecom/mobile/news/2013/02/smartphone-verbreitung-s chweiz.

    aspxIn

    2http://www.bfs.admin.ch/bfs/portal/de/index/themen/01/01/key.html

    1

    http://en.comparis.ch/telecom/mobile/news/2013/02/smartphone-verbreitung-schweiz.aspxInhttp://en.comparis.ch/telecom/mobile/news/2013/02/smartphone-verbreitung-schweiz.aspxInhttp://www.bfs.admin.ch/bfs/portal/de/index/themen/01/01/key.htmlhttp://www.bfs.admin.ch/bfs/portal/de/index/themen/01/01/key.htmlhttp://en.comparis.ch/telecom/mobile/news/2013/02/smartphone-verbreitung-schweiz.aspxInhttp://en.comparis.ch/telecom/mobile/news/2013/02/smartphone-verbreitung-schweiz.aspxIn
  • 8/12/2019 acebulla_BachelorThesis

    14/61

    1 Introduction

    while avoiding (sometimes moving) obstacles. Furthermore, to fulfil the tasks described above,it would be preferable if it (or at least its camera) could assume different altitudes.

    One possible way to meet these requirements would be to combine a smartphone with a quadro-tor. Quadrotors can not only go to different locations in 3D space, but also easily avoid some of

    the common obstacles ground-based robots have to deal with, like, for example, stairs or tablelegs. In addition, in recent years there has been a lot of research into quadrotors which amongstother things concerned itself with following a leader and collision avoidance.

    We, therefore, decided to work on this thesis topic, because it allowed us to contribute toone of the many projects at ETH Zurich on quadrotors: The PIXHAWK Research Project3.Through preparing the hard- and software, which assists one of their PIXHAWK quadrotorswith following a human being indoors while avoiding collisions, we gained valuable insightsin the inner workings of a quadrotor and went a first step in the direction of an autonomousmoving smartphone.

    1.2 Problems and Goals

    To prepare a quadrotor for following a human being indoors while avoiding obstacles, the au-thors needed to solve the following problems:

    1. Identifying a human being and determining the position relative to herThe quadrotor needs to be able to identify the correct human and then measure its relativeposition with respect to this human.

    This problem was solved by attaching a passive marker to the human in question. Thismarker was then detected through a system already set up by another work based on thePIXHAWK platform [Ngeli 2013]. However, this system used a camera rigidly attachedto the quadrotor.This can lead to different problems:First, if the human is quickly moving sideways the dynamics of the quadrotor might be toslow to follow the marker.Second, if the human moves forwards or backwards the quadrotor needs to lean in thecorresponding direction in order to perform a translative flight and keep its predefinedposition relative to the marker. However, this might move the marker out of the field ofview of the camera.

    2. Registering nearby obstacles and measuring the distance towards themEven while automatically avoiding obstacles such as table legs or stairs, a quadrotor stillneeds to deal with obstacles like human beings, walls or columns. Therefore, the quadro-tor must be able to register nearby objects and measure the distance towards them.

    3. Using the position and distance measurements for following a human being whileavoiding obstacles

    Finally, the quadrotor must use the measured distances towards obstacles and the positionmeasurements provided by the marker detection system to follow a human being while

    3https://pixhawk.ethz.ch/

    2

    https://pixhawk.ethz.ch/https://pixhawk.ethz.ch/
  • 8/12/2019 acebulla_BachelorThesis

    15/61

    1.3 Thesis Outline

    avoiding obstacles.

    From these problems we then derived the following goals and subgoals

    1. Building a pan/tilt platform and implementing a controller for it so that the platform

    follows a marker detected by the marker detection systemWith such a platform the quadrotor can track the marker without an immediate need tomove. In addition, the pan/tilt platform can compensate for tilting or rotational motionsof the quadrotor.Subgoals are:

    Designing a rc servo-based pan/tilt platform.

    Implementing a driver to control the rc servos (for the rest of this thesis we drop therc) of the platform.

    Implementing a position controller for the platform.

    Testing the functionality of this controller.

    2. Using ultrasonic distance sensors to register nearby obstacles and to measure thedistance towards them

    Ultrasonic distance sensors report the distance towards the nearest obstacle inside theircone-shaped detection zone. However, multiple of these sensors used at the same timecan interfere with each other, since one sensor might record the ultrasound emitted byanother sensor4.Therefore, we set the following subgoals:

    Attaching the sensors to the quadrotor.

    Extending an exiting driver such that it can read out multiple distance sensors.

    Exploring how to use these sensors such that they do not interfere with each other.

    3. Extending an existing position controller for following a human being while avoidingobstacles and testing this extension through a simulation

    The last goal was to devise an extension for an existing position controller such that itkeeps a predefined position relative to the marker and deviates from this position only ifthe measured distance towards an obstacle becomes too small. Furthermore, since thiscontroller extension could not be tested during an actual quadrotor flight, its functionalitywas tested through a simulation.

    1.3 Thesis Outline

    Chapter1:Explains the motivation behind this thesis and discusses the problems posed by it and thegoals which were derived from them.

    Chapter2:

    4http://www.maxbotix.com/articles/031.htm

    3

    http://www.maxbotix.com/articles/031.htmhttp://www.maxbotix.com/articles/031.htm
  • 8/12/2019 acebulla_BachelorThesis

    16/61

    1 Introduction

    Gives a short overview over other work related to following an object and avoiding colli-sions with a quadrotor.

    Chapter3:Introduces the mathematical representation of the pan/tilt platform and the distance sen-

    sors. Chapter4:

    Explains the controllers used for simulating a servo and to control the pan/tilt platform.Furthermore, the extension of the quadrotors position controller is described.

    Chapter5:Provides an overview over the used hardware and the software implemented for it.

    Chapter6:Explains how the conducted experiments were set up. Furthermore, the simulation of thequadrotor system and how this simulation was evaluated is described.

    Chapter7:Discusses the results obtained through the experiments. In addition, the outcomes of thesimulation are shown.

    Chapter8:Gives a conclusion and discusses possible future work.

    4

  • 8/12/2019 acebulla_BachelorThesis

    17/61

    2Related Work

    We now present a short overview over other work related to following an object, and avoidingcollisions, with a quadrotor.

    2.1 Tracking Objects

    In [Ngeli 2013] it was demonstrated how quadrotors could fly in a formation without requiringsupport from their environment. Thereby, it was necessary that the quadrotors could measuretheir position relative to each other. So markers were attached to each quadrotor and a markerdetection system, which could track these markers, was set up. This system is the same whichwas used for this thesis. The problem that it might lose track of the marker, when the quadrotorneeded to tilt in order to follow it, was also described in this work.A quadrotor which accompanies a jogger in order to make the exertion experience more engag-ing and to maybe act as a motivational partner was presented in [Graether and Mueller 2012].

    The tracking of the jogger was, thereby, made possible through a visual marker printed on aT-shirt.Another marker-based tracking system was presented in [Wenzel et al. 2012]. Four IR diodes,arranged in a known pattern, were tracked by an IR camera, which reported their xy-positions inits image frame. The authors used a method developed by them to compute the 3D marker posi-tion from this information, which allowed a quadrotor to successfully follow another quadrotor.Similar to this thesis, the authors attached the IR camera to a servo-based pan/tilt platform,which allowed the follower to keep track of the leader even while the leader was not directly infront of it.A marker-less approach for following a human was discussed in [Naseer et al. 2013]. Thereby,

    the idea was to a attach a depth camera to a quadrotor and then use an existing person tracker

    5

  • 8/12/2019 acebulla_BachelorThesis

    18/61

    2 Related Work

    to obtain the position of a persons body parts. However, a problem was that the person trackerrequired a static camera in order to segment a human from the background. The authors pro-vided a solution to this through warping the depth images to a virtual, static camera. It was thenshown that the depth images of the virtual camera were sufficiently stable to be used with theexisting person tracker. The position of the body parts computed by it allowed a quadrotor tofollow a human.A color-based approach to object tracking was shown in [Teuliere et al. 2011], where the to-betracked object was specified through providing an image of it to the quadrotor. The positionof the object was then estimated with a particle filter, which improved the robustness of thesystem against large displacements and occlusions of the object. However, because only the 2Dposition of the object in the image plane of the camera was estimated, the quadrotor had to flyabove the tracked object at a constant altitude.

    2.2 Collision AvoidanceA minimal sensor setup enabling a quadrotor to fly autonomously indoors was described in[Roberts et al. 2007]. Thereby, four perpendicular infrared sensors were used to measure thedistance towards obstacles and the authors successfully let the quadrotor fly along a randompath while it avoided collisions. However, this was done in a controlled environment where theonly obstacles were walls which offered a large surface for detection.Five different ways how a quadrotor could react to obstacles in its flight path were discussedin [Bouabdallah et al. 2007]. Furthermore, a collision avoidance for a hovering quadrotor wasimplemented. Similar to this thesis, four ultrasonic distance sensors were used to measure

    the distance to obstacles. The authors found that the measurements of theses sensors couldbe extremely noisy, because of various reasons such as sound reflecting from the ground whenflying at a low altitude, the propeller downwash influencing the ultrasound waves and, as alreadymentioned, one sensor recording the ultrasound emitted by another sensor. Through adding afilter the sensor noise could be successfully reduced.Other problems of ultrasonic sensors are their low resolution and that an object needs to actuallyreflect the sound emitted by the sensors back to them. Therefore, for a successful detection theangles at which the surface of the object might face a sensor and the materials it could be madeof are limited. The authors of [Gageik et al. 2012] solved some of these problems throughfusing together the measurements of multiple ultrasonic distance sensors. Concerning the lastproblem they suggested to further add distance sensor which use other methods than measuring

    the time-of-flight of ultrasound.A completely different approach to obstacle avoidance was presented in [Grzonka et al. 2008].There the quadrotor was provided with a map of its environment in which it localized itselfthrough the use of a laser range finder attached to it.

    6

  • 8/12/2019 acebulla_BachelorThesis

    19/61

    3Mathematical Representation

    In this chapter we present the mathematical models we used to model the pan/tilt platform andthe distance sensors.

    3.1 Preliminary: Position and Attitude of a Quadrotor

    A detailed discussion of how a quadrotor could be modelled is, for example, given in[Mahony et al. 2012].For this thesis, it was important to model the position and the attitude of a quadrotor relative toits environment.In order to do so the quadrotor was assumed to be a point-mass. Then two right-handed coor-dinate systems were introduced: The world coordinate systemWwith basis{eWx , eWy , eWz}and the quadrotors body coordinate system Bwith basis{eBx, eBy , eBz}, defined with respectto W. The quadrotors centre of mass coincides with the origin of B.

    The position of the quadrotor is, thus, given by (see Figure3.1) the vector p= [px, py, pz] Wpointing to the origin ofB and its attitude by the rotation matrix RBW : B W, whereR S O(3).

    3.2 Pan/tilt Platform Model

    There are different ways to construct a pan/tilt platform, however, they all have in common that,as their name suggests, they allow the camera attached to them to be moved in a pan and tilt

    motion. The setup discussed in this thesis consists of a pan and a tilt lever, named according to

    7

  • 8/12/2019 acebulla_BachelorThesis

    20/61

    3 Mathematical Representation

    Figure 3.1:Position and attitude of the modelled quadrotor.

    their type of movement. The camera is attached to the tilt lever, while the pan lever is mountedon the quadrotor such that it can be rotated by a servo. The two levers are connected through another servo. For the rest of this thesis, we will refer to them as pan and tilt servo, according tothe lever they moved.

    We modelled this setup with the two vectors lpanand ltilt.The orientation of the attached camera was described through the orientation of the camera

    coordinate systemCwith respect to B. We followed the convention1

    thatC is a right-handedcoordinate system, where the z-axis points towards the scenery the camera observes and they-axis points downwards. Its basis is given by{eCx , eCy , eCz}which is defined with respect toB.

    The following assumptions were made about the system setup:The pan lever is directly mounted on top of the centre of mass of the quadrotor, therefore, lpanpoints in the same direction as the z-axis ofB.The camera is attached orthogonal to the tilt lever such that ltilt coincides with the y-axis ofCand points to its origin.

    Let now the position of the shaft of the pan servo be given by , the angle between the projectionof the z-axis ofConto the xy-plane ofB, and the x-axis ofB(2

    < < 2

    ).In addition, let the position of the shaft of the tilt servo be given by , the angle between thez-axis ofBandltilt(

    2

    < < 2

    )(see Figure3.2).Furthermore, letdpananddtiltbe the lengths of the pan and the tilt lever.

    1http://www.hitl.washington.edu/artoolkit/documentation/cs.htm

    8

    http://www.hitl.washington.edu/artoolkit/documentation/cs.htmhttp://www.hitl.washington.edu/artoolkit/documentation/cs.htm
  • 8/12/2019 acebulla_BachelorThesis

    21/61

    3.2 Pan/tilt Platform Model

    Figure 3.2: Outline of the pan/tilt platform model showing the body and camera coordinate system.

    Furthermore, the position of the tilt servos motor shaft and the pan servos motor shaft

    is displayed.

    The two vectorslpanand ltiltare then calculated by:

    lpan =

    0

    0

    dpan

    (3.2.1)

    ltilt =

    dtilt sin cos

    dtilt sin sin

    dtilt cos

    . (3.2.2)

    In addition, the rotation matrix RCB, which transforms camera coordinates to body coordinatescan be computed through:

    eCx =

    cos /2

    sin /2

    0

    (3.2.3)eCy =ltilt/|ltilt| (3.2.4)

    eCz =eCx eCy (3.2.5)

    RCB =eCx, eCy , eCz

    , (3.2.6)

    where equation (3.2.3) is based on the observation that by construction the x-axis ofCis alwaysparallel to the xy-plane ofB. Therefore, this axis can be calculated through rotating the x-axis

    ofBclock-wise according to the angle /2.

    9

  • 8/12/2019 acebulla_BachelorThesis

    22/61

    3 Mathematical Representation

    0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.4580

    60

    40

    20

    0

    20

    40

    60

    80

    time [s]

    positionoftheservosmotorshaft[]

    Step response of a servo

    Figure 3.3:The step response of a servo, averaged over 10 samples.

    3.2.1 Servo Model

    To control the motion of the the pan/tilt platform we used two servos. In general, a servo consistsof a control circuit and an electro motor, which is connected to a gear box and a feedbackpotentiometer2. A position can be provided to it modulated as a PWM signal. The controlcircuit decodes this position and compares it to the position measured by the potentiometer.If these two position differ the control circuit starts to pulse the motor (switches it on/off) ata fixed rate per second, where the speed of the motor can be controlled through the length ofthese pulses. Therefore, the motor moves to the set position and then remains there.

    In order to create a model of a servo, we read out its feedback potentiometer to measure its stepresponse. We did so ten times and then calculated an average (for details see Chapter 6.2), the

    result can be seen in Figure3.3.Based on this average step response, we made the following assumptions:If the motor of the servo is turned on it quickly accelerates with a constant angular accelerationsuntil it reaches a maximum angular velocity max, where the sign ofsandmaxis deter-mined by the direction in which the motor should turn.If the motor is turned off it is decelerated with s.

    2http://www.futaba-rc.com/servos/digitalservos.pdf

    10

    http://www.futaba-rc.com/servos/digitalservos.pdfhttp://www.futaba-rc.com/servos/digitalservos.pdf
  • 8/12/2019 acebulla_BachelorThesis

    23/61

    3.2 Pan/tilt Platform Model

    Let now be the position of the servos motor shaft, then the motion of a servo can be modelledby:

    If the motor is turned on

    =s if ||< |max|

    0 otherwise

    and if the motor is turned off

    =

    s if= 0

    0 otherwise

    3.2.2 Marker Detection Model

    The location of the marker in camera coordinates is measured by the marker detection systemif the marker is inside the field of view (FOV) of the camera.

    Let the position of the marker in camera coordinates be rCM. Furthermore, let and be thehorizontal and the vertical angle of view of the camera (see Figure3.4).One can now calculate the relative position of the quadrotor to the marker in its body coordi-nates:

    rBM= lpan+ ltilt+ R

    CB rCM if

    arctan

    rCMxrCMz

    2

    and

    arctan

    rCMyrCMz

    2

    0 otherwise

    , (3.2.7)

    wherelpanand ltiltare calculated according to (3.2.1) and (3.2.2) andRCBaccording to (3.2.6).

    Figure 3.4:Field of view of the camera.

    11

  • 8/12/2019 acebulla_BachelorThesis

    24/61

    3 Mathematical Representation

    Figure 3.5:Overview over the distance sensor model.

    3.3 Distance Sensor Model

    We used ultrasonic distance sensors to measure the distance towards an object. They emitultrasound and then measure the time it needs to be reflected back to them. Since the soundwaves expand as they travel through the air, these sensors have a cone-shaped detection area,where the opening angles of this cone is predefined by the manufacturer. The distance to thenearest object inside this cone is then measured.

    Hence, we modelled a distance sensor as a cone defined throught,d, h , (see Figure3.5),wheret Wis the apex of the cone (the position of the sensor) in world coordinates, d Wis its normalized axis direction (the direction in which the sensor is oriented),his its height andis half its opening angle. Furthermore, let lmax =

    hcos()

    be the reach of the sensor.The obstacles were modelled as planes, given in Hesse normal form. Therefore, a plane isspecified by its unit normal vector n W, andd its distance to the origin ofW, where d =pTn, with p Wa point on the plane. We defined the unit normal vectors, such that they pointtowards the quadrotors starting point.

    Since the quadrotor should never fly through such a plane, one can now check if the sensordetected an obstacle by testing if there exists a point on the cone, which lies in the negative

    halfspace of the plane. For that, we used the procedure outlined in [Ericson 2004, Section 5.2.4]:First, one must calculateq the point furthermost in the direction ofn, located on the circularendcap of the cone:

    q= t +hd +r m,

    wherer = h tan andm= (n d) d.Second, it must be tested if this point is in the negative halfspace of the plane:

    nT q< d

    If this is true, the modelled distance sensor detected an obstacle.

    In this case, the intersection of a line between t and q, and the plane is found, where the

    12

  • 8/12/2019 acebulla_BachelorThesis

    25/61

    3.3 Distance Sensor Model

    intersection is given as:0 = (t + lO v)

    Tn d,

    withv = qt|qt|

    . After that the distance from the apex tto this intersection is calculated.

    Otherwise, if no object was detected, it is assumed that the sensor reports its maximum reachlmax.

    Therefore, the distance measurement of the sensor is given through:

    lO =

    dtT nvT n

    ifnT q< d

    lmaxotherwise (3.3.1)

    13

  • 8/12/2019 acebulla_BachelorThesis

    26/61

    3 Mathematical Representation

    14

  • 8/12/2019 acebulla_BachelorThesis

    27/61

    4Controller

    In this chapter the controllers used for simulating the pan and the tilt servo and to control thepan/tilt platform are shown. Furthermore, the extension of the quadrotor position controller isdescribed.

    Figure 4.1:The controlled system of the pan/tilt platform, with andthe set points for, and, the

    current position of the pan servos and the tilt servos motor shaft, respectively. x andzare the angular velocities around the z- and the x-axis of the quadrotors body frame. rCMis a vector in camera coordinates pointing from the camera to the marker.

    15

  • 8/12/2019 acebulla_BachelorThesis

    28/61

    4 Controller

    4.1 Pan/tilt Platform

    The controlled system of the pan/tilt platform can be seen in Figure 4.1. Since its behaviourshould be simulated, we devised a controller for the servo model presented in Chapter 3.2.1.

    After that the controller of the pan/tilt platform is shown.

    4.1.1 Bang-bang Servo Motor Controller

    The task of this controller was to simulate the behaviour of a servo, hence, it was not used tocontrol an actual servo motor.

    With this in mind, we simplified the controllers design by omitting the pulsing behaviour men-tioned in Chapter3.2.1. Furthermore, we made the assumption that the controller can observethe rate at which the motor decelerates (s) when it is turned off.

    Therefore, it can compute the time the motor stops its movement if it is turned off

    th =ss

    and the position the servos motor shaft will be at this time

    h= + s ths

    2 t2h,

    wherethe current position of the servos motor shaft andsits current angular velocity.

    Based on this we devised a simple on-off controller, which calculates the input to the motor as:

    u=

    1 if >0 and =h1 if

  • 8/12/2019 acebulla_BachelorThesis

    29/61

    4.2 Extension of a Quadrotors Position Controller: Following a Leader While Avoiding Obstacles

    To achieve this, we used a controller, which calculates a position set point for each of the panand the tilt servo, where it was assumed that the camera is directly attached to them, i.e. |lpan|=|ltilt| = 0. Therefore, changing the position of a motor shaft does only cause a rotation of thecamera coordinate system C, but not any translation of its origin, relative to the quadrotors bodycoordinate system B.

    Let nowC be the angle between the projection ofrCM onto the zy-plane ofCand the z-axisofC(see Figure4.2(a)). Similarly, letC be the angle between the projection ofrCMonto thezx-plane ofCand the z-axis ofC(see Figure4.2(b)):

    C = arctan

    rCMyrCMz

    C = arctan

    rCMxrCMz

    If these two angles are zero then rCMcoincides with the z-axis ofCand the marker is in themidpoint of the cameras FOV as required.

    Hence, the error term for the controller of the tilt servo is defined as

    eC = 0 C

    and the error term for the controller of the pan servo is defined as

    eC = 0 C

    In order to compensate for changes of the quadrotors attitude, its angular velocities around thez- and the x-axis of its body frame,zandx, are integrated and subtracted.

    The set point for the tilt servo is then given as

    = K eC x dt (4.1.2)

    and, analogous, for the pan servo

    = K eC zdt, (4.1.3)

    wheredt the sample time of the respective controller and , the current position of the panservos and the tilt servos motor shaft, respectively. The controller gainsK andK werefound through manual tuning.

    4.2 Extension of a Quadrotors Position Controller:

    Following a Leader While Avoiding Obstacles

    The quadrotor should keep a predefined position relative to the marker and deviate from this

    position if the measured distance towards an obstacle becomes too small. In order to achieve

    17

  • 8/12/2019 acebulla_BachelorThesis

    30/61

    4 Controller

    (a) (b)

    Figure 4.2:(a)C is the angle between the projection ofrCMonto the zy-plane ofCand the z-axis ofC.(b)C is the angle between the projection ofrCMonto the zx-plane ofCand the z-axis ofC.

    this, an extension for an existing quadrotor controller (see[Mellinger and Kumar 2011]) wasdevised.

    Given a set point specified through a positionp Wand a yaw angle , the original controllerfirst computes the errors on position and velocity

    ep =p p (4.2.1)

    ev = p p

    and then the desired force vector:

    Fdes=Kp ep Kv ev+m g eWz+ m p, (4.2.2)

    whereKpandKv are positive definite gain matrices,mthe mass of the quadrotor and eWz theunit vector for the z-axis of the world coordinate system W.After that the desired attitude of the quadrotor Rdesis calculated:

    eBz ,des= Fdes

    |Fdes|

    xdes=

    cos()

    sin()

    0

    eBy ,des= eBz,des xdes|eBz,des xdes|

    eBx,des=eBy,des eBz,des

    Rdes= eBx,des eBy ,des eBz ,des

    18

  • 8/12/2019 acebulla_BachelorThesis

    31/61

    4.2 Extension of a Quadrotors Position Controller: Following a Leader While Avoiding Obstacles

    Figure 4.3:Display of the various vectors involved in calculating the set point position pfor the exten-

    sion of the quadrotors position controller. Only distance sensor 1 has detected an obstacle,

    therefore, all other force vectors Fdisti i {2, ..., N} have length zero.

    FdesandRdesare then used to compute the desired inputs u.Based on this we wanted to use the measured relative position of the marker to set psuch thatit points from the origin ofWto the predefined position relative to the marker.For that letrp Wbe a vector pointing from the marker to the predefined position relative toit. Furthermore, let pM Wbe the position of the marker in world coordinates and rWM =RWB rBMa vector pointing from the quadrotor to the marker, with rBMcalculated according to(3.2.7) (see Figure4.3). It follows:

    p= pM+rp

    =p + rWM+rp

    From this the error term (4.2.1) can now be defined as:

    ep =

    p p= (rWM+rp)ifrWM=0

    0otherwise (4.2.3)

    Furthermore, since the quadrotor should always be "looking" at the marker, we set

    = arctanrWMyrWMx

    19

  • 8/12/2019 acebulla_BachelorThesis

    32/61

  • 8/12/2019 acebulla_BachelorThesis

    33/61

    5Hardware and Implementation

    In this chapter we give an overview over the hardware we used and the software we imple-mented.

    5.1 Pixhawk 4 Flight Management Unit (PX4FMU)

    The PX4FMU was developed by the PIXHAWK Reasearch Project and "is a high-performanceautopilot-on-module suitable for fixed wing, multi rotors, helicopters, cars, boats and any otherrobotic platform that can move."1 It runs the NuttX2 real-time OS and applications can be de-veloped for it in C or C++. The communication between the various applications is realisedthrough an micro object request broker (uORB), which implements the publish-subscribe pat-tern. The PX4FMU offers, among others, four UART and two I2C ports, which we used tointeract with the ultrasonic distance sensors and the pan/tilt camera platform. Furthermore, ithas four different sensors: MPU-6000 (3D ACC / Gyro), L3GD20 (3D Gyro), HMC5883L (3DMag) and MS5611 (barometric pressure), the measurements of which are fused and publishedvia the uORB.

    5.2 Pan/tilt platform

    The requirements for the pan/tilt platform were:

    1http://pixhawk.org/modules/px4fmu

    2http://www.nuttx.org/

    21

    http://pixhawk.org/modules/px4fmuhttp://www.nuttx.org/http://www.nuttx.org/http://pixhawk.org/modules/px4fmu
  • 8/12/2019 acebulla_BachelorThesis

    34/61

    5 Hardware and Implementation

    (a) (b)

    (c)

    Figure 5.1:The 3D models of the pan (a) and the tilt(b)lever. The assembled pan/tilt platform(c).

    22

  • 8/12/2019 acebulla_BachelorThesis

    35/61

    5.2 Pan/tilt platform

    1. compact dimension

    2. low weight

    3. simple adaptation to different servos and cameras

    Based on these we designed a platform consisting of a pan and a tilt lever in Autodesk Inventorand then 3D printed it on a MakerBot3 Replicator 2 (see Figure5.1). This approach allowedus to adjust the weight and stability of the platform through controlling the infill parameter ofthe 3D printer. Furthermore, the shape of the levers could easily be changed to allow the use ofdifferent servos and cameras.

    5.2.1 Servos

    For moving the pan/tilt platform two Graupner4 DES 488 BB MG servos were used, which we

    connected to a 12 channel servo controller IC (SERVO12C) from Hobbytronics 5. This chipis connected to the PX4FMU via I2C and allows to specify the position of a servo through adimensionless scalar value ranging from 0 to 255. In order to refer to this value we invented theunit ABS.

    We implemented a driver for the SERVO12C, which allows an application to change the positionof the pan/tilt camera platform. For that it sends a message via uORB to the driver, whichcontains the desired position of the pan and the tilt servo, where the position can be specifiedeither in ABS or in radian. If the latter is the case, the position is converted to ABS by thedriver.In both cases the driver must check if the positions lie inside the predefined range of positions

    the pan/tilt platform can assume and needs to adjust them if necessary.Finally, the positions are sent to the SERVO12C via the I2C protocol. The chip then convertsthem to PWM signals which are applied to the corresponding servos.

    In order to enable the driver to convert from radians to ABS we wrote a calibration application.This application uses the marker detection system to first place the marker in the midpoint ofthe cameras FOV and then gradually changes the position of the pan servos motor shaft whilemeasuring the corresponding angle. After that it does a linear regression on these data pointsand provides the computed parameters to the driver. This procedure is then repeated for the tiltservo.

    5.2.2 Marker Detection System: PointGrey Firefly Camera and

    ODROID-U2

    The marker detection system we utilized was already set up by another work [ Ngeli 2013]and uses a 0.3 MP PointGrey6 black and white Firefly camera running at 30 Hz to observe the

    3http://www.makerbot.com/4http://www.graupner.de/5http://www.hobbytronics.co.uk/datasheets/slave_servo_datasheet_v02.pdf

    6http://ww2.ptgrey.com/

    23

    http://www.makerbot.com/http://www.graupner.de/http://www.hobbytronics.co.uk/datasheets/slave_servo_datasheet_v02.pdfhttp://ww2.ptgrey.com/http://ww2.ptgrey.com/http://www.hobbytronics.co.uk/datasheets/slave_servo_datasheet_v02.pdfhttp://www.graupner.de/http://www.makerbot.com/
  • 8/12/2019 acebulla_BachelorThesis

    36/61

    5 Hardware and Implementation

    Figure 5.2:The marker detection system consists of a PointGrey black and white Firefly camera and an

    ODROID-U2 single-board computer

    marker. Captured frames from this camera are transmitted via USB to an ODROID-U27 single-board computer, which runs the Ubuntu operating system. If a marker is present, its 3D positionin camera coordinates is then extracted from these frames by the ARToolKitPlus8 library andsent to the PX4FMU over an UART connection. On the PX4FMU a receiver application extractsthe relevant information and publishes it via uORB.

    5.2.3 Implementation of the Position Controller

    The implementation of position controller followed the ideas presented in Chapter4.1.2. Thesample timedt was, thereby, set to 33 ms, since the Firefly camera was running at 30 Hz andwe made the simplifying assumption that the time needed to extract the position of the markerwas constant.

    A problem was that the current position of the servo motor shafts, and , could not be ob-served. We, therefore, estimated them as the last position, which was set. However, to do so ithad to be ensured that and lie inside the predefined range of positions the pan/tilt platformcould assume. If this check would be omitted the position sent to the driver might be adjustedby it, which led to wrong estimates.

    5.3 Distance sensors

    For measuring the distance towards an obstacle, we used the MB1222 I2CXL-MaxSonar-EZ2ultrasonic distance sensor. It is suggested for collision avoidance by its manufacturer and candetect persons up to approximately 2.4 m.9 Furthermore, its measurements can be triggered andread out via I2C.

    7http://www.hardkernel.com8http://studierstube.icg.tugraz.at/handheld_ar/artoolkitplus.php

    9http://www.maxbotix.com/documents/I2CXL-MaxSonar-EZ_Datasheet.pdf

    24

    http://www.hardkernel.com/http://studierstube.icg.tugraz.at/handheld_ar/artoolkitplus.phphttp://www.maxbotix.com/documents/I2CXL-MaxSonar-EZ_Datasheet.pdfhttp://www.maxbotix.com/documents/I2CXL-MaxSonar-EZ_Datasheet.pdfhttp://studierstube.icg.tugraz.at/handheld_ar/artoolkitplus.phphttp://www.hardkernel.com/
  • 8/12/2019 acebulla_BachelorThesis

    37/61

    5.3 Distance sensors

    We extended an already existing driver for this sensor, such that it can trigger the measurementand read out multiple sensors. However, when using multiple sensors they can influence eachother, since one sensor might record the ultrasound emitted by another sensor. A save method toavoid this is to let one sensor complete its measurement before starting the measurement of thenext sensor. Even so, this method rapidly reduces the measurement rate of the sensors, which,if only one sensor is used, can vary between 10 and 40 Hz depending on the environment andthe farthest distance one wants to measure.Thus, we decided to implement a function, which allows to group sensors together, such thatthe measurements of all the sensors in one group must be completed before the measurementsof the next group are started. With this it is possible to group sensors together, which areunlikely to influence each other, for example, sensors which are oriented in opposite directions.Furthermore, we designed and 3D printed funnels, which we attached to the sensors, thereby,physically shielding them from each other. In addition, we also designed brackets, which canbe attached to the quadrotors frame, to mount the sensors on the quadrotor (see Figure5.3).

    25

  • 8/12/2019 acebulla_BachelorThesis

    38/61

    5 Hardware and Implementation

    (a) (b)

    Figure 5.3:The MB1222 I2CXL-MaxSonar-EZ2 ultrasonic distance sensor attached to the quadrotor

    with (a)and without(b)funnel

    26

  • 8/12/2019 acebulla_BachelorThesis

    39/61

  • 8/12/2019 acebulla_BachelorThesis

    40/61

    6 Experiment Setup and Simulation

    Figure 6.1: Experiment setup for testing the influence two ultrasonic distance sensors might have on

    each other, when used at the same time. The body frame was first placed at a distance of

    70 cm and then of 100 cm from each of the two walls.

    28

  • 8/12/2019 acebulla_BachelorThesis

    41/61

    6.2 Servo Modification

    Figure 6.2:Modification of a servo. The white, green and black wires are connected to the control circuit

    of the servo. The blue and the second black wire were added in order to measure the position

    of the servos motor shaft.

    6.2 Servo Modification

    A servo contains a feedback potentiometer, which informs its position controller about the cur-rent position of its motor shaft.We opened the pan and the tilt servo and soldered a wire to each of their potentiometers (see Fig-ure6.2), which we then lead out of the servo casing. The voltage measured on these wires isdirectly related to the position of the servos motor shafts. To convert it to radian we measuredthe corresponding voltage for different positions of the servos motor shaft and then calculated

    a linear regression to obtain the conversion factor.

    6.3 Testing the Functionality of the Pan/tilt Platforms

    Position Controller

    In order to test the functionality of the pan/tilt platforms position controller a marker was placedat different positions relative to the platform and it was then measured how long the controller

    needed to orient the platform, starting from a known initial position, such that in the end themarker was placed in the middle of the PointGrey Firefly cameras FOV.Because the position of the pan and the tilt servo was controlled independently by the controller,we decided to test its functionality for each of the platforms two degrees of freedom separately(see Figure6.3). Therefore, the first two marker positions were chosen such that the pan servosmotor shaft needed to be rotated by24 and by16 degrees, respectively. The next two positionswere then selected such that the tilt servos motor shaft needed to be rotated by16 and by10,respectively.Thereby, we measured the angle of view of the PointGrey Firefly camera to be48 horizontallyand32 vertically.

    Because of the sensitivity of the marker detection system to a changing illumination of the

    29

  • 8/12/2019 acebulla_BachelorThesis

    42/61

    6 Experiment Setup and Simulation

    (a) (b)

    Figure 6.3:Experiment setup for testing the functionality of the pan/tilt platforms position controller.

    The marker was positioned such that the platform either moved in a tilting(a)or a panning(b)motion.

    marker, it was important to control the lighting conditions while these measurements weretaken.

    6.4 Simulating the Quadrotor SystemWe gradually implemented a simulation based on the models and controllers described in Chap-ter3and4. First, the bang-bang position controller for the servo model was implemented andthe model was fitted to our measurements of the servos system responds. This was then usedas a building block for the simulation of the pan/tilt platform.We then extended a simulation of a quadrotor model provided to us according to the ideas de-scribed in Chapter4.2.Finally, this simulation was combined with the simulation of the pan/tiltplatform.

    6.4.1 Simulating and Evaluating the Servo Model

    The servo model should be used in the simulation of the pan/tilt platform. Therefore, werecorded the system response of the two servos ten times with an oscilloscope while they wereincorporated in the pan/tilt platform with the PointGrey Firefly camera attached.These measurements were then put on top of each other and an average curve was calculated.In order to do that the time delays between them were estimated through computing their cross-correlation. For each of the two servos the model parameters sandmaxwere then read outfrom their corresponding averaged system responds.

    For evaluating the model the movements of the servos were recorded while they headed for var-

    30

  • 8/12/2019 acebulla_BachelorThesis

    43/61

    6.4 Simulating the Quadrotor System

    ious positions from a known starting position. For each of the provided positions the recordingwas repeated ten times and an average was calculated as described above. Then the same posi-tions were provided to the model and the differences between the simulation and the averagedmeasurements were calculated.

    6.4.2 Evaluating the Pan/tilt Platform Model

    To evaluate the pan/tilt platform model we used a similar procedure to the one described in theprevious section. We, thereby, calculated an average of the measurements obtained through theexperiment for testing the functionality of the pan/tilt platforms position controller and thencompared it to the simulated movement of the pan/tilt platform model.

    6.4.3 Simulating the Quadrotor Flight

    The pan/tilt camera platform simulation was incorporated in an already existing simulation of aquadrotor, which we extended as described in Chapter4.2.With this simulation we then tested the functionality of the extension for the quadrotors positioncontroller, therefore, if it could follow a marker while avoiding obstacles. In addition, we testedif the problems the marker detection system might has through using a camera rigidly attachedto the quadrotor, namely, the loss of the marker, due to rapid sideways or forwards/backwardsmovement of the marker (compare Chapter1.2), could be mitigated with the pan/tilt platform.

    31

  • 8/12/2019 acebulla_BachelorThesis

    44/61

    6 Experiment Setup and Simulation

    32

  • 8/12/2019 acebulla_BachelorThesis

    45/61

    7Results and Discussion

    We now present and discuss the results of the experiments and the simulations described in theprevious chapter.

    7.1 Influence Ultrasonic Distance Sensor Might Haveon the Measurements of Each Other

    As one can see from Figure7.1both distance sensors reported 1 m when they were used withfunnels. This corresponded to the actual distance at which the quadrotors body frame wasplaced from the corner walls. However, if the sensors were used without the funnels, one sensorrepeatedly reported 38 cm (see Figure7.2).

    After the quadrotors frame was placed at a distance of 70 cm from the corner walls, theexperiment was repeated and we obtained a similar result. With funnels both sensors re-

    ported 70 cm (see Figure7.3), without funnels one sensor started to report distances of around38 cm (see Figure7.4).

    The reason for why only the measurements of one sensor started to oscillate if no funnels wereused, while the measurements of the other one remained relatively stable, was that these sensorsreceived their take measurement command via I2C. Hence, they were not exactly triggered atthe same time, but with a slight delay, which we measured with a logic analyzer to be smallerthan half a millisecond. One can, therefore, see from these measurements, which sensor wastriggered first and which one second, since the first one influenced the measurements of thesecond one.

    It is interesting that the measurement error, which one could see if no funnels were used, was of

    33

  • 8/12/2019 acebulla_BachelorThesis

    46/61

    7 Results and Discussion

    a similar magnitude for both experiments. So far we have no explanation for this phenomena.We tried to exclude other sources of measurement errors through ensuring that the sensors, whenused individually, reported the correct distance every time we attached a funnel or removed onefrom them. Furthermore, to rule out a programming error, we also made an experiment wherewe removed the funnels while not stopping the measurements. The results were similar to theones already discussed.

    From these experiments we concluded that funnels can diminish the influence ultrasonic dis-tance sensor might have on the measurement of each other. However, they were conducted ina static environment and the use of these sensors in a dynamic environment might introduceadditional noise. To deal with this a filter, as suggested by [ Bouabdallah et al. 2007], might berequired.

    34

  • 8/12/2019 acebulla_BachelorThesis

    47/61

    7.1 Influence Ultrasonic Distance Sensor Might Have on the Measurements of Each Other

    0 2 4 6 8 10 12 14 16 18 200

    10

    20

    30

    40

    50

    60

    70

    80

    90

    100

    110

    Time [s]

    M

    easureddistance[cm]

    Sensor 2Sensor 1

    Figure 7.1:1 m with funnels.

    0 2 4 6 8 10 12 14 16 18 200

    10

    20

    30

    40

    50

    60

    70

    80

    90

    100

    110

    Time [s]

    Measureddistance[cm]

    Sensor 2Sensor 1

    Figure 7.2:1 m without funnels.

    35

  • 8/12/2019 acebulla_BachelorThesis

    48/61

    7 Results and Discussion

    0 2 4 6 8 10 12 14 16 18 200

    10

    20

    30

    40

    50

    60

    70

    80

    Time [s]

    M

    easureddistance[cm]

    Sensor 2Sensor 1

    Figure 7.3:70 cm with funnels.

    0 2 4 6 8 10 12 14 16 18 200

    10

    20

    30

    40

    50

    60

    70

    80

    Time [s]

    Measureddistance[cm]

    Sensor 2Sensor 1

    Figure 7.4:70 cm without funnels.

    36

  • 8/12/2019 acebulla_BachelorThesis

    49/61

    7.2 Functionality of the Pan/tilt Platforms Position Controller

    7.2 Functionality of the Pan/tilt Platforms Position

    Controller

    Through the measurements we obtained, it could be verified that the pan/tilt platforms positioncontroller we implemented was indeed able to control the position of the platform such that themarker is placed in the FOV of the marker detection systems camera. Its average precision,thereby, was better than2.

    However, as one can see from the red and the green curve in Figure 7.5the performance ofthe controller could vary noticeably from test to test. Furthermore, it could happen that thecontroller might overshot for one test (see the blue curve in Figure 7.5) and then not producedany overshoots for the following tests.We also observed that the time the controller needed to orient the pan/tilt platform, such thatthe marker is placed in the FOV of the camera, might not get shorter if the distance, by which

    servos motor shaft needed to be moved, was reduced (see Figure7.6).A possible explanation for this variance of the pan/tilt platforms position controllers perfor-mance might be that the marker detection system used the Ubuntu OS, which is not a real-timeOS and so there are no guarantees given for the time needed to compute the position of themarker from a captured frame. Hence, the system has not a constant rate at which it sends themessages, containing the measurements of the markers position, to the PX4FMU, even thoughthe frame rate of the camera was set to 30 Hz. Therefore, it is not possible for the pan/tiltplatforms position controller to synchronize its execution with the image-taking cycle of thecamera or, for that matter, to predict when the camera might take an image of the marker.This could lead to two different problems:

    First, since the positions of the servos motor shafts could not be observed by the controllerand, thus, their last set positions were used as an estimation, it was implicitly assumed thatthe marker detection system took its measurements always after the servos had finished theirmovement. Violating this assumption might be the reason why the controller, from time to time,produced overshoots even though its gain was not changed.The second problem was that the interval between two position messages could vary and sincethe controller was only able to carry out its computation when a position message arrived fromthe marker detection system, the time between two outputs from the controller could also varyto the same extent. This might explain the variance of the time needed to orient the platform.

    37

  • 8/12/2019 acebulla_BachelorThesis

    50/61

    7 Results and Discussion

    0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4

    1

    1

    3

    5

    7

    9

    11

    13

    15

    17

    19

    time [s]

    p

    ositionofthepanservosmotorshaft[]

    test run 1 (target pos.: 16)test run 2 (target pos.: 16)test run 3 (target pos.: 16)

    Figure 7.5:Three measurements of the movement of the pan servos motor shaft, where the position of

    the marker and the controllers gain were left unchanged. The measurements were filtered

    in order to remove measurement noise.

    0 0.05 0.1 0.15 0.2 0.25 0.3 0.35

    2

    0

    2

    4

    6

    8

    10

    12

    14

    16

    18

    20

    22

    24

    26

    28

    30

    time [s]

    posi

    tionofthepanservosmotorshaft[]

    test run 1 (target pos.: 16)

    test run 2 (target pos.: 24)

    Figure 7.6:Two measurements of the motion of the pan servos motor shaft, where the marker was first

    positioned such that the servo needed to rotate its shaft by16 (blue curve) and then by24

    (red curve). The controllers gain remained unchanged. The measurements were filtered in

    order to remove measurement noise.

    38

  • 8/12/2019 acebulla_BachelorThesis

    51/61

    7.3 Simulation of the Quadrotor System

    7.3 Simulation of the Quadrotor System

    We now present the results obtained through simulating the quadrotor system. Furthermore, incase of the servos and the pan/tilt platforms simulation, these results were also compared with

    the measured real-world behaviour.

    7.3.1 Evaluation of the Servo Model

    A comparison between the simulated and the averaged measured movement of the tilt servosmotor shaft by20 is displayed in Figure7.7.One can see a jump at the start of the movement ofthe servos motor shaft and spikes at its end. These phenomena are present in all measurementsof movements of the servos motor shaft, however, we have no explanation for them. Ignoringthese, the biggest difference between the simulation and the averaged measurements in Figure

    7.7has a magnitude of around2.7

    and originates from the overshooting of the servo, whichwas not modelled.

    39

  • 8/12/2019 acebulla_BachelorThesis

    52/61

    7 Results and Discussion

    0 0.02 0.04 0.06 0.08 0.1 0.12 0.14

    0

    2

    4

    6

    8

    10

    12

    14

    16

    18

    20

    22

    24

    time [s]

    position

    ofthetiltservosmotorshaft[]

    Average of 10 measurementsSimulation

    0 0.02 0.04 0.06 0.08 0.1 0.12 0.142

    1

    0

    1

    2

    3

    4

    5

    time [s]Differencebetweentherealandthesimulat

    edposition[]

    (Average of 10 measurements simulation)

    Figure 7.7:Validation of the servo model. The movement of the tilt servos motor shaft was recorded

    while it should move by20. The blue curve is the average of ten measurements while the

    green curve is the simulations output. On the bottom, the difference between these two

    curves is displayed.

    40

  • 8/12/2019 acebulla_BachelorThesis

    53/61

    7.3 Simulation of the Quadrotor System

    7.3.2 Evaluation of the Pan/tilt Platform Model

    As one can see from Figure 7.8the movement of our model was slower than the measuredmovement of the real-world pan/tilt platform.

    A possible explanation for this might be that in our simulation we did not consider the varyingrate at which the platforms position controller receives the position messages from the markerdetection system (see Chapter7.2).

    41

  • 8/12/2019 acebulla_BachelorThesis

    54/61

    7 Results and Discussion

    0 0.2 0.4 0.6 0.8 1 1.22

    0

    2

    46

    8

    10

    12

    14

    16

    18

    20

    22

    24

    26

    28

    time [s]

    position

    ofthepanservosmotorshaft[]

    Average of 10 measurementsSimulation

    0 0.2 0.4 0.6 0.8 1 1.21

    0

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    time [s]Differencebetweentherealandthesimulat

    edposition[]

    (Average of 10 measurements simulation)

    Figure 7.8:Validation of the pan/tilt platform model. The movement of the pan servos motor shaft was

    recorded while it should move24. The blue curve is the average of ten measurements while

    the red curve is the simulations output. On the bottom, the difference between these two

    curves is displayed.

    42

  • 8/12/2019 acebulla_BachelorThesis

    55/61

  • 8/12/2019 acebulla_BachelorThesis

    56/61

    7 Results and Discussion

    (a) (b)

    (c) (d)

    Figure 7.9:The quadrotor follows a marker ((a) and (b)). It then stops before it collides with a wall(symbolized by the green plane) ((c)and(d)).

    44

  • 8/12/2019 acebulla_BachelorThesis

    57/61

    7.3 Simulation of the Quadrotor System

    1 0.5 0 0.5 1 1.5 2 2.5 30

    0.5

    1

    1.5

    2

    2.5

    3

    3.5

    4

    x position [m]

    zposition[m]

    1 0.5 0 0.5 1 1.5 2 2.5 30

    0.5

    1

    1.5

    2

    2.5

    3

    3.5

    4

    x position [m]

    zposition[m]

    (a) (b)

    Figure 7.10: Without the pan/tilt platform the marker is lost (symbolized by the red marker) if the

    quadrotor tilts in order to perform a translative flight(a). The pantilt platform can compen-sate for this movement(b)and the marker remains in the FOV of the camera (symbolizedby the blue marker).

    1 0.5 0 0.5 1 1.5 2 2.5 33

    2

    1

    0

    1

    2

    3

    x position [m]

    yposition[m]

    1 0.5 0 0.5 1 1.5 2 2.5 33

    2

    1

    0

    1

    2

    3

    x position [m]

    yposition[m]

    (a) (b)

    Figure 7.11:Without the pan/tilt platform the marker is lost if it is moved rapidly sideways (a). With theplatform it is possible to still keep track of it(b).

    45

  • 8/12/2019 acebulla_BachelorThesis

    58/61

    7 Results and Discussion

    46

  • 8/12/2019 acebulla_BachelorThesis

    59/61

    8Conclusion and Outlook

    8.1 Conclusion

    In this thesis preparations were made to allow a quadrotor to follow a human being indoorswhile avoiding collisions.

    The tracking of the human was, thereby, realized through attaching a visual marker to her, whichwas tracked by an existing marker detection system. However, this system used a rigidly at-tached camera that might lose the marker if it was moved rapidly sideways or when the quadro-tor needed to tilt for transitional flight in case the marker was moved forwards or backwards.Furthermore, the positions, which the quadrotor could assume relative to the marker, were lim-ited. Therefore, to mitigate these problems, a lightweight servo-based pan/tilt platform wasbuilt and a position controller for it was implemented. Through a simulation and experiments itwas shown that this controller was successfully able to orient the platform such that the marker

    stayed in the middle of the cameras FOV.However, its performance varied noticeable during the experiments and we believe a reason forthis might be that the marker detection system used a non real-time OS to compute the posi-tion of the marker from a captured frame and, therefore, the rate at which it sent the computedpositions to the PX4FMU might vary to a great degree.

    To take measurements of the distances to nearby obstacles, which are needed to avoid colli-sions with them, an existing driver for an ultrasonic distance sensor was extended such that itcould read out multiple sensors. Furthermore, to reduce the influence these sensors had on themeasurements of each other, they could be grouped together such that only sensors, which wereunlikely to influence each other, measured at the same time. In addition to that, funnels were

    designed and it was shown that they can reduce the influence these sensors have on one another.

    47

  • 8/12/2019 acebulla_BachelorThesis

    60/61

    8 Conclusion and Outlook

    Finally, an extension of an existing quadrotor position controller was devised and, through asimulation, its capability to follow a marker while avoiding collisions was shown.

    8.2 Future Work

    We believe that the following extensions would be useful for this system:

    Implementation of a filter for the ultrasonic sensors such as described in[Bouabdallah et al. 2007]:

    While it was shown that the measurements of the sensors could be stabilized through theuse of funnels, this was only tested for a static environment. The use of these sensorsin a dynamic environment might introduce additional noise, which would require theirmeasurements to be filtered in order to be useful for collision avoidance.

    Emergency landing:If the system notices that the distance measurements of the all distance sensors becomesmaller than a defined threshold the quadrotor should perform an emergency landing inorder to avoid damage to nearby objects or the system itself.

    Alternative marker detection system:We believe that one reason for the varying performance of the pan/tilt platforms positioncontroller was the varying rate at which the marker detection system sent the computedmarker positions to the PX4FMU. It would, therefore, be interesting to test the platformwith an alternative marker detection system. We started to implement the one describedby [Wenzel et al. 2012], however, due to time constraints we were not able to finish it.

    Automatically searching for markers with the pan/tilt platform:If the marker is lost the pan/tilt platform could begin to search for it, starting with thedirection in which the marker left the FOV of the camera.

    Finally, we would like to evaluate the functionality of the system during a real quadrotor flight.

    48

  • 8/12/2019 acebulla_BachelorThesis

    61/61