ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

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 trans is tf from turtle1. There is a good tutorial that explains this in more detail: https://automaticaddison.com/working-with-tf2-in-ros-noetic/