Interfacing Matlab-2591 PDF
Interfacing Matlab-2591 PDF
Interfacing Matlab-2591 PDF
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
Abstract: The primary factor restricts of the new control systems developments for air vehicles and the
implementation of new sensors is being physically unable to quick and cost-effective testing. Flight testing is costly
and requires a long preparation process. The aim of this article is improve the simulator infrastructure which
easily implementable to the AscTec Hummingbird Quadrotor that located in the University’s lab and have
interaction with the 3D physical environment. Firstly, quadrotor’s mathematical model has been developed and
this model is implemented on the Matlab/Simulink environment. Afterwards, a bacis PID controller is developed.
The quadrotor’s physical model, the electric motor, the rotor and the IMU model have been modelled on Virtual
Robotics Experimentation Platform (V-REP). Matlab / Simulink controller is synchronized with the V-REP and is
used for the quadrotor’s physical environment tests. The verification of the simulation is planning made by real
experimental flight data of AscTec Hummingbird.
Keywords: Quadrotor, Matlab/Simulink, V-REP, PID Controller.
I. INTRODUCTION
The quadrotor is a Vertical Takeoff and Landing (VTOL) rotorcraft which is propelled by four fixed pitch rotor. Because
of mechanical simplicity and high mobility research related to the quadrotor topic is widespread. The use of area of
quadrotors include military applications such as border patrolling, cartography, cost guards and also civilian applications
such as mapping, search and rescue missions, agricultural applications, power and nuclear plants inspection and etc.
Recent years there is a wide range of academic quadrotor and quadrotor testbed studies have been made. Some of them
are STARMAC II in Stanford University [1], MARK II X4 Flyer in Australia National University [2], swarm of nano
quadrotors in UPenn GRASP Lab [3], quadrotor project in ETH Zurich [4], variable pitch quadrotor in MIT [5], and etc.
On the other hand the commercial products also had widespread in this period, such as Microdrones MD4-200 [6],
Draganfly [7], Silverlit X-UFO [8], Quattrokopter [9], Asctec Hummingbird [10], and etc.
A quadrotor system is a simple structure but design and implementation of control algorithms is not always an easy task.
Especially flight tests in the early stages of algorithm developments can be dangerous and costly. Besides the lack
technical hardware such as indoor localization systems (Vicon cameras), 3D scanner and visual sensors, and etc. is
reducing development ability. Another challenge the studies related to swarm flight algorithms requires number of
quadrotors and technological infrastructure. To avoid these types of problems simulator platform tests and
implementations have been spread. Most of these simulator studies are generally developed in Matlab/Simulink platform.
In his thesis Martines modelled the quadrotor in Matlab/Simulink platform and his model based around Draganfly XPro
quadrotor [11]. The non-linear model of quadrotor was derived using classical mechanics and multiple control techniques
were employed in Matlab/Simulink in Marcelo’s thesis study [12]. Karwoski developed a model in Simulink based on
AscTec Hummingbird quadrotor for design and analysis of variable control systems [13].
The Matlab/Simulink environment is widespread and easy use for developing, debugging and testing complex control
algorithms in a fast prototyping and testing. On the other hand Matlab lacks an easy to use 3D physical simulation engine
for robotic applications. In this point Virtual Robot Experimentation Platform (V-REP) is one of the alternatives for 3D
modeling and physical enviroment interaction testing. In Matteucci’s study simulation enviroment created for an
Page | 42
Research Publish Journals
International Journal of Engineering Research and Reviews ISSN 2348-697X (Online)
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
autonomous all-terrain mobile robot in V-REP and validation experiments presented in which the behavior of the real
system is compared with the corresponding simulations [14]. There are also quadrotor modeling and control algorithm
implementation studies in V-REP. One of them is PyQuadSim study in which quadrotor is controlled via joystick or
gamepad, and the controller is written in Python and modeling is done in V-REP [15]. In Riccardo’s study the interface of
Matlab/Simulink with V-REP usin ROS as communication middleware is done and the default V-REP quadrotor model
control is done using visual servoing [16]. The configuration of V-REP and ROS to work in parallel, using ROS packages
for pose estimation based on vision and for the design and use fuzzy logic control system in quadrotor is done in
Mendez’s study [17]. The experimental flights were set by a real Ar.Drone parrot power edition quadrotor and the results
support virtual flight test data.
In our study goal is to design Matlab/Simulink model and controller for simulation. To test model and implement
controller algorithms and observe 3D physical interaction Matlab/Simulink is interfaced with V-REP directly.
Page | 43
Research Publish Journals
International Journal of Engineering Research and Reviews ISSN 2348-697X (Online)
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
where is motor-prop specified thrust coefficient. The relation between propeller torque and rotational speed is as
follows,
The control of quadrotor model is done by adjusting rotational speed of each propeller. The matrix describing the thrusts
and torques shown below:
[ ] [ ]
[ ]
where is the distance between the propeller rotation axes. Deriving state equations
̇
[ ̇] [ [ ]] where is inertia matrix and, [ ]
̇
The next state allows us to determine the rate of change of the Euler angles in the inertial frame
̇
[ ̇] [ ][ ]
̇
[ ]
̇
[ ̇] [ ]
̇
Page | 44
Research Publish Journals
International Journal of Engineering Research and Reviews ISSN 2348-697X (Online)
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
This state equation determines the velocity of quadrotor in (x,y,z) directions of the inertial frame. Using this mathematical
model PID controller is designed for the altitude and attitude control of the quadrotor. The hovering height and roll, pitch,
and yaw angles have been controlled. The general controller scheme for roll control and hover control can be seen in Fig.
2. The pitch and yaw controller scheme are similar to roll controller.
(a) (b)
Fig.2. (a) Roll angle PID controller, (b) Altitude PID controller
(a) (b)
Fig.3. (a) Thrust change w.r.t. the angular velocity of the rotor using BET in hovering flight, (b) Rotor torque change w.r.t. the
angular velocity of the rotor using BET in hovering flight
The thrust coefficient (N/ ) and rotor torque coefficient (Nm/ ) parameter are found by using the method of
least squares.
Page | 45
Research Publish Journals
International Journal of Engineering Research and Reviews ISSN 2348-697X (Online)
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
⁄
⁄
The estimated parameter then has been implemented in V-REP environment. The CAD model of propeller is imported to
the platform and appropriate LUA embedded script has been written which gets the rotation speed and particle velocity
from main script. Particle velocity is modeled for ground effect studies in future studies. In Fig.4 there is one example
work of propeller at 3900 RPM which attached to the cube and force and torque sensors have been mounted.
Then sensor components like accelerometer, gyroscope and GPS unit has been added to simulation platform. In this point
of study the accelerometer and gyroscope sensors have been used for calculation of roll and pitch angle. The sensors have
their own embedded LUA scripts and using these scripts the data has been in read in main script. To obtain angular
position both accelerometer and gyroscope data can be used. Gyroscope can do this by integrating angular velocity over
time, with accelerometer it can be done by determining the position of gravity vector by using atan2 function. But in
gyroscope due to integration over time, the measurement has tendency to drift and not returning to zero when it comes its
original position, so gyroscope data is reliable in short term. On the other side, accelerometer all the small forces will
disturb our measurement completely, so accelerometer data is reliable in long term. Using complementary filter will solve
this problem because using this filter on the short term data from the gyroscope will be used and on the long term data
from accelerometer will be used. The complementary filter looks like as below:
Using formulation above the appropriate code has been developed in main script to calculate roll and pitch angle.
C. Matlab/Simulink and V-REP Interfacing:
V-REP offers a remote API allowing to control a simulation from an external application. The V-REP remote API is
composed by approximately one hundred functions that can be called from Matlab program. In our application the
command and controller part is developed in Simulink and actuation and physical interaction part created in V-REP. The
general scheme of developed simulator can be seen in Fig.6.
In Simulink part controller gets commands and state data, makes corrections and sends this data to control mixing and
motor speed calculation block. Then speed data is sent to Matlab S-Function where all communication process is done. In
Matlab S-Function the remote API functions and Matlab functions are used. The remote API functions are interacting
with V-REP via socket communication in a way that reduces lag and network load to a great extent. The synchronization
with V-REP is also done in this part of simulation. Matlab S-Function sends motor speeds to V-REP and gets state data
from V-REP and sends these data to controller and correction block in Simulink. In V-REP side main LUA script gets
motor speeds from Matlab/Simulink and sends these values to appropriate propeller model child LUA scripts. Meanwhile,
main LUA script read accelerometer and gyroscope data from child scripts, implement complementary filter to these data
and calculate roll and pitch angles. On the other hand, also gets absolute positions (x,y,z) and absolute velocities (u,v,w)
of quadrotor, combining them with angle (φ,θ,ψ) and angular velocity (p,q,r) data sends them to Matlab/Simulink
application. The visualization of processed data is done both in Matlab/Simulink and V-REP application.
Page | 47
Research Publish Journals
International Journal of Engineering Research and Reviews ISSN 2348-697X (Online)
Vol. 3, Issue 4, pp: (42-49), Month: October - December 2015, Available at: www.researchpublish.com
V. SIMULATION RESULTS
Afterwards interfacing the Matlab/Simulink with V-REP controller tuning and flight simulations trials have done.
Processing with hand tuning and referring to Karwoski’s studies [13] PID gains have been determined and can be seen in
TABLE II.
TABLE II: Tuned PID Gains
After tuning PID gains some flight conditions have been tested in simulator. One of them is to hover from 1 m to 1.5 m
and 10 degree roll angle doublet input in 1 sec. The motor command and state results can be seen in Fig.7 and Fig.8.
REFERENCES
[1] G. Hoffmann, D. G. Rajnarayan, S. L. Waslander, D. Dostal, J. Jang and C. J. Tomlin, “The Stanford testbed of
autonomous rotorcraft for multi agent control(STARMAC),” Digital Avionics Systems Conference, 2004. DASC 04.
The 23rd, Vol.2, 2004.
[2] P. Pounds, R. Mahony and P. Corke, “Modeling and Control of a Quad-Rotor Robot”, Australian National
University, Canberra, Australia, 2006.
[3] University of Pennsylvania, GRASP Lab., http://www.gizmag.com/grasp-nano-quadrotor-robots-swarm/21302/
[4] Flying Machine Arena, Institute for Dynamic Systems and Control, ETH Zurich, http://
http://flyingmachinearena.org/
[5] M. J. Cutler, "Design and Control of an Autonomous Variable-Pitch Quadrotor Helicopter", M.Sc. thesis,
Massachusetts Institute of Technology, Massachusetts, USA, 2012.
[6] Microdrones MD4-200, http://www.microdrones.com/md4-200.html
[7] Draganfly, http://www.draganfly.com/industrial/products.php
[8] Silverlit X-UFO, http://www.silverlit-flyingclub.com/xufo-body.htm
[9] Quattrokopter, http://www.lcc-shop.de
[10] Ascending Technologies, http://www.asctec.de/uav-uas-drohnen-flugsysteme/asctec-hummingbird/
[11] V. M. Martinez, “Modelling of the Flight Dynamics of a Quadrotor Helicopter”, M.Sc. thesis, Cranfield University,
Cranfield, UK, 2007.
[12] M. Oliveira, “Modeling, Identification and Control of a Quadrotor Aircraft”, M.Sc. thesis, Czech Technical
University in Prague, Prague, Czech Republic, 2011.
[13] K. Karwoski, “Quadrocopter Control Design and Flight Operation”, NASA USRP – Internship Final Report.
[14] G. Bardaro, A. Cucci, L. Bascetta and M. Matteucci, “A simulation based architecture for the development of an
autonomous all terrain vehicle”, 4th International Conference, SIMPAR 2014, Bergamo, Italy, October 20-23, 2014.
Vol.8810, pp. 74-85, 2014.
[15] PyQuadSim: An open-source Python Quadcopter Simulator for Linux, Windows, and Mac OS X,
http://home.wlu.edu/~levys/software/pyquadsim/
[16] R. Spica, G. Claudio, F. Spindler and P.R. Giordano, “Interfacing Matlab/Simulink with V-REP for an Easy
Development of Sensor-Based Control Algorithms for Robotic Platforms”, University of Rennes.
[17] M. Mendez, S. Kannan and H. Voobs, “Setting Up a Testbed for UAV Vision Based Control Using V-REP & ROS:
A Case Study on Aerial Visual Inspection”, 2014 International Conference on Unmanned Aircraft Systems (ICUAS)
May 27-30, 2014. Orlando, FL, USA
[18] M. Achtelik, “Nonlinear and Adaptive Control of a Quadcopter”, M.Sc. thesis, Technische Universität München,
München, Germany, 2010.
[19] D. Kaya, “Modeling and Experimental Identification of Quadrotor Aerodynamics”, M.Sc. thesis, Middle East
Technical University, Ankara, Turkey, 2014.
[20] AscTec Hummingbird CAD Model, http://wiki.asctec.de/display/AR/CAD+Models.
Page | 49
Research Publish Journals