STOP publishing a ros topic

asked 2021-05-30 11:42:59 -0500

shoriya gravatar image

updated 2021-05-30 16:26:26 -0500

jayess gravatar image

Hello,

I would like to stop publishing a ROS topic under certain condition.

I am using ROS melodic, Ubuntu 18.04.

I have multiple nodes subscribed to the topic /joint_state from the joint_state_publisher node. Now , I have another node which is publish a topic /object_detected. I want to stop /joint_state topic from publishing when the /object_detected topic publishes some value.

Is there any way I can do this ?

edit retag flag offensive close merge delete

Comments

Put the publishing of the topic under a conditional. Can't really say much more without seeing your code

jayess gravatar image jayess  ( 2021-05-30 16:27:06 -0500 )edit

I have to stop the publishing of the topic joint_states from the joint_state_publisher node

shoriya gravatar image shoriya  ( 2021-05-30 16:30:25 -0500 )edit

It sounds like you want to multiplex then. I haven't used this package so I can't vouch for it, but it may be worth taking a look at it

jayess gravatar image jayess  ( 2021-05-30 16:52:40 -0500 )edit

Yes, I did give it a shot.. So now I have 4 node which are subscribed to /joint_state topic from the joint_state_publisher node.
And i have defined a mux with output topic sel_jointstate and I would like the 4 nodes to subsribe to this output (sel_jointstate) and not to /joint_state directly. Any idea how this can be done.

And the mux can select between blank_msg and joint_states.

Launch file : <node pkg="topic_tools" type="mux" name="jointstate_mux" args="sel_jointstate joint_states blank_msg mux:=jointstate_mux"> </node>

shoriya gravatar image shoriya  ( 2021-05-31 05:30:28 -0500 )edit