-
Notifications
You must be signed in to change notification settings - Fork 18k
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
AP_Mount: Fix GIMBAL_DEVICE_FLAGS in GIMBAL_DEVICE_ATTITUDE_STATUS #27073
AP_Mount: Fix GIMBAL_DEVICE_FLAGS in GIMBAL_DEVICE_ATTITUDE_STATUS #27073
Conversation
uint16_t flags = AP_Mount_Backend::get_gimbal_device_flags(); | ||
// per get_attitude_quaternion() above, angles are all body frame, so clear all the LOCK flags... | ||
const uint16_t mask = ~(GIMBAL_DEVICE_FLAGS_ROLL_LOCK | | ||
GIMBAL_DEVICE_FLAGS_PITCH_LOCK | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMPORTANT: The clearing of GIMBAL_DEVICE_FLAGS_ROLL_LOCK
and GIMBAL_DEVICE_FLAGS_PITCH_LOCK
is only applicable if #27072 is merged.
const uint16_t flags = (get_mode() == MAV_MOUNT_MODE_RETRACT ? GIMBAL_DEVICE_FLAGS_RETRACT : 0) | | ||
(get_mode() == MAV_MOUNT_MODE_NEUTRAL ? GIMBAL_DEVICE_FLAGS_NEUTRAL : 0) | | ||
GIMBAL_DEVICE_FLAGS_ROLL_LOCK | // roll angle is always earth-frame | ||
GIMBAL_DEVICE_FLAGS_PITCH_LOCK| // pitch angle is always earth-frame, yaw_angle is always body-frame | ||
GIMBAL_DEVICE_FLAGS_YAW_IN_VEHICLE_FRAME | // yaw angle is always in vehicle-frame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Davidsastresas: You made the change to set GIMBAL_DEVICE_FLAGS_YAW_IN_VEHICLE_FRAME
unconditionally (in f12ca0b). My understanding is that it should only be set if yaw_lock_state
is false
?
Hi @nexton-winjeel, I think we should always be reporting the gimbal's attitude in body-frame. I think it will be too confusing for the GCSs to have to deal with body-frame sometimes and earth-frame other times. I think the lock state (which is more of a target or control state) is not directly related to the reporting of the attitude estimate. |
Thanks @rmackay9. Yes, I agree the reported attitude should be in body frame.
That doesn't align with the description here: https://mavlink.io/en/messages/common.html#GIMBAL_DEVICE_ATTITUDE_STATUS. My understanding is that we should prefer |
I'm going to close this, because it's not correct as-is. However, we might need another PR to align the |
Hello @nexton-winjeel, thanks for catching my attention. This matter with flags on gimbal is confusing, back at the time when we did the QGC implementation we also got confused for a while. Please see here: So the recommended use is always for new systems: But consumers ( mainly GCS ) need to also have support for GIMBAL_DEVICE_FLAGS_YAW_LOCK, as some older systems use it to indicate yaw frame too, if the above flags are not used. As far as I remember, Ardupilot always deal with gimbal angles in vehicle frame, that is why I left GIMBAL_DEVICE_FLAGS_YAW_IN_VEHICLE_FRAME permanently set. This works perfectly fine and should be gimbal manager v2 compliant. Then, in order to indicate if yaw is locked or not, we can just use GIMBAL_DEVICE_FLAGS_YAW_LOCK. If we have the 2 flags mentioned above to just indicate the frame reference, this flag will exclusively indicate yaw lock state. Considering that, I think as it is now ( at least as it was the last time I looked at it a few weeks back ), it should be compliant and functional. But I might be wrong, if it doesn't make sense to you let me know and I will look at it again. Thanks! |
This PR fixes two issues with the reported flags in
GIMBAL_DEVICE_ATTITUDE_STATUS
:GIMBAL_DEVICE_FLAGS_YAW_IN_VEHICLE_FRAME
is always set, even if the yaw is locked (i.e. in earth frame); andGIMBAL_DEVICE_FLAGS_YAW_LOCK
andGIMBAL_DEVICE_FLAGS_YAW_IN_EARTH_FRAME
flags need to be unset.FYI: @rmackay9