From ddb91afdde19c33807dba15c8cf21bfac1fd319f Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 6 Jul 2023 13:55:23 +0900 Subject: [PATCH] AP_Mount: add set_tracking accessor --- libraries/AP_Mount/AP_Mount.cpp | 12 ++++++++++++ libraries/AP_Mount/AP_Mount.h | 5 +++++ libraries/AP_Mount/AP_Mount_Backend.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index 13b024e34e..3256e89172 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -751,6 +751,18 @@ SetFocusResult AP_Mount::set_focus(uint8_t instance, FocusType focus_type, float return backend->set_focus(focus_type, focus_value); } +// set tracking to none, point or rectangle (see TrackingType enum) +// if POINT only p1 is used, if RECTANGLE then p1 is top-left, p2 is bottom-right +// p1,p2 are in range 0 to 1. 0 is left or top, 1 is right or bottom +bool AP_Mount::set_tracking(uint8_t instance, TrackingType tracking_type, const Vector2f& p1, const Vector2f& p2) +{ + auto *backend = get_instance(instance); + if (backend == nullptr) { + return false; + } + return backend->set_tracking(tracking_type, p1, p2); +} + // send camera information message to GCS void AP_Mount::send_camera_information(mavlink_channel_t chan) const { diff --git a/libraries/AP_Mount/AP_Mount.h b/libraries/AP_Mount/AP_Mount.h index 09798629d8..e9a9509896 100644 --- a/libraries/AP_Mount/AP_Mount.h +++ b/libraries/AP_Mount/AP_Mount.h @@ -218,6 +218,11 @@ public: // focus in = -1, focus hold = 0, focus out = 1 SetFocusResult set_focus(uint8_t instance, FocusType focus_type, float focus_value); + // set tracking to none, point or rectangle (see TrackingType enum) + // if POINT only p1 is used, if RECTANGLE then p1 is top-left, p2 is bottom-right + // p1,p2 are in range 0 to 1. 0 is left or top, 1 is right or bottom + bool set_tracking(uint8_t instance, TrackingType tracking_type, const Vector2f& p1, const Vector2f& p2); + // send camera information message to GCS void send_camera_information(mavlink_channel_t chan) const; diff --git a/libraries/AP_Mount/AP_Mount_Backend.h b/libraries/AP_Mount/AP_Mount_Backend.h index 5eda3e5e62..827c7db133 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.h +++ b/libraries/AP_Mount/AP_Mount_Backend.h @@ -157,6 +157,11 @@ public: // focus in = -1, focus hold = 0, focus out = 1 virtual SetFocusResult set_focus(FocusType focus_type, float focus_value) { return SetFocusResult::UNSUPPORTED; } + // set tracking to none, point or rectangle (see TrackingType enum) + // if POINT only p1 is used, if RECTANGLE then p1 is top-left, p2 is bottom-right + // p1,p2 are in range 0 to 1. 0 is left or top, 1 is right or bottom + virtual bool set_tracking(TrackingType tracking_type, const Vector2f& p1, const Vector2f& p2) { return false; } + // send camera information message to GCS virtual void send_camera_information(mavlink_channel_t chan) const {}