Setting Robotics Toolbox in MATLAB

Here is the link to download a trial or purchase the Robotics Toolbox in MATLAB (https://in.mathworks.com/products/robotics.html). This toolbox is compatible with MATLAB version 2013 onward. If you don't have MATLAB, you can test the chapter's code using a trial version; if you have it, buy or download a trial version of Robotic Toolbox.

Basic ROS functions in MATLAB

After setting up Robotics Toolbox in MATLAB, we can start working on the important functions of MATLAB that are used to interact with a ROS network. Let's look at them with examples.

Initializing a ROS network

Before running a ROS node, we have to run the roscore command, right? The roscore command will start a ROS master, and other ROS nodes can find each other through it. In MATLAB, instead of the roscore command, we can use the rosinit function to start a ROS master.

Initializing a ROS network

Figure 2 : The rosinit function in MATLAB

The rosinit function can start a ROS master and a global node that is connected to the master. Here, we can see that MATLAB itself can act as a ROS master and other nodes can connect to it. We can also connect to a ROS network from MATLAB. We'll cover that in the next section. In such a setup, the ROS master is running on a different system, either on a ROS robot or ROS PC. Let's try some of the ROS commands in MATLAB to list ROS nodes, topics, and all that. The good thing about the MATLAB – ROS interface is that the commands of Robotics Toolbox are similar to the actual ROS bash commands. Let's go through a few commands to list out ROS parameters.

Listing ROS nodes, topics, and messages

The commands to inspect nodes, topics, and messages are similar to ROS bash commands. MATLAB provides a command to start sample ROS nodes that can publish topics. You can just call exampleHelperROSCreateSampleNetwork to start these nodes.

Listing ROS nodes, topics, and messages

Figure 3: ROS-MATLAB commands

You can see that the usage of rosnode and rostopic is the same as with real ROS commands. You can even echo the rostopic using rostopic echo /topic_name. Here is one example, in which we are echoing a topic called /pose:

Listing ROS nodes, topics, and messages

Figure 4: ROS topic echo output

You can get the complete list of ROS commands in MATLAB using the help command.

Here is the syntax for doing so:

>> help robotics.ros

This is the screenshot of the list of commands with MATLAB for ROS:

Listing ROS nodes, topics, and messages

Figure 5: List of ROS-MATLAB commands

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.36.192