ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
As guessed by felix k before this is intended behavior of rostopic echo
. It subscribes to parent topics and attempts to extract field names with that name from the messages.
When the subscription is performed in a node it will not auto magically subscribe to the parent topic. You can try the following Python script sub.py with the argument /parent
or /parent/child
instead of invoking rostopic:
#!/usr/bin/env python
import sys
import rospy
from std_msgs.msg import String
def callback(data):
rospy.loginfo(rospy.get_caller_id() + 'Incoming message: %s',data.data)
rospy.init_node('listener', anonymous=True)
rospy.Subscriber(sys.argv[1], String, callback)
rospy.spin()