# How to set drone's yaw heading the target point

**URL:** <https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713>\
**Category:** ROS 1 / ROS 2\
**Created:** [March 30, 2021, 9:06am UTC](https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713 "2021-03-30T09:06:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![XANA](https://discuss.px4.io/user_avatar/discuss.px4.io/xana/32/7315_2.png) [@XANA](https://discuss.px4.io/u/XANA)\
**Post date:** [March 30, 2021, 9:06am UTC](https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713/1 "2021-03-30T09:06:53Z")

</div>

Hello,

I use the companion computer to control the Pixhawk4 in offboard mode.

The drone initializes at the home position **A** , and I set a target point **B** (global point).

Now my question is: how to set yaw so that the drone can towards B, then fly from A to B?

I use **MAVROS** , and

```auto
ros::Publisher global_pose_pub = nh.advertise<geographic_msgs::GeoPoseStamped>("mavros/setpoint_position/global", 10)

```

to set the target point.

The drone now can successfully fly from point A to point B, but the yaw of the drone stays the same during the flight(keep heading north). It just can’t fly heading point B. So how to set the drone’s orientation?

**Thanks a lot!**

---

<div class="post-metadata">

**Author:** ![Niknu](https://discuss.px4.io/user_avatar/discuss.px4.io/niknu/32/8033_2.png) [@Niknu](https://discuss.px4.io/u/Niknu)\
**Post date:** [April 1, 2021, 6:22pm UTC](https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713/2 "2021-04-01T18:22:23Z")

</div>

You can do it by the local pose topic of the drone where you set the orientation with quaternions.

---

<div class="post-metadata">

**Author:** ![copterspace](https://discuss.px4.io/user_avatar/discuss.px4.io/copterspace/32/3187_2.png) [@copterspace](https://discuss.px4.io/u/copterspace)\
**Post date:** [April 2, 2021, 4:52am UTC](https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713/3 "2021-04-02T04:52:05Z")

</div>

> [@XANA](#):
>
> `"mavros/setpoint_position/global`

[Global position setpoint](http://docs.ros.org/en/api/mavros_msgs/html/msg/GlobalPositionTarget.html) has yaw and yawrate setpoints, you may try both.

I controlled yaw with local position setpoint, [example is here](https://github.com/copterspace/robocross2019/blob/master/crash_baloon.py)

---

<div class="post-metadata">

**Author:** ![XANA](https://discuss.px4.io/user_avatar/discuss.px4.io/xana/32/7315_2.png) [@XANA](https://discuss.px4.io/u/XANA)\
**Post date:** [April 25, 2021, 1:01pm UTC](https://discuss.px4.io/t/how-to-set-drones-yaw-heading-the-target-point/21713/4 "2021-04-25T13:01:36Z")

</div>

Very helpful and a great example to control yaw, thank you for your reply!
