45
1 © 2016 The MathWorks, Inc. Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia

Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

  • Upload
    others

  • View
    22

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

1© 2016 The MathWorks, Inc.

Modelling, Simulation and Control of a Quadcopter

Brad Horton

Engineer

MathWorks Australia

Page 2: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

2

The MATLAB technical computing environment

Page 3: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 4: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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 ?

Page 5: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 6: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

6

Does it fly ?

Page 7: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

7

Not new:

Matrix Algebra,

Euler angles,

Numerical methods,

Solving ODEs,

Curve Fitting,

Control system design,

Simulation

Page 8: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 9: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

9

The quadcopter.

… make it behave

Page 10: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 11: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 12: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

12

Task: Principal moments of Inertia

>> doc eig

>> doc Linear Algebra

Free MATLAB Courseware

Numerical Computing with MATLAB

Applied Numerical Methods with MATLAB

Page 13: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 14: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 15: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

15

Demo

these

tasks

Page 16: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

16

Clarity of the system being studied:

Page 17: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 18: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 19: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 20: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

20

Demo

these

tasks

Page 21: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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.

Page 22: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 23: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

23

Does

it

fly ?

Page 24: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

24

Demo

these

tasks

Page 25: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 26: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

26

Task: Generate C-code from the design

>> doc embedded coder

Free MATLAB Courseware

Page 27: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

27

Demo

these

tasks

Page 28: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

28

Perhaps you actually don’t care about the code !

+ many

more FREE

hardware

support

libraries

http://au.mathworks.com/hardware-support/home.html

Page 29: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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 ?

Page 30: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 31: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

31

APPENDIX:

Teaching Resources.

Page 32: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

32matlabacademy.mathworks.com

Page 33: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

33

Educators:

http://www.mathworks.com.au/academia/educators.html

A dedicated site for supporting teachers.

Page 34: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

34

Educators - Curriculum materials: - part 1

http://www.mathworks.com.au/academia/courseware

Page 35: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 36: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

36

Connecting to Hardware

http://au.mathworks.com/hardware-support/home.html

Page 37: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

37

Connecting to Hardware

Page 38: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 39: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

39

APPENDIX:

User Stories.

Page 40: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 41: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 42: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 43: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

43

APPENDIX:

Graphics.

Page 44: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

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

Page 45: Modelling, Simulation and Control of a Quadcopter...Modelling, Simulation and Control of a Quadcopter Brad Horton Engineer MathWorks Australia 2 The MATLAB technical computing environment

XY

1

2

3

4

3 1

𝐿

XZ

𝜙yaw

𝜃pitch

𝜓roll

4 2

YZ

𝐿

x

O = into your faceX = into the page