Hardware in the Loop Simulation for Unmanned
Aerial Vehicles
NATIONAL
AEROSPACE
LABORATORIES
BANGALORE-560 017 INDIA
CSIR-NAL
1
Shikha JainKamali C
Scientist, Flight Mechanics and Control DivisionNational Aerospace Laboratories
Bangalore, India
MATLAB EXPO 2016,4/21/2016
Introduction
Hardware-In-The Loop Simulation (HILS) is a real-time
simulation setup, in which the UAV platform is tested in the
same way as it is in the real experiment.
2
The motivation is to develop a simulation and testing
framework that can be exhaustively used to examine the
performance of designed automatic flight control algorithms.
MATLAB EXPO 2016, 4/21/2016
Unmanned Aerial Vehicle
A mini UAV developed by NAL with surveillance as
the main application.
Table 1: A mini UAV geometric
3
Parameter A (Military Version) B (Police Version)
Length 1.2 m 1.2 m
WingSpan 1.6 m 1.9 m
Weight 2 kg 2.5 kg
Payload <1kg <1kg
Table 1: A mini UAV geometric parameters
UAV designed by NAL
MATLAB EXPO 2016, 4/21/2016
Six DOF model for UAV
In order to develop a 6DOF model of the system, following data is required
Aerodynamic data
Propulsion data
Mass, Centre of gravity, inertia and moment reference point data
4
Geometry data such as wing-span, mean aerodynamic chord and wing
surface area.
The 1:1 UAV model is subjected to the wind tunnel tests to yield the
aerodynamic coefficients.
The coefficients are in the look table form and it captures all nonlinearities.
Rigid body Equations of Motion are implemented in MATLAB/Simulink.
MATLAB EXPO 2016, 4/21/2016
Trimming & Linearization
Trimming
A nonlinear Least Squares (LS) minimization algorithm is
implemented to perform wings level trim.
Trim solution is used to start the simulation.
5
Trim solution is used to start the simulation.
Linearization
Linearization is performed using central difference method.
The linear models are generated at trim point.
The linear models are used for control design.
MATLAB EXPO 2016, 4/21/2016
HILS framework
Host PC
Real Time Target Machine and Interfaces
A HILS framework contains four modules
6
Real Time Target Machine and Interfaces
Autopilot Hardware
Ground Control Station
MATLAB EXPO 2016, 4/21/2016
HOST PC
The UAV aerodynamic model and engine model along with
equations of motions, sensor models, hardware interface blocks and
control algorithms are developed in Simulink platform.
Open loop, model in the loop, software in the loop and processor in
7
Open loop, model in the loop, software in the loop and processor in
the loop simulation models are tested on Host PC.
For HILS
compiles the 6 DOF model and communicates it to the target machine
which is a Matlab real time kernel.
Runs the model in target machine.
Communicates with target machine through Ethernet.MATLAB EXPO 2016, 4/21/2016
6DOF Simulation model of UAVNATIONAL
AEROSPACE
LABORATORIES
BANGALORE-560 017 INDIA
CSIR-NAL
MATLAB EXPO 2016, 4/21/2016
8
Control Algorithm
Using embedded real-time
target, autocode is
generated for the control
strategy and is burnt in the
micro controller.
MATLAB EXPO 2016, 4/21/2016
9
Real Time Target Machine and Interfaces
I7 Single Board Computer
Boots MATLAB real time kernel from CD.
Real time target machine is a real time operating system whichmeets the timing constraints required for real time applications.
10
Acts as a root complex and Communicates with Spartan 6
FPGA through PCIe bus.
Spartan 6 FPGA
SPI, I2C, UART, USB, CAN, GPIO, PWMIO, ADC and DAC
IP run in Spartan 6 FPGA
The IP’s are developed in VHDL programming language
All hardware signals are isolated from Autopilot using
Digital IsolatorsMATLAB EXPO 2016, 4/21/2016
Autopilot Hardware
Focus on low weight with
reconfiguration capability.
Hardware is realized using
programmable systems on chip
11
programmable systems on chip
(PSoC).
On board 3 axis accelerometers, 3
axis gyroscope, 3 axis
magnetometer, and, a static
pressure and temperature sensor.NAL Autopilot Version 3 (APV3)
MATLAB EXPO 2016, 4/21/2016
Ground Control station
Open source mission
planner software is used
12
Used for direct
observation and
monitoring purposes.
MATLAB EXPO 2016, 4/21/2016
HILS Architecture
Classified based on the level of fidelity
Low fidelity
13
Medium fidelity
High fidelity
Presentation covers the development of low
and medium fidelity HILS architecture
MATLAB EXPO 2016, 4/21/2016
Low fidelity HILS
Communication between target machine and autopilot hardware is
via serial communication.
Sensor data (IMU and GPS)are generated at regular interval.
14
PWM signal are normalized and mapped to the flight control
parameters.
Low fidelity HILS architecture
Real Time
Target Machine
Autopilot board
Serial
MATLAB EXPO 2016, 4/21/2016
Detail connection diagram15
MATLAB EXPO 2016, 4/21/2016
Communication protocol
Real Time
Target Machine
Autopilot board
Protocol
16
Data Length
PayloadCheck Sum
1 byte 1 byte Data Length 1 byte 1 byte
Total Count= Data length(byte)+ 4 bytes
Check Sum Range
Protocol
Flow of code in the Target Machine
Receive Data Packet Scaling of Data
Decode the Packet
17
Mapping of Data to Flight Model
Formation of packet
Decode the Packet
Normalization of Data
Send packet through UART/USB
6 DOF Simulation
Model
MATLAB EXPO 2016, 4/21/2016
Flow of code in an autopilot board
Generate Control
Execute Control Subroutine
Mapping of sensor data to
the control subroutine
18
Receive Data Packet via
UART
Generate Control Deflections (PWM)
Decode & scaling of Data Formation of
Packet
Send Packet to Target Machine through UART
Send packet to Ground Control
Station for Visualization
MATLAB EXPO 2016, 4/21/2016
Snapshot
Target Machine
19
Host PC Visualization PC
NAL Autopliot
MATLAB EXPO 2016, 4/21/2016
4/21/2016MATLAB EXPO 2016,
20
Medium fidelity
Sensors data is sent over
the interface supported by
the autopilot hardware
such as I2C, UART.
Real Time
Target Machine
Autopilot board
Sensor data
21
such as I2C, UART.
Feedback to the flight
model in target machine is
obtained from the actuator
(servos).
Medium fidelity HILS architecture
MATLAB EXPO 2016, 4/21/2016
Actuator(Servos)
Block Diagram22
Flow of code in the Target Machine
Receiving Analog
Voltages
Scaling of sensor data
Framing of Aircraft
23
Mapping Voltage values to the Flight
control parameters
Framing of packet
Sending data:IMU through I2C interface
GPS through UART interface
Aircraft6DOF
Simulation Model
MATLAB EXPO 2016, 4/21/2016
Flow of code in an autopilot board
Receive Data Packet
via (I2C & UART)
Packet Decode &
scaling of Data
Mapping of sensor data to
the control subroutine
24
Generate Control
Deflections (PWM)
Drive Servo Motors
Execute Control
Subroutine
Encode packet for visualization in Ground Control
Station
MATLAB EXPO 2016, 4/21/2016
Snapshot
Visualization PC
Target Machine
25
Host PCVisualization PC
NAL Autopliot
Servos
MATLAB EXPO 2016, 4/21/2016
4/21/2016MATLAB EXPO 2016,
26
Results
UAV performing way point navigation
27
MATLAB EXPO 2016, 4/21/2016
Conclusions
Design and development of a low and medium
fidelity HILS for a mini UAV is presented.
The development is based on Model Based Design.
28
The development is based on Model Based Design.
These architectures are used to verify the working
of control code and sensor fusion algorithms on
the autopilot board.
MATLAB EXPO 2016, 4/21/2016
Acknowledgements
Our sincere thanks to
Director, NAL
Dr. G. K Singh and his team
Dr. C M Ananda and his team
29
Dr. C M Ananda and his team
Dr Jatinder Singh, Head FMCD
Dr Abhay A Pashilkar, Group head, Flight Simulation
MATLAB EXPO 2016, 4/21/2016
References
1. C Kamali, Alexander Kale,” Development of Six DOF model for Class-I MAV”, September, 2013.
2. “Preliminary test results on 1:1 scale UAV models” Report No. HAL/ARDC/UAV/WNT/001, July 2012.
3. Alexander Kale, Shikha Jain, C Kamali,” Simulation, Modal Analysis and Parameter Estimation of Class-I MAV”, October
2013.
4. Shikha Jain, C Kamali,” Experimental Validation of NAL’s Class 1 MAV Simulation Model Using Flight Data”, December
30
2013.
5. Software In the Loop Simulation (SILS) for NAL’s Class 1/Similar class MAV.
6. Arya, Hemendra,(2010), Hardware-In-Loop Simulator for Mini Aerial Vehicle, Centre for Aerospace Systems Design and
Engineering, Department of Aerospace Engineering, IIT Bombay, India.
7. Dongwon Jung and Panagiotis Tsiotras (2007), Modelling and Hardware-in-the-Loop Simulation for a Small Unmanned
Aerial Vehicle, AIAA Infotech at Aerospace, Rohnert Park, CA.
8. A. Gholkar, A. Isaacs, and H. Arya, (2004), .Hardware-In-Loop Simulator for Mini Aerial Vehicle, Sixth RealTime Linux
Workshop, Nanyang Technological University (NTU), Singapore.
9. Viswanathan S, Guruganesh R, “Design of Autopilot for Class I MAV using Classical Control”, November 2013.
MATLAB EXPO 2016, 4/21/2016
Thank You31
MATLAB EXPO 2016, 4/21/2016