lunes, 9 de agosto de 2010

How to know to wich topic a node subscribes or publishes

We can know to wich topic a node subscribes or publishes by viewing carefully the .cpp file of the node. Along the code you can find the name of the topic to which the node subscribes or publish, for example:

ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);

In this line you can see that the node publishes to the "chatter" topic, and that the message is of the type of std_msgs/String

ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);

In this other example you can see that the node subscribes to the "chatter" topic.

For more information: Writing a Simple Publisher and Subscriber (C++)

No hay comentarios:

Publicar un comentario