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

Not able to run multiple matlab ROS nodes simultaneously

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

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

Comments

2

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 -0600 )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 -0600 )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 -0600 )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 -0600 )edit
1

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 -0600 )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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

sea-bass gravatar image

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

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: https://www.mathworks.com/help/matlab...

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: https://www.mathworks.com/videos/matl...

Sebastian

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 910 times

Last updated: Mar 14 '19