O'Reilly logo

Mastering ROS for Robotics Programming - Second Edition by Jonathan Cacace, Lentin Joseph

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Starting with ROS topics and MATLAB callback functions

In this section, we will discuss how to publish and subscribe ROS messages using MATLAB scripts. The first script that we analyze defines a typical template to develop the control loop of our robot. Firstly, we will subscribe to an input topic, and, successively, we will republish its value on an output topic for a certain amount of time. The complete source code is contained in the talker.m, in the code provided with the book, or  you can clone the following Git repository:

$ git clone https://github.com/jocacace/ros_matlab_test

Let's see the content of the talker.m script:

ros_master_ip = 'http://192.168.1.5:11311'; matlab_ip = '192.168.1.13'; rosinit(ros_master_ip, 'NodeHost', matlab_ip); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required