ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Let's say node A has created it's publisher using something like
ros::Publisher pub = node.advertise<std_msgs::Twist>("turtle1/cmd_vel", 100);
and node B has subscribed using something like
ros::Subscriber sub = node.subscribe("cmd_vel", 100, datacb);
I believe that is the situation you are describing. Then the question is how to get the subscriber in B to successfully subscribe to the topic published by A. This is fundamentally a question of how ROS Names are resolved. Below are a few possible solutions. The correct solution depends on your specific application:
rosrun
via Remapping Arguments, or in roslaunch
via the remap tag.turtle1/
namespace. Then its subscriber would automatically resolve to turtle1/cmd_vel
. This could be done using the ns
attribute of either the node tag or the group tag. You could also modify the namespace of a node at the command line with the ROS_NAMESPACE environment variable.