White Paper

Teaching Robotics with MATLAB and Simulink

Introduction

With the increased demand for skills in robotics and automation applied to different industry sectors, such as health care, agriculture, manufacturing, and more, there is growing global demand for teaching tools that facilitate the accelerated development of robotics and autonomous systems (RAS) competencies for both students in higher education and professionals looking to upskill.

Robotics is a multidisciplinary branch of science and engineering that requires knowledge in physics, electronics, control, mechatronics, programming, and telecommunications, among other disciplines. Likewise, teaching at the university level presents challenges that encompass a series of activities ranging from the preparation and development of classes to the assessment and oversight of technical projects.

Could it be possible to cover the educational needs for such a wide breadth of subjects with a single set of tools?

In this white paper, you can find practical examples, resources, and tools that utilize MATLAB® and Simulink® for teaching robotics. A typical academic curriculum (shown below) is analyzed, from the first courses to the final projects, to demonstrate how pedagogy for relevant knowledge can be accelerated and how a consistent learning platform is used in a variety of teaching activities.

Table containing robotics engineering bachelor’s degree courses classified by discipline and sorted by years.

Typical robotics curriculum where courses are classified by knowledge domains.

Learning Objectives

  • Preparing lessons: Design lessons and get adequate materials for your courses.
  • Conducting lessons: Make lessons more engaging, interactive, and practical.
  • Self-study: Provide resources to your students to motivate independent study.
  • Laboratories: Design virtual laboratories and physical laboratories. 
  • Evaluation: Improve traditional evaluation and save time.
  • Challenges: Challenge your students by linking theory to practice and real-world application.
section

Preparing Lessons

What tools do you have available? Where can you find them?

Tools at Universities

All teaching tools presented in this white paper are based in MATLAB and Simulink. Many universities worldwide have campus-wide access to MATLAB, Simulink, and 125+ toolboxes.

MATLAB

MATLAB is a programming and numeric computing platform used by millions of engineers and scientists to analyze data, develop algorithms, and create models. MATLAB also provides a platform to develop and share interactive technical computing content based on extensive programming libraries.

Simulink

“Model-Based Design with MATLAB and Simulink covers a wide range of software domains needed for the design of advanced robotic systems. It enables the simulation of complex mechatronic systems and controllers, code generation for real-time HIL testing, signal, and image processing, and data analysis and visualization.”​

Berthold Bäuml, director, Autonomous Learning Robot Lab, German Aerospace Centre

Simulink is a block diagram environment used to design systems with multidomain models, simulate before moving to hardware, and deploy without writing code. Model-Based Design with Simulink can be implemented to reduce development time and defects in final products, as well as provide an integration platform for development and education of multidomain systems.

Diagram describing the different phases of Model-Based Design with Simulink. The Model-Based Design system development workflow includes 1. Research, 2. Requirements and Specifications, 3. Design, 4. Implementation, and 5. Test and Verification.

Model-Based Design with Simulink workflow.

Toolboxes for Robotics Applications

A toolbox is a collection of functions built in the MATLAB technical computing environment. Some of the toolboxes that are particularly relevant for robotics applications include:

Teaching Materials

Teach in and out of the classroom using resources tailored to robotics.

Courseware

MATLAB and Simulink project-based learning courseware is published for professors to reuse or adapt the contents to apply them into their courses. Some popular courses include:

MATLAB Robotics Playground app screenshot from courseware. This particular screen has buttons for examples, lessons, documentation, and more.

Robotics Playground MATLAB app.

GitHub Repositories

GitHub® repositories from MathWorks contain a diverse selection of open-source robotics projects and resources for educators using MATLAB and Simulink.

section

Conducting Lessons

How can you make your lessons more engaging, interactive, and practical?

Increasing Motivation

Share with your students how engineers worldwide use MATLAB and Simulink to accelerate the pace of innovation with robotics:

Online Solutions

Use MATLAB Online™ and Simulink Online™ for robotics education so your students can follow lessons containing live examples, such as the example below on path planning, without downloads or installations. This cloud-based resource allows you to always have access to the latest version of the software.

Cloud Storage

MATLAB Drive™ provides a common cloud-based storage location for your MATLAB files. Use it with MATLAB Online to share robotics curriculum materials with your students and make your lessons more interactive.

Diagram describing MathWorks cloud resources and how users can use MATLAB Drive to share and synchronize up to 20 GB of files between different platforms such as MATLAB Online, MATLAB Desktop, and MATLAB Mobile. It also shows how MATLAB Drive Connector can be used to store synchronized files locally.

