# Determining (Heading) Yaw to rotate the Turtle Robot to desired point (X,Y) so it moves towards it

I have a turtle bot and I want to modify its heading so it moves to certain point (x,y) in the world.

Now I reckon that yaw is angle from robots reference, how do I determine the yaw as the point (x,y) is from global (world's reference)?

## 1 Answer

This is basic geometry/trigonometry. Here is an image of your situation (the plane being your turtle bot, and the red circle being your target ($$x$$,$$y$$). You want your turtle bot to first turn to face the target and then head towards it. So first you need to compute your desired heading ($$\theta_t$$)

This is basic trigonometry: $$tan(\theta_t) = \frac{y_t-y}{x_t - x} \Rightarrow \theta_t = atan(\frac{y_t-y}{x_t - x})$$

So you need to turn your robot of $$\theta - \theta_t$$ to face your target first.

• it is so clear with a picture. thanks – GENIVI-LEARNER Feb 21 at 16:09
• You welcome. Pictures always help ;) – ejalaa12 Feb 21 at 16:32