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

Publish in python, subscribe in matlab

asked 2022-03-31 10:24:09 -0500

jcutler2018 gravatar image

Hello, my team is trying to implement ROS into our robotics lab, however, we have not been able to do this successfully in the last couple of weeks. We have been able to publish messages via python script and then subscribe to receive that message on a python script. We've also done the same, publishing and subscribing only using matlab. Now, we are trying to publish a message from a python script and then subscribe and receive that message in a matlab/simulink script. We are having issues utilizing ROS over multiple languages and have gotten to the point where we wonder if this is even possible. Any advise is much appreciated.

edit retag flag offensive close merge delete

Comments

1

Python and C++ are the two officially supported languages, while all other languages may be supported by the community. Have you looked into the ROS Toolbox for Matlab? https://jp.mathworks.com/help/ros/ref...

ijnek gravatar image ijnek  ( 2022-04-06 08:13:10 -0500 )edit

If there are both ROS2 and older ROS1 workstations, the ros1_bridge could be used as well

ljaniec gravatar image ljaniec  ( 2022-07-18 07:21:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-18 05:29:47 -0500

bartb gravatar image

It is completely possible. We use matlab & pyton on the same network in our robotics lab. (albeit not with simulink, but I dont see why it should not be possible cross platform - its one of the core points that gives ROS value)

  • Devices should be able to ping eachother over the network
  • Check environment variables
    • ROS_IP = device ip;
    • ROS_MASTER_URI = http://IP_OF_MASTER_DEVICE:/11311 (port number is 11311 by default)
    • printenv ENVIRONMENT_NAME lets you check this in linux terminal (I dont know for other environments to call pyton in though)
    • getenv("ROS_MASTER_URI") lets you check this in matlab
  • do lots of "rostopic lists" to see whether you can see topics, when you can do rostopic echo if the respective device can see contents. This works both in python and in matlab.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-03-31 10:24:09 -0500

Seen: 241 times

Last updated: Jul 18 '22