MATLAB Drive allows you to have your files synchronized with MATLAB for desktop, MATLAB Online, and MATLAB Mobile.

Apps Design

MATLAB App Designer lets you create professional robotics apps without having to be a professional software developer.

Only two steps are needed to create an application like the industrial robotics app below:

  1. Design the user interface without writing code, using drag-and-drop components.
  2. Write the code that determines the behavior of the app.

MATLAB App Designer (left) design view and (right) code view of an industrial robotics workspace app.

Visit the MATLAB App Gallery and File Exchange to find more examples related to robotics.

Interactive Scripts

You can create interactive documents that combine MATLAB code with formatted text, equations, and images in a single environment called the Live Editor. In addition, live scripts store and display output alongside the code that creates it.

Live scripts can be presented as a set of interactive online tutorials and exercises during your lessons. For example, you can use live scripts to teach the basics of using Robot Operating System (ROS and ROS2) to develop and program robots.

Diagram showing how to export ROS live scripts to different file formats such as PDF, Word, HTML, or LaTeX.

Live scripts can be exported to PDF, Word, HTML, and LaTeX formats.

Visit the Live Script Gallery and File Exchange, as well as find more examples related to robotics.

section

Self-Study

How can you facilitate self-study for your students? Which platforms can they use?

Interactive Online Courses

Learn how to program through relevant robotics-related exercises. MATLAB Academy hosts interactive, self-paced, and flexible online courses that provide hands-on exercises with step-by-step instruction and automated feedback.

Onramps

Onramp courses are free, interactive, self-paced, and online. Find robotics-related onramp courses on fields such as image processing, deep learning, and more.

More Courses

Learn about different disciplines in more depth with these complete course offerings:

MATLAB Academy interface showing (left) robotics exercises and (right) a robotics project.

Videos

Find videos and webinars about MATLAB, Simulink, and other products and services related to robotics:

Book Program

The MathWorks Book Program supports authors and publishers around the globe who are developing books based on MATLAB and Simulink. This library includes more than 30 books related to robotics and autonomous systems.

Robotics-related books included in the MathWorks Book Program.

Are you writing or planning a book about using robotics with the MATLAB and Simulink product families? You may be eligible for membership in the MathWorks Book Program.

section

Laboratories

How can you use or design laboratories to enable student participation and active learning?

Virtual Laboratories

You can use MATLAB and Simulink to build interactive virtual labs by incorporating modeling and simulation.

MATLAB: Programming Labs

MATLAB helps students to convert robotics ideas and concepts into autonomous system models that work seamlessly in realistic environments.

Application examples:

Simulink: Design and Simulate

Simulink is for modeling and simulation. You can simulate large-scale robotic system models with reusable components and libraries including specialized, third-party modeling tools:

Simulink simulations with Simulink 3D Animation, Gazebo, and Quanser Virtual Labs.

Simscape: Physical Systems Modelling

Simscape™ enables you to rapidly create models of robotics systems within the Simulink environment. With Simscape, you don’t need to write your code to numerically solve systems of equations. You just need to build the custom blocks, connect them graphically, and let the solver do its work.

(Left) Simscape model and (right) simulation of a delivery quadcopter.

Application examples:

Stateflow: State Machines and Flow Charts

Stateflow® provides a graphical language that includes state transition diagrams, flow charts, state transition tables, and truth tables. You can use Stateflow to describe how MATLAB algorithms and Simulink models react to input signals, events, and time-based conditions.

Stateflow model and simulation of a pick-and-place workflow.

Physical Laboratories

Designing and simulating systems is important for trying new concepts and visualizing how they will work. Moving to hardware is beneficial for students to gain experience with real systems.

Engineers and scientists connect MATLAB and Simulink to physical hardware to design, test, and verify systems that combine hardware components and software algorithms.

MATLAB Mobile: Mobile Devices and Sensors

Students have a small laboratory in their pockets with sensors such as an accelerometer, a speedometer, a magnetometer, an orientation tracker, a GPS, and a camera, among others that are commonly used in robotics and autonomous systems applications for environment perception.

Using mobile devices such as smartphones and tablets, students can:

  • Acquire data from device sensors and analyze the data in MATLAB.
  • Take pictures and record videos for further processing and analysis.

MATLAB Mobile™ is a tool that allows you to learn and teach robotics and autonomous systems–related topics right from your mobile device by connecting to a MATLAB session running on MathWorks Cloud.

 Four MATLAB Mobile screenshots showing sensor settings, examples, live scripts, and MATLAB Drive.

