Confirmation regarding my understanding of Angle speed and linear speed calculation in Unit 3 TF listener exercise?

angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular

My understanding is that the listener finds the position of the followed object within the reference frame of the follower object. Thus in this case follower object becomes the origin of the reference frame of interest and followed object is a point in the reference frame . Thus by using the formula of calculating standard angle(atan) and distance(sqrt) between two points[origin,trans coord] , these values are used as gradient to calculate the angular and linear speed correct ?


Totally correct. Its a very smple way of creating a follower robot using TFs

Yes atan2 ia very interesting formula to avoid addressing a wrong quadrant in robotics. For example if you use atan(1,1) = 45 and atan(-1,-1) =45. So if your model to be followed be in the second quadrant you would follow it wrongly using atan formula, and your robot would go to northeast direction ever … However using atan2(-1,-1) = 135 which is the second quadrant! And your robot would follow the model properly, in northwest! There is a math behind this very cool which considers the direction (CW or CCW) of the arguments between (-π,π) when returning the degree value!

1 Like