Skip to content

Commit

Permalink
AP_Mount: In Servo backend, set flags to indicate attitude is in body…
Browse files Browse the repository at this point in the history
… frame
  • Loading branch information
nexton-winjeel committed May 16, 2024
1 parent 745c4e5 commit 59a5d30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libraries/AP_Mount/AP_Mount_Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ bool AP_Mount_Servo::get_attitude_quaternion(Quaternion& att_quat)
return true;
}

// helper function to provide GIMBAL_DEVICE_FLAGS for use in GIMBAL_DEVICE_ATTITUDE_STATUS message
uint16_t AP_Mount_Servo::get_gimbal_device_flags() const
{
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 |
GIMBAL_DEVICE_FLAGS_YAW_LOCK |
GIMBAL_DEVICE_FLAGS_YAW_IN_EARTH_FRAME);
flags &= mask;
// and set the YAW_IN_VEHICLE_FRAME flag
flags |= GIMBAL_DEVICE_FLAGS_YAW_IN_VEHICLE_FRAME;

return flags;
}

// private methods

// update body-frame angle outputs from earth-frame angle targets
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_Mount/AP_Mount_Servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class AP_Mount_Servo : public AP_Mount_Backend
// get attitude as a quaternion. returns true on success
bool get_attitude_quaternion(Quaternion& att_quat) override;

// helper function to provide GIMBAL_DEVICE_FLAGS for use in GIMBAL_DEVICE_ATTITUDE_STATUS message
uint16_t get_gimbal_device_flags() const override;

private:

// update body-frame angle outputs from earth-frame targets
Expand Down

0 comments on commit 59a5d30

Please sign in to comment.