Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Subscribing to a Topic
Description: Subscribing to a Topic.Tutorial Level: BEGINNER
Next Tutorial: Publishing a Topic
Subscribing for Sonar
Figure shows how to subscribe to a sonar data publisher. Firstly connect to ROS. Then, create a subscriber with parameter topic name and message type. Then, specify operations that is going to execute when data received. In this example range value of received data is alerted. field_of_ciew_ min_range, max_range and range options are available in sonar data.
Subscribing for Infrared
Similarly figure shows subscribing to a infrared data publisher. field_of_ciew_ min_range, max_range and range options are available in infrared data. field_of_ciew_ min_range, max_range and range options are available in infrared data.
Subscribing for Bumper
Similarly figure shows subscribing to a bumper data publisher. bumper0_state, bumper1_state and bumper2_state options are available in bumper data.
Subscribing for Odometry
Similarly figure shows subscribing to an odometry data publisher. position_x, position_y, position_z, orientation_x, orientation_y, orientatian_z, oriantation_w, position_covariance, twist_linear_x, twist_linear_y, twist_linear_z, twist_angular_x, twist_ angular _x, twist_ angular _x, twist_covariance options are available in odometry data.
Subscribing for Clock
Similarly figure shows subscribing to a clock data publisher. clock_secs and closc_nsecs options are available in clock data.
Subscribing for Any Topic
Figure shows subscribing to any topic. In this way select a topic and type its message type, when the data received get any value from it and show in alert.