ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# why the turtle2 follow turtle1 in tf2 tutorials? I am following the Python tutorials of tf2 - http://wiki.ros.org/tf2/Tutorials. I have completed it till writing a tf2.listener step. I am confused as to why after this step turtle2 follow the turtle1. All I understood is that the previous broadcaster broadcasts the pose of turtle1 w.r.t to the world frame. And the listener listens to that pose or transform and does frame transformation from turtle2 to turtle1. Why frame transform between frame1 and frame2 makes one turtle follow the other one?

Isn't it true that transform is just a relationship between coordinate frames of both the turtles. We then generally use this information to transform a point in frame1 to frame 2. But I am a little confused about what's happening in that tutorial. Any help is appreciated.

I am using ROS Noetic in Ubuntu 20.04. I wanted to use tf2 to transform vector and point of an object from camera frame to the robot frame in my project.

edit retag close merge delete

Does this code ''trans = tfBuffer.lookup_transform(turtle_name, 'turtle1', rospy.Time())'' gives pose of turtle1 w.r.t turtle_name i.e.turtle2?

Sort by » oldest newest most voted The tf2 broadcaster is publishing the coordinate frames of the lead turtle. A tf2 listener calculates the difference between the coordinate frames of the lead turtle and the follower turtle. It then moves the follower turtle so that it follows the lead turtle.

  30         msg = geometry_msgs.msg.Twist()
31
32         msg.angular.z = 4 * math.atan2(trans.transform.translation.y, trans.transform.translation.x)
33         msg.linear.x = 0.5 * math.sqrt(trans.transform.translation.x ** 2 + trans.transform.translation.y ** 2)


Where transis tf from turtle1. There is a good tutorial that explains this in more detail: https://automaticaddison.com/working-...

more

Thank you for answering Osilva. Can you tell which line of code calculates the difference between the coordinates frame? Is it this one- ''trans = tfBuffer.lookup_transform(turtle_name, 'turtle1', rospy.Time())'' And does this line of code gives pose of turtle1 w.r.t turtle_name i.e.turtle2?

1

That line gets the transform from turtle1, the difference is calculated with lines 30-33.

The line which I mentioned, does that line of code gives pose of turtle1 w.r.t turtle_name i.e.turtle2? I don't want to leave any confusion that's why asking again. Thank you again. I find the terminology of transform from and to confusing. The tutorials use this terminology.

1

Inherits tf2_ros::BufferInterface and tf2::BufferCore. Stores known frames and offers a ROS service, "tf_frames", which responds to client requests with a response containing a tf2_msgs::FrameGraph representing the relationship of known frames

Check this video: https://ocw.tudelft.nl/course-lecture...