Robotics StackExchange | Archived questions

Publish in python, subscribe in matlab

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.

Asked by jcutler2018 on 2022-03-31 10:24:09 UTC

Comments

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/ros2subscriber.html

Asked by ijnek on 2022-04-06 08:13:10 UTC

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

Asked by ljaniec on 2022-07-18 07:21:48 UTC

Answers

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.

Asked by bartb on 2022-07-18 05:29:47 UTC

Comments