# Yaw control by Offboard

**URL:** <https://discuss.px4.io/t/yaw-control-by-offboard/16583>\
**Category:** ROS 1 / ROS 2\
**Created:** [May 4, 2020, 2:18pm UTC](https://discuss.px4.io/t/yaw-control-by-offboard/16583 "2020-05-04T14:18:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexW159](https://discuss.px4.io/user_avatar/discuss.px4.io/alexw159/32/6116_2.png) [@AlexW159](https://discuss.px4.io/u/AlexW159)\
**Post date:** [May 4, 2020, 2:18pm UTC](https://discuss.px4.io/t/yaw-control-by-offboard/16583/1 "2020-05-04T14:18:30Z")

</div>

Hi,

I am controlling my drone via an offboard computer using velocity commands. Here I have chosen the /mavros/setpoint\_velocity/cmd\_vel\_unstamped topic. Besides thid, I would like to control the yaw / heading of my drone independently from the velocity.  
Is this possible?

I could control the yaw value via ‘attitude’-commands, however, the pitch and roll-values will override my velocity control.  
Similar, when setting the yaw by local or global positions, this will overwrite my velocity control?

I appreciate your help! Thanks.

---

<div class="post-metadata">

**Author:** ![steveJobless](https://discuss.px4.io/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@steveJobless](https://discuss.px4.io/u/steveJobless)\
**Post date:** [March 26, 2021, 12:17pm UTC](https://discuss.px4.io/t/yaw-control-by-offboard/16583/2 "2021-03-26T12:17:10Z")

</div>

I’m having same issue, were you able to solve it

---

<div class="post-metadata">

**Author:** ![AlexW159](https://discuss.px4.io/user_avatar/discuss.px4.io/alexw159/32/6116_2.png) [@AlexW159](https://discuss.px4.io/u/AlexW159)\
**Post date:** [March 26, 2021, 1:06pm UTC](https://discuss.px4.io/t/yaw-control-by-offboard/16583/3 "2021-03-26T13:06:06Z")

</div>

Kind of.  
We bypassed the problem by using the following topic for velocity control:

`/mavros/setpoint_raw/local`

with following msg type:

```
  mavros_msgs::PositionTarget velocityMsg;

  velocityMsg.header.stamp = ros::Time::now();

  velocityMsg.coordinate_frame = mavros_msgs::PositionTarget::FRAME_LOCAL_NED;
  velocityMsg.type_mask = mavros_msgs::PositionTarget::IGNORE_AFX | 
                                  mavros_msgs::PositionTarget::IGNORE_AFY | 
                                  mavros_msgs::PositionTarget::IGNORE_AFZ |
                                  mavros_msgs::PositionTarget::IGNORE_PX | 
                                  mavros_msgs::PositionTarget::IGNORE_PY | 
                                  mavros_msgs::PositionTarget::IGNORE_PZ;
                                // mavros_msgs::PositionTarget::IGNORE_VX | 
                                // mavros_msgs::PositionTarget::IGNORE_VY | 
                                // mavros_msgs::PositionTarget::IGNORE_VZ;
        
  velocityMsg.velocity.x = groundSpeed_ * sin(move_direction_ * M_PI / 180);
  velocityMsg.velocity.y = groundSpeed_ * cos(move_direction_ * M_PI / 180);
  velocityMsg.velocity.z = climb_speed_;

  velocityMsg.yaw = heading_;
  velocityMsg.yaw_rate = yaw_rate_; 

```

Don’t know if this is the desired/recommended way, however, it works fine.

---

<div class="post-metadata">

**Author:** ![awaisk65](https://discuss.px4.io/user_avatar/discuss.px4.io/awaisk65/32/20968_2.png) [@awaisk65](https://discuss.px4.io/u/awaisk65)\
**Post date:** [September 27, 2023, 8:46am UTC](https://discuss.px4.io/t/yaw-control-by-offboard/16583/4 "2023-09-27T08:46:45Z")

</div>

using /mavros/setpoint\_raw/local topic can solve the issue by ignoring position and acceleration values
