ros experimental operation - programming implementation of subscriber Subscriber

Create a Turtle Location Subscriber

After starting the turtle simulation, ROS will publish a topic named "/turtle1/Pose" by default

Which publishes data of turtlesim/Pose type

Contains the position x, y of the turtle; yaw angle theta; linear velocity linear_velocity; angular velocity angular_velocity.

insert image description here

Now, we create a subscriber in the previous learning_pub_sub_pkg package to subscribe to the location of the turtle and print it to the terminal:

First, create a cpp file named pose_subscriber.cpp in the src folder of the learning_pub_sub_pkg package.

cd ros_wxw/src/learning_pub_sub_pkg/src/

Guess you like

Origin blog.csdn.net/weixin_47723732/article/details/127421742