How to set drone's yaw heading the target point

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

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!

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

Global position setpoint has yaw and yawrate setpoints, you may try both.

I controlled yaw with local position setpoint, example is here

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