ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Not able to run multiple matlab ROS nodes simultaneously

asked 2019-03-05 09:38:41 -0500

Matthias De Ryck gravatar image

Hello all,

I am struggling with ROS on Matlab. It seemed very nice in the beginning that I could use ROS with Matlab but now it seems not to be so flexible as I thought it would be. If ROS is run directly on ubuntu, infinite nodes can run just by opening a terminal and typing rosrun. However, in matlab there is only one terminal. I just want multiple nodes run together. But if I execute one node, then the terminal is not free anymore to run another one. I tried to put them all in 1 script and run this script but this also does not work. I am looking for a way that I can initialize a node in each script and then executing these scripts one by one. Can someone help me with this please?

Regards, Matthias

edit retag flag offensive close merge delete



Would this not be something to ask Mathworks? They are a commercial company with good support channels and engineers.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-05 10:05:15 -0500 )edit

sorry to ask, but why you are not using roslaunch to start multiple nodes ? An additional typical unix/linux option is to fork processes from shell (rosrun pkg prg&).

ChriMo gravatar image ChriMo  ( 2019-03-05 16:35:18 -0500 )edit

Does Matlab support roslaunch? I've not been able to find it in the docs.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-06 01:21:10 -0500 )edit

That's exactly what I'm missing now. A roslaunch function in Matlab, which is not available I think.

Matthias De Ryck gravatar image Matthias De Ryck  ( 2019-03-06 01:33:13 -0500 )edit

A cursory glance at the matlab docs shows that running multiple nodes should be possible. It should be possible to start them and then return to the command console, but that I'm not sure about.

Again, I would recommend using Mathworks support for this. They should know.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-06 01:37:11 -0500 )edit

If you're looking to run existing nodes from MATLAB, you can definitely do this in MATLAB with the ! operator. Following the standard from that previous comment:

!rosrun pkg prg&

But if it's multiple MATLAB scripts, my answer would be the way to go.

sea-bass gravatar image sea-bass  ( 2019-03-15 00:30:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-14 14:33:48 -0500

sea-bass gravatar image

updated 2019-03-14 17:11:50 -0500

That's correct. MATLAB is single-threaded to the user because it has a lot of internal functions that use multithreading.

So you have 2 options:

  • Open up multiple MATLAB instances and run separate scripts/functions. Obviously really heavy on the processing, so opening MATLAB without the desktop and display can help:

matlab -nodesktop -nodisplay -r myNode

  • Generating standalone C++ ROS nodes which requires your code to be placed in a Simulink model (and you also need the Simulink Coder and/or Embedded Coder toolbox). Then you can run these generated nodes from multiple terminals like any other ROS node. See this video for more info:


edit flag offensive delete link more

Question Tools


Asked: 2019-03-05 09:38:41 -0500

Seen: 789 times

Last updated: Mar 14 '19