Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copter: Handle DO_MOUNT_CONTROL yaw angle as body frame #27071

Conversation

nexton-winjeel
Copy link
Contributor

The demanded yaw angles in the MOUNT_CONTROL and DO_MOUNT_CONTROL commands are in body frame (and are handled this way in AP_Mount). This fixes the Copter handlers where they were being treated as earth frame.

It also rejects these messages if an invalid mode is provided, as the yaw control is only applicable when the mode is MAV_MOUNT_MODE_MAVLINK_TARGETING.

FYI: @rmackay9

@@ -1219,6 +1219,7 @@ MAV_MISSION_RESULT AP_Mission::mavlink_int_to_mission_cmd(const mavlink_mission_
break;

case MAV_CMD_DO_MOUNT_CONTROL: // MAV ID: 205
// TODO: this is only valid if packet.z == MAV_MOUNT_MODE_MAVLINK_TARGETING
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be returning MAV_MISSION_INVALID_PARAM7 if the mode (packet.z) is not set to MAV_MOUNT_MODE_MAVLINK_TARGETING?

@joshanne
Copy link
Contributor

@rmackay9 you might have some interest on this one.

@rmackay9
Copy link
Contributor

We talked about this on the dev call and discussed the concern that users of MP may find that if they use the payload control tab that the vehicle may end up doing circles. The procedure would be to setup a vehicle with a 2-axis gimbal and then:

  • move Pan control to 45 deg
  • move Tilt up and down

Each time the Tilt is moved the yaw would be re-sent and because after this change it would be in body-frame the vehicle would rotate

On the other hand, the Pan control changing the vehicle's heading to an absolute heading (e.g. North) also doesn't seem very good

I'll test and see what happens in SITL

@rmackay9
Copy link
Contributor

Hi @nexton-winjeel,

I've tested this and I agree that it is an improvement. The existing behaviour results in the vehicle turning to point North if the user clicks on MP's the Payload Control pitch or roll controls which is certainly unexpected.

One small issue I noticed is that this essentially locks in any yaw error so if the user constantly adjusts roll or pitch the vehicle will also yaw slightly. I think we could fix this by using the current target yaw instead of the actual yaw.

@nexton-winjeel nexton-winjeel force-pushed the upstream/copter-autoyaw-mount_control-yaw-is-body-frame branch from cb594fa to 85e0f10 Compare October 1, 2024 06:58
@nexton-winjeel
Copy link
Contributor Author

@rmackay9:

I think we could fix this by using the current target yaw instead of the actual yaw.

I've updated to use the current yaw target. I've also added an autotest.

@nexton-winjeel nexton-winjeel force-pushed the upstream/copter-autoyaw-mount_control-yaw-is-body-frame branch from 85e0f10 to 214cce6 Compare October 1, 2024 23:58
@nexton-winjeel
Copy link
Contributor Author

test.Plane.DeadreckoningNoAirSpeed failed when I made Copter changes?

Rebased on master to re-trigger the tests.

@nexton-winjeel
Copy link
Contributor Author

And now test.Copter.AutoTuneYawD is failing. Can't repro locally though. Flapping?

@nexton-winjeel nexton-winjeel force-pushed the upstream/copter-autoyaw-mount_control-yaw-is-body-frame branch from 214cce6 to d6b2a79 Compare October 4, 2024 04:17
@joshanne joshanne requested a review from rmackay9 October 4, 2024 04:18
@nexton-winjeel nexton-winjeel force-pushed the upstream/copter-autoyaw-mount_control-yaw-is-body-frame branch from d6b2a79 to 6ec5817 Compare October 6, 2024 21:42
@rmackay9 rmackay9 merged commit 77f1efa into ArduPilot:master Oct 7, 2024
98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants