Ask Your Question
0

Subscribe in MATLAB to a ROS node on another PC

asked 2018-06-26 11:04:20 -0500

Rick gravatar image

Hi,
I have MATLAB running on a Windows-PC and ROS running on a separate Linux-PC. Both are connected in a network. On the Linux-PC I started ROS with the command "roscore". On the MATLAB-PC I used the commands

master = robotics.ros.Core

and

node = robotics.ros.Node('/test')

to create a node with the name /test (after specifying the ROS_MASTER_URI and ROS_IP on ROS and MATLAB). I want to declare this node to a subscriber for the /chatter-topic. Messages are published by a talker (Standard node, described in the ROS tutorial). The problem is, that I can't receive messages on the node /test. To specify the publisher, MATLAB advertises the command

sub = robotics.ros.Subscriber(node,'/chatter','std_msgs/String')"

To use this, I have to insert the node name of the talker, which is not know.
My question is, if there is a possibility to receive messages to this topic. If I start a listener in ROS and a publisher in MATLAB, then the message transfer is possible.

Regards,
Rick

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-26 11:09:02 -0500

gvdhoorn gravatar image

updated 2018-06-26 11:11:14 -0500

Please see #q230737. This is most likely very closely related, if not a duplicate of that question.

sub = robotics.ros.Subscriber(node,'/chatter','std_msgs/String')"

To use this, I have to insert the node name of the talker, which is not know.

this is just one of the possible ways to initialise a Subscriber object. The documentation has a few more that don't require you to know the name of the publisher.

edit flag offensive delete link more

Comments

Thank you for your answer. I also tried rossubscriber without a node, but in the rqt_graph I saw, that the MATLAB node is also the publisher. That's why I tried this way.

Rick gravatar imageRick ( 2018-06-26 13:02:25 -0500 )edit

Now it works. Thanks a lot!

Rick gravatar imageRick ( 2018-06-27 02:43:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-06-26 11:04:20 -0500

Seen: 148 times

Last updated: Jun 26 '18