Is it possible to use the Matlab's system function to call ROS commands?

For example, using system('rostopic pub /cmd_vel geometry.msgs.Twist {....} or system('rospack find ipc_bridge).

I'm trying to send some commands to ROS without using something like IPC-Bridge.

PS: I know, however, that I need to use IPC-Bridge to subscribe to topics.


1 Answer 1


This is possible. But it is very sloppy, in my humble opinion. It is useful for one-off commands, but how will you read back output, verify your command was executed, etc.

If you are dead-set against the IPC bridge, you may want to look at using the MATLAB-java interface. ROS also allows you to program in Java using ros-fuerte-client-rosjava (ubuntu), or just rosjava.

  • $\begingroup$ Ok. Then what am I doing wrong? How can I use the system function properly? $\endgroup$
    – Ze Nog
    Nov 25, 2012 at 10:30
  • $\begingroup$ Nothing wrong. Use it if it works for you. Just be sure to set up your bash environment correctly so your commands work. I can see this as helpful for running a matlab script, which then uses rosparam to set the output of the functions for nodes to read. However, I was referring to how difficult it might be to "close the loop" and use matlab to read from ROS ndoes. $\endgroup$ Nov 25, 2012 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.