Skip to content

GCS_MAVLink_Copter: implement yaw control in guided do_reposition#32814

Open
tedtasman wants to merge 1 commit intoArduPilot:masterfrom
tedtasman:feat/reposition-yaw
Open

GCS_MAVLink_Copter: implement yaw control in guided do_reposition#32814
tedtasman wants to merge 1 commit intoArduPilot:masterfrom
tedtasman:feat/reposition-yaw

Conversation

@tedtasman
Copy link
Copy Markdown

@tedtasman tedtasman commented Apr 17, 2026

Summary

handle_command_int_do_reposition now unpacks param4 to get target yaw from MAV_CMD_DO_REPOSITION packet. Also checks the MAV_DO_REPOSITION_FLAGS_RELATIVE_YAW bit in param2

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

logs.zip

Attached are two logs for the same commands, pre.BIN and post.BIN, before and after the change respectively. The commands send the copter to one position with a yaw of 180º (pi in radians) with relative_yaw=0. The second command sends the copter to the same position at a lower altitude, with relative_yaw=1 and yaw of 45º (pi/4). Without the change, the copter does not follow the requested angles. With the change it does.

Before:
pre_yaw

After:
post_yaw

@tedtasman
Copy link
Copy Markdown
Author

tedtasman commented Apr 17, 2026

For reference, here is the test mission I used:

        await controller.set_mode("GUIDED")
        await controller.set_message_interval(MAVMessage.GLOBAL_POSITION_INT, 500_000)
        await controller.arm()

        await controller.takeoff(0, 20)
        await asyncio.sleep(5)

        coord_1 = Coordinate(latitude_deg=-35.362139, longitude_deg=149.1638792, altitude_m=30, heading_deg=180)
        await controller.send_reposition(coord_1)
        await controller.wait_for_position_reached(coord_1, 20, 60)

        coord_2 = Coordinate(latitude_deg=-35.362139, longitude_deg=149.1638792, altitude_m=10, heading_deg=45)

        await controller.send_reposition(coord_2, relative_yaw=True)
        await controller.wait_for_position_reached(coord_2, 20, 60)

handle_command_int_do_reposition now unpacks param4 to get target yaw from MAV_CMD_DO_REPOSITION packet. Also checks the MAV_DO_REPOSITION_FLAGS_RELATIVE_YAW bit in param2
@tedtasman tedtasman force-pushed the feat/reposition-yaw branch from 1a9389d to 74fb554 Compare April 17, 2026 19:12
@Ryanf55
Copy link
Copy Markdown
Contributor

Ryanf55 commented Apr 18, 2026

Nice! Good work. Would you consider taking the test your wrote and adding that to the pull request?

In the autotest suite (Tools/autotest/arducopter.py), you can use functions like self.wait_heading(180), self.assert_heading and self.send_do_reposition.

From inspection, the code change looks good.

Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an autotest or two showing this working.

If ArduPilot starts to support this then ground control stations will start to send it.

Older ArduPilot simply won't follow the extra arguments (rather than rejecting the command)..... could be a problem in certain circumstances. Just noting it here, I don't think it's a show-stopper for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants