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

It is possible to create a different Publisher and Listener in the same NodeHandle ?

asked 2020-08-04 03:13:49 -0500

Pombor gravatar image

updated 2022-01-22 16:10:42 -0500

Evgeny gravatar image

Hi,

My question is in the title.

Actually, I have this :

subscriber = select.subscribe("select", 1, &Node::selectCallback, this);
publisher = select.advertise<std_msgs::String>("select", 1);

I would like the program receive vectors but publish only one string. It works for the vector but not for the string, it seems impossible to handle two differents information.

[ERROR] [1596527879.014894165]: Client [/select] wants topic /select to have datatype/md5sum [msg/select/6b204e294ba3cb6f15defcb9cd6b3d7c], but our version has [std_msgs/String/992ce8a1687cec8c8bd883ec73ca41d1]. Dropping connection.

Do I have to create a new NodeHandle or can I use only one topic for this ?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-08-04 20:14:29 -0500

Thomas D gravatar image

You can use a single node handle, but you must have different topic names for the publisher and subscriber. Think of you subscriber as the input to your node, and the publisher as the output of your node. Those two things must be different, otherwise you create a circular graph (first problem) with identical topic names that have different types (second problem).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-08-04 03:11:30 -0500

Seen: 61 times

Last updated: Aug 04 '20