{"id":540,"date":"2023-03-02T14:04:51","date_gmt":"2023-03-02T19:04:51","guid":{"rendered":"https:\/\/blogs.mathworks.com\/autonomous-systems\/?p=540"},"modified":"2023-03-02T14:04:51","modified_gmt":"2023-03-02T19:04:51","slug":"using-matlab-for-robotics-education","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/autonomous-systems\/2023\/03\/02\/using-matlab-for-robotics-education\/","title":{"rendered":"Using MATLAB for Robotics Education"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><em><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-510\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/03\/corke.jpg\" alt=\"\" width=\"165\" height=\"165\" \/>\u00a0 <\/em><\/p>\n<p><em>This post is from\u00a0<a href=\"https:\/\/petercorke.com\/\">Peter Corke<\/a>, a professor, researcher, teacher and writer about robotics and robotic vision.\u00a0<\/em><\/p>\n<hr \/>\n<p><strong>The journey<\/strong><\/p>\n<p>My journey into robotics began in the mid 1980s and I learnt about homogeneous transformations and kinematics from the books by Paul<a href=\"#_ftn1\" name=\"_ftnref1\"><sup>[1]<\/sup><\/a> and Fu et.al.<a href=\"#_ftn2\" name=\"_ftnref2\"><sup>[2]<\/sup><\/a>. I wrote code to implement those algorithms, initially in C, so that I could control a Puma 560 robot.\u00a0 By the time I started my PhD in 1990 I\u2019d been using MATLAB for a few years and found it to be very productive.\u00a0 I began to reimplement a lot of my C code in MATLAB, starting with primitives for creating transformation matrices, roll-pitch-yaw angle and other conversions, and robot arm forward and inverse kinematics.\u00a0 In 1995 I was very fortunate to attend my first ever International Symposium on Robotics Research (Herrsching, Germany) where I got to meet many of the big names in robotics.\u00a0 I demonstrated my humble toolbox to some folk there, they said nice things, and encouraged me to make it publicly available.\u00a0 Anybody still remember ftp servers?<\/p>\n<p>John Craig chose the toolbox for use in the third edition of his well known textbook<a href=\"#_ftn3\" name=\"_ftnref3\"><sup>[3]<\/sup><\/a>.\u00a0 Over time I added more functionality to the toolbox, e.g., quaternions, mobile robotics, and extended the manual with more and more tutorial content.\u00a0 In the early 2000s I started to think about writing a book that would have a big emphasis on code and code examples.\u00a0 In 2009 I had the opportunity to start writing that book and it was published in 2011.<\/p>\n<p>I began an active collaboration with MathWorks and had some input to the Robotics Toolbox as it was developing.\u00a0 Through that process I go to know Remo Pillat who leads the Robotics Team.\u00a0 In 2015 I spent a few months at MathWorks working with Remo and the robotics team, and met Witek Jachimczyk who headed up the Computer Vision Team.\u00a0 I had a personal agenda to get as much functionality from my own toolbox into the MathWorks products, selfishly so that there\u2019d be less personal toolbox maintenance for me to do.\u00a0 It was during this visit that I had the idea of factoring out all the code related to what I started calling \u201cspatial math\u201d into its own toolbox &#8211; a set of functions and classes that implement all the mathematical objects we use to represent orientation and pose, in 2D and 3D, and all the conversions between those types. \u00a0This includes Lie Group matrices SO(2), SE(2), SO(3), SE(3), quaternions, roll-pitch-yaw angles, angle-vector pairs, exponential coordinates, twists and so on.\u00a0 I quickly refactored my own toolboxes and the Spatial Math Toolbox was born.\u00a0 I gave a lunchtime \u201cbrown bag\u201d seminar at MathWorks and rather audaciously proposed that all this functionality should go into the MATLAB core and be used by all toolboxes, rather than have different partial implementations for each toolbox. Now in 2023 much of this functionality is included in MATLAB, some in the core and some is included with, and common to, selected toolboxes.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-480\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/02\/Robotics_Vision_Control_Book-207x300.png\" alt=\"\" width=\"303\" height=\"439\" \/><\/p>\n<p><strong>Third edition of the book<\/strong><\/p>\n<p>By 2020 it was time to start thinking about a third edition of the book.\u00a0 My toolbox was nearly 30 years old, and it was clear that the MathWorks toolboxes developed over the last decade could do everything that mine could do, plus more. Dropping my toolbox meant reworking every line of code in the book (there are over 2500 lines of MATLAB code), modifying the narrative to suit, plus getting up to speed with all the relevant toolboxes in the MathWorks product line.\u00a0 Or I could invite my friends Witek and Remo to join as authors.\u00a0 We made a pact and started in 2021 and it has been a thoroughly enjoyable and productive collaboration. The book benefited across the board by having new eyes looking at it, and Witek and Remo were able to bring not only their own perspectives, but also those of their customers.\u00a0 The manuscript was prepared using LaTeX and we communicated using GitHub, Teams and email and had a weekly coordination meeting. The book will be out in late in the first quarter of 2023.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Teaching robotics at u<\/strong><strong>niversity<\/strong><\/p>\n<p>My day job is being a professor at the Queensland University of Technology, and I\u2019ve made significant use of MATLAB for teaching over the last decade.\u00a0 I use MATLAB Grader to set problems for students, and test their ability to understand problems by how well they articulate solutions as MATLAB code.\u00a0 Grader provides instant feedback which the students appreciate, and I don\u2019t have to grade their papers which I appreciate.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-486 alignnone\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/02\/robot_harware-300x225.jpg\" alt=\"\" width=\"407\" height=\"305\" \/><\/p>\n<p>I believe it is important to provide students with access to physical robots but this is challenging for large classes.\u00a0 Last year we used MATLAB to share one robot across a class of 180 students \u2014 students emailed their MATLAB code to a server connected to the robot. The task was to type a given 5-letter word on a keyboard and the solution involves coordinate transformations, inverse kinematics and simple path planning.\u00a0 The students did their development using MATLAB and CopelliaSim via a simple API. The same API was used when their code ran on the server, and the server returns a detailed log file as well as a video of the robot doing the task.\u00a0 The server enforces motion limits to prevent damage to the robot and the keyboard.\u00a0 The whole runtime was written in MATLAB and the email handling was done with PowerAutomate.<\/p>\n<p>The robot ran unattended in a locked lab but the students could see it through the glass wall, and a screen showed the identity of the group whose job was currently running. The students found this very engaging and the robot was available 24&#215;7 to run their jobs.\u00a0 It was a delight to see students watching their robot through the glass and high-fiving after their submitted job ran successfully.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-483 alignnone\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/02\/RPi-Robot-300x128.jpg\" alt=\"\" width=\"434\" height=\"185\" \/><\/p>\n<p>In our mobile robot course we use small custom-built<a href=\"#_ftn4\" name=\"_ftnref4\"><sup>[4]<\/sup><\/a> mobile robots that include a Raspberry Pi and camera.\u00a0 An onboard web server allows a user to send motion commands, read odometry or grab an image from the robot\u2019s camera.\u00a0 A RESTful web API allows the robot to be controlled from a students&#8217; laptop and we provided a MATLAB API.\u00a0 The robots have IR LEDs on top, and an overhead RaspberryPi and camera system can provide localization information.\u00a0 We use this setup to teach mobile robot motion control, moving to a point or following a line, path planning, obstacle avoidance, and visual SLAM.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"#_ftnref1\" name=\"_ftn1\"><sup>[1]<\/sup><\/a> R. P. Paul. Robot Manipulators: Mathematics, Programming, and Control. MIT Press, Cambridge, Massachusetts, 1981.<\/p>\n<p><a href=\"#_ftnref2\" name=\"_ftn2\"><sup>[2]<\/sup><\/a> K. S. Fu, R. C. Gonzalez, and C. S. G. Lee. Robotics. Control, Sensing, Vision and Intelligence. McGraw- Hill, 1987.<\/p>\n<p><a href=\"#_ftnref3\" name=\"_ftn3\"><sup>[3]<\/sup><\/a> J. Craig. Introduction to robotics: mechanics and control. Prentice Hall, 2004.<\/p>\n<p><a href=\"#_ftnref4\" name=\"_ftn4\"><sup>[4]<\/sup><\/a> https:\/\/github.com\/qcr\/PenguinPi-robot<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/02\/Robotics_Vision_Control_Book.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>&nbsp;<br \/>\n\u00a0<br \/>\nThis post is from\u00a0Peter Corke, a professor, researcher, teacher and writer about robotics and robotic vision.\u00a0<\/p>\n<p>The journey<br \/>\nMy journey into robotics began in the mid 1980s and I learnt&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/autonomous-systems\/2023\/03\/02\/using-matlab-for-robotics-education\/\">read more >><\/a><\/p>\n","protected":false},"author":191,"featured_media":480,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27],"tags":[30],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/540"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/users\/191"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/comments?post=540"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/540\/revisions"}],"predecessor-version":[{"id":546,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/540\/revisions\/546"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/media\/480"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/media?parent=540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/categories?post=540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/tags?post=540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}