0
$\begingroup$

Rosanswers logo

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


Originally posted by Rick on ROS Answers with karma: 7 on 2018-06-26

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2018-06-26

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Rick on 2018-06-26:
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.

Comment by Rick on 2018-06-27:
Now it works. Thanks a lot!

$\endgroup$

Your Answer

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