Interfacing MATLAB and ROS.pdf

17
1 © 2014 The MathWorks, Inc. In t er facin g MA TL A B and ROS By Yanli ang Zhan g (Ph.D. ) MathWorks Robotics Produ ct and Marketing Manager  [email protected] ICRA 2014, Hong K on g 6/5/2014

Transcript of Interfacing MATLAB and ROS.pdf

Page 1: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 1/17

1

© 2014 The MathWorks, Inc.

Interfacing MATLAB and ROS

By Yanliang Zhang (Ph.D.)

MathWorks Robotics Product and Marketing Manager 

[email protected]

ICRA 2014, Hong Kong

6/5/2014

Page 2: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 2/17

2

MATLAB/Simulink Robotics Portal:

www.mathworks.com/robotics

Page 3: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 3/17

3

Why?

Page 4: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 4/17

4

MATLAB/Simulink Integration with Robots

MATLAB/Simulink

MATLAB Non-

target

 API

Simulink Non-

target

Lib

Simulink Target ROS

 Any Robot

Running

ROS

Page 5: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 5/17

5

What Is ROS?Robot Operating System (ROS) is a BSD-licensed, non real-time,

software framework for robot development, providing operating

system-like functionalities like hardware abstraction, device drivers,

libraries, visualizers, message-passing, package management.

Page 6: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 6/17

6

Existing Packages (Libraries):

Perception

Object Identification

Segmentation

Face recognition

Natural Language

Gesture recognition

Motion tracking

Structure from motion (SFM) Egomotion

Stereo vision

SLAM

Control

Navigation

Motion Planning

Manipulation

Grasping

Motion understanding Mobile robotics

There are many ready-to-use packages (using ROS integration

and messaging conventions) which contain vetted

implementation of common algorithms for each area of robotics:

The possibility of reusing software without having to rewrite it

is one of the main drivers of ROS adoption within both

universities and commercial companies.

Page 7: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 7/17

7

ROS on Robots

Click Here

Page 8: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 8/17

8

ROS on Robots

Click Here

Page 9: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 9/17

9

ROS Used in Teaching

Pretty much any university robotics lab these days is using ROS, and

many are also contributing code back to it, including top institutions.

Some of the top contributors:

• Stanford

• MIT

• CMU

• Brown University• CCNY

• UT Austin/ART

• SIUE

• Rice University

• Penn• TUM

• Uni Freiburg

• WPI

• Cornell

• Georgia Tech

• USC• Columbia University

• Imperial College (London)

• UT Austin

• Washington University St

Louis• University of Maryland

• University of Colorado at

Boulder 

Page 10: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 10/17

10

How?

Page 11: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 11/17

11

Download and Install MATLAB ROS I/O:

www.mathworks.com/ROS

Page 12: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 12/17

12

 A Simple Example (All Codes inside MATLAB)

Create (Connect to) a ROS Master 

>> roscore = rosmatlab.roscore(11311); Create a ROS node

>> node = rosmatlab.node('NODE', roscore.RosMasterUri);

Create a Publisher 

>> publisher = rosmatlab.publisher('TOPIC', 'std_msgs/String', node);

 Add a Subscriber 

>> subscriber = rosmatlab.subscriber('TOPIC', 'std_msgs/String', 1,

node);

Bind Functions to Subscriber 

>> subscriber.setOnNewMessageListeners({@function1, @function2});

Page 13: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 13/17

13

 A Simple Example (All Codes inside MATLAB)

Now you can use different MATLAB toolboxes

Page 14: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 14/17

14

 A Simple Example (All Codes inside MATLAB)

Create a new message for use by the publisher 

>> msg = rosmatlab.message('std_msgs/String', node); Set the data field of the std_msgs/String message

>> msg.setData(sprintf('Message created: %s', datestr(now)));

Publish the Message

>> publisher.publish(msg);

Page 15: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 15/17

15

Demonstration:Ball Tracking on Gazebo and Real

TurtleBot

Page 16: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 16/17

16

Husky + ROS I/O Code Example

Step by Step instructions can be found on Clearpath’s BLOG:

http://www.clearpathrobotics.com/blog/ros-for-matlab/

Or Google: HUSKY MATLAB

Page 17: Interfacing MATLAB and ROS.pdf

8/10/2019 Interfacing MATLAB and ROS.pdf

http://slidepdf.com/reader/full/interfacing-matlab-and-rospdf 17/17

17

Join us at IROS 2014, Chicago, Sept. 14–18, 2014