1© 2016 The MathWorks, Inc.
Modelling, Simulation and Control of a Quadcopter
Brad Horton
Engineer
MathWorks Australia
3
ChallengeDevelop a real-time system to minimize HVAC energy costs
in large-scale commercial buildings via proactive, predictive
optimization
SolutionUse MATLAB to analyze and visualize big data sets,
implement advanced optimization algorithms, and run the
algorithms in a production cloud environment
Results Gigabytes of data analyzed and visualized
Algorithm development speed increased tenfold
Best algorithmic approaches quickly identified
BuildingIQ Develops Proactive Algorithms for HVAC
Energy Optimization in Large-Scale Buildings
Large-scale commercial buildings
can reduce energy costs by 10–25%
with BuildingIQ’s energy
optimization system.
Link to user story
“MATLAB has helped accelerate
our R&D and deployment with its
robust numerical algorithms,
extensive visualization and
analytics tools, reliable
optimization routines, support for
object-oriented programming, and
ability to run in the cloud with our
production Java applications.”
Borislav Savkovic
BuildingIQ
4
Is the MATLAB technical computing environment relevant ?
RELEVANCE: the degree to which something is related or
useful to what is happening or being talked about
What makes it compelling ?**REF: http://dictionary.cambridge.org/dictionary/english/relevance
T2
Will it follow your students through their degree from beginning to end ?
5
Communication
… Knowledge Sharing
Clarity
… help me
understand
it.
Continuity
… can it help
now ?
now + 5 ?
Continuity:
something that is the
same or similar in
two or more things
and provides a
connection between
them
Is the MATLAB technical computing environment relevant ?
Communication:
a process by which
information is exchanged
between individuals
through a common system
of symbols, signs, or
behavior
Clarity:
the quality of
being expressed,
remembered,
understood, etc.,
in a very exact way
**REF: http://www.merriam-webster.com/dictionary
7
Not new:
Matrix Algebra,
Euler angles,
Numerical methods,
Solving ODEs,
Curve Fitting,
Control system design,
Simulation
8
A MATLAB Technical computing environment offers:
Communication
… Knowledge Sharing
Clarity Continuity
… can it help
now ?
now + 5 ?
T3
… help me
understand it.
Usage choices
– APPS
– Scripts
– Functions
– OOP
Plotting
DOC
Application libraries
– stats
– control
– Signal, image
– +++
Interface with hardware
Deploy to hardware– Microcontrollers
– DSps
– Arduino, Rasp Pi, +++
Simulink
Live Editor
Our FREE curriculum
resources
Our FREE training
resources
– MATLAB OnRamp
– Tutorial videos
MATLAB
Courseware
10
What we’ll do:
Model
the
vehicle
Calibrate
the
electric
motors
Control
the
vehicle
Get
from
Simulation
To
Hardware
SUBPROBLEM
T2
TASKS (application)
CONCEPTS (foundation)
HIGHLIGHTS
MATLAB Courseware
11
The model.
Model
the
vehicle
Matrix Algebra
Numerical Methods
ODEs
CONCEPTS
(foundation)
TASKS
(application)
SUBPROBLEM
HIGHLIGHTS
MATLAB Courseware
Principal moments of inertia
Passive rotation sequences
Euler rates from body rates
Solving ODEs
12
Task: Principal moments of Inertia
>> doc eig
>> doc Linear Algebra
Free MATLAB Courseware
Numerical Computing with MATLAB
Applied Numerical Methods with MATLAB
13
Task: Passive Rotations and Euler rates
>> doc live scripts
>> doc matlabFunction
>> doc matlabFunctionBlock
Free MATLAB Courseware
Introduction to MATLAB
Aeronautical Systems-Guidance and Control
14
Task: Solving ODEs
>> doc ODE solver
>> doc ode45
>> doc table
>> doc readtable
Free MATLAB Courseware
Numerical Computing with MATLAB
Applied Numerical Methods with MATLAB
Differential Equations and Linear Algebra
17
Characterize
and
Calibrate.
CONCEPTS
(foundation)
TASKS
(application)
SUBPROBLEMCalibrate
the
electric
motors
Numerical Methods
Curve Fitting
Nonlinear optimization
Thrust vs motor speed
Do I trust my motor model ?
HIGHLIGHTS
MATLAB Courseware
18
Task: calibrate Thrust,Torque with speed
>> doc curve fitting
>> doc cvfit
>> doc linear equations
>> doc readtable
Free MATLAB Courseware
Numerical Computing with MATLAB
Engineering Models I
Engineering Models II
Introduction to Engineering Analysis
19
Task: calibrate electric motor parameters
>> dc motor estimation
>> doc spetool
>> doc sdo.optimize
Free MATLAB Courseware
Numerical Computing with MATLAB
System Dynamics with Simscape
Teaching System Dynamics with Arduino,
MATLAB, and Simulink
21
Control
the
vehicle
Linearization
Classic control needs
a linear model
Design a control system
CONCEPTS
(foundation)
TASKS
(application)
SUBPROBLEM
T1
HIGHLIGHTS
MATLAB Courseware
Control.
22
Task: Linearise and Control design
>> doc findop
>> doc linearize
>> doc pidTuner
>> doc controlSystemDesigner
Free MATLAB Courseware
Control Tutorials for MATLAB and Simulink
Aeronautical Systems-Guidance and Control
Embedded Control and Mechatronics
25
CONCEPTS
(foundation)
TASKS
(application)
Get
from
Simulation
To
Hardware
Implement control design
onto embedded hardware
Getting a MATLAB
design into an
embedded device
SUBPROBLEM
HIGHLIGHTS
One step
towards
hardware
28
Perhaps you actually don’t care about the code !
+ many
more FREE
hardware
support
libraries
http://au.mathworks.com/hardware-support/home.html
29
*Clarity:
the quality of being
expressed, remembered,
understood, etc., in a
very exact way
*Communication:
a process by which
information is exchanged
between individuals
through a common system
of symbols, signs, or
behavior
*Continuity:
something that is the
same or similar in
two or more things
and provides a
connection between
them
Is the MATLAB technical computing environment relevant ?
30
A MATLAB Technical computing environment offers:
Communication
… Knowledge Sharing
Clarity Continuity
… can it help
now ?
now + 5 ?
… help me
understand it.
Usage choices
– APPS
– Scripts
– Functions
– OOP
Plotting
DOC
Application libraries
– stats
– control
– Signal, image
– +++
Interface with hardware
Deploy to hardware– Microcontrollers
– DSps
– Arduino, Rasp Pi, +++
Simulink
Live Editor
Our FREE curriculum
resources
Our FREE training
resources
– MATLAB OnRamp
– Tutorial videos
MATLAB
Courseware
33
Educators:
http://www.mathworks.com.au/academia/educators.html
A dedicated site for supporting teachers.
34
Educators - Curriculum materials: - part 1
http://www.mathworks.com.au/academia/courseware
35
Educators – Classroom resources:
http://au.mathworks.com/academia/classroom-resources/search.html
Search the
entire resource
library
Find a broad
range of
resources:
– A few scripts,
functions
– Libraries,
toolboxes
36
Connecting to Hardware
http://au.mathworks.com/hardware-support/home.html
38
Hardware for Project Based Learning:
Get hands on WORKSHOP
resources
– Workshop tutorial manual
– examples
http://au.mathworks.com/programs/resource-
portals/project-based-learning/index.html
40
University of Potsdam Earth Scientists Study
Ancient Climates Using Sophisticated Time
Series and Spatial Analysis Methods
ChallengeTeach earth sciences students advanced data analysis
methods as they study changes to Earth’s environment
over millions of years
SolutionUse MathWorks tools to perform time series analysis,
process satellite and microscope images, and gain
insight into climate change
Results Transferable skills acquired
Sophisticated analysis methods quickly learned
Researcher collaboration fostered
“You can apply advanced
mathematical methods very easily
with MATLAB. I frequently show
students who are struggling with a
problem in a spreadsheet how
easily it can be solved in MATLAB,
which can be used for many
different types of data analysis.”
Dr. Martin Trauth
University of Potsdam
Link to user story
Dr. Trauth on location in Kenya.
Earth and Ocean Sciences
41
University of Melbourne Supports
New Engineering Curriculum with
MathWorks Tools
ChallengeEnable students to solve complex problems
across a wide range of disciplines and to support
faculty research
SolutionGive undergraduate and graduate students and
faculty campus-wide access to MathWorks tools
Results Course planning simplified
Vital skills acquired
Complex concepts visualized, enabling
exploration and problem solving
“Students pick up MATLAB much faster
than a low-level language such as C.
They can try things out in MATLAB and
get immediate, visual feedback. When
we couple MATLAB with hands-on
activities, we have the full progression
from theory to numerical computation
to lab experiments.”
Dr. Jamie Evans
University of Melbourne
Link to user story
Engineering students working in a design studio.
Engineering
42
Penn State GATE Program
ChallengeTeach students how to design and develop products
within today’s compressed development cycles
SolutionUse MathWorks tools to teach the full development
process, including concepts such as hardware-in-the-loop
for testing and rapid prototyping
Results Utilize a single platform for design, verification,
hardware-in-the-loop testing, and final implementation
Speed up student learning by introducing more
concepts in the classroom and providing hands-on
learning opportunities
Equip students to “hit the ground running” when
entering industry
“I was recruited to work at General
Motors before I even finished graduate
school. And I think that one of the things
that made me attractive was my hands-on
experience with tools like MATLAB and
Simulink…”
Melanie Fox, PhD Candidate
Diesel Combustion Engineer, GM
“One of the reasons we chose
MathWorks products to standardize our
course on was because we see that’s
actually what industry is using.”
Joel Anstrom, PhD, Director
DOE GATE Program
Penn State
Link to user story and video
1
2
3
4
𝜔𝑚1
𝜔𝑚2
𝜔𝑚3
𝜔𝑚4
YX
Motor speeds
1
2
3
4
𝜏𝑚1
𝜏𝑚2
𝜏𝑚3
𝜏𝑚4
YX
REACTION torques
Applied to airframe
O = into your faceX = into the page