With MATLAB Mobile, use sensors, access examples, and run live scripts and share them with MATLAB Drive.

Hands-on Example (Computer Vision with AI):

Run this script in MATLAB Mobile and use Deep Learning Toolbox™ to take and classify photos on your mobile device.

 >> m=mobiledev; %acquire data from the mobile device sensors

 >> c=camera(m); %connect to the camera

 >> c.Autofocus='on’; %activate autofocus

 >> im=snapshot(c,'manual’); %take a photo

 >> imshow(im) %review your photo

 >> net=alexnet; %use AlexNet pretrained neural network

 >> layer=net.Layers; 

 >> outlayer=layer(end); %last AlexNet layer is where the categories name are

 >> categorias=outlayer.ClassNames; 

 >> img=imresize(im,[227,227]); %resize your image to meet AlexNet requirements

 >> [pred,scores]=classify(net,img); %classify your photo

 >> highscores=scores>0.04; %define the highscores

 >> bar(scores(highscores)) %plot the results

 >> set(gca,'xtick',1:7); 

 >> xticklabels(categorias(highscores)) %add categories name to the plot

Continuation example: Open your PC, explore the Deep Network Designer and the Deep Learning Network Analyzer apps, and adjust this pretrained network to your needs!

Hardware Support

Once you are satisfied with your model, you can automatically generate C, HDL, or PLC code from your algorithms, and run them on manipulators, drones, mobile robots, and any robotics hardware supported by MATLAB and Simulink.

Diagram explaining how you can automatically generate C, HDL, PLC, or GPU code from MATLAB, Simulink, and Stateflow models using automated code generation.

Automated code generation for hardware support.

Low-Cost Hardware

Hands-on learning with MATLAB and Simulink together with the use of low-cost hardware makes it possible for students to participate in motivating projects while building valuable expertise.

Real-Time Applications

You can also use professional hardware to simulate and test control designs and the dynamics of robots and manipulators, autonomous systems, electric motors, and so on.

Speedgoat® machines, which are real-time target computers, are expressly designed to work together with Simulink and Simulink Real-Time™ to create, control, and instrument real-time applications.

section

Evaluation

How can you improve and simplify traditional evaluation?

Automated Evaluation

MATLAB Grader™ lets you scale assessments and automatically grade MATLAB coding assignments in any learning environment or your web browser.

Submit Homework

Use rich text, images, hyperlinks, and LaTeX equations in problem descriptions. Select options for pass/fail and weighted grading.

Two images showing the same laboratory practice on control engineering. The first picture shows a PDF and the second shows one a self-assessed exercise with MATLAB Grader.

Homework in a PDF format and MATLAB Grader homework on control engineering.

Instant Feedback

MATLAB Grader allows you to see details about concepts where students are struggling:

  • Access solution maps showing size, time of arrival, and distance from the solution.
  • View a complete history of students’ attempts to find the correct solution.
  • Review student outcomes (available to instructors and authorized teaching assistants).
  • Deliver real-time, contextual feedback to students on their solutions.

MATLAB Grader feedback graphs.

“The fact that you can get immediate feedback (or confirmation) on a complicated piece of code is really neat, and without it, debugging your own code would really be a mess. It also motivated me to get 100% scores on all the MATLAB assignments.”

Juoost P., Virginia Tech student

LMS Integration

MATLAB Grader can provide outcomes from automated assessments that feed directly to your learning platform, reporting in the tools you use every day for course management.

Screenshot of MATLAB Grader grades integrated in Moodle.

MATLAB Grader scores in Moodle LMS integration.

Problem Collections

MATLAB Grader problem collections such as Electric Circuits and Dynamics are available to verified instructors only. Instructors can request access through Customer Support.

section

Challenges

How can you challenge your students? Where can you find relevant final project topics?

Student Competitions

MathWorks supports competitions related to Robotics, Automotive, and AI.

Demos from (left) the European Rover Challenge, (center) MathWorks Minidrone Competition, and (right) the Formula Student competition.

Research Projects

Find new ideas for RAS research projects, submit your work, and receive official recognition from MathWorks:

section

Summary

Preparing Lessons Conducting Lessons Self-Study
MATLAB and Simulink
Toolboxes
Courseware
MATLAB and Simulink Online
MATLAB Drive
MATLAB App Designer
MATLAB Live Editor
Interactive courses
Other resources
Laboratories Evaluation Challenges
Simscape
Stateflow
MATLAB Mobile
Hardware support
MATLAB Grader Competitions
Innovation projects