From f5ab31a9839aa7658f7cd2d5a77a1e20e6d6143e Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 2 Nov 2023 12:34:31 +0900 Subject: [PATCH] AP_Camera: camera_fov_status includes field-of-view --- libraries/AP_Camera/AP_Camera_Backend.cpp | 4 ++-- libraries/AP_Camera/AP_Camera_Backend.h | 4 ++++ libraries/AP_Camera/AP_Camera_Params.cpp | 16 ++++++++++++++++ libraries/AP_Camera/AP_Camera_Params.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Camera/AP_Camera_Backend.cpp b/libraries/AP_Camera/AP_Camera_Backend.cpp index 94613beef107c..abda67057dfae 100644 --- a/libraries/AP_Camera/AP_Camera_Backend.cpp +++ b/libraries/AP_Camera/AP_Camera_Backend.cpp @@ -280,8 +280,8 @@ void AP_Camera_Backend::send_camera_fov_status(mavlink_channel_t chan) const poi_loc.lng, poi_loc.alt, quat_array, - NaN, // currently setting hfov as NaN - NaN // currently setting vfov as NaN + horizontal_fov() > 0 ? horizontal_fov() : NaN, + vertical_fov() > 0 ? vertical_fov() : NaN ); } #endif diff --git a/libraries/AP_Camera/AP_Camera_Backend.h b/libraries/AP_Camera/AP_Camera_Backend.h index ad2fa95544b48..bae4fb8ea291e 100644 --- a/libraries/AP_Camera/AP_Camera_Backend.h +++ b/libraries/AP_Camera/AP_Camera_Backend.h @@ -85,6 +85,10 @@ class AP_Camera_Backend // set camera lens as a value from 0 to 5 virtual bool set_lens(uint8_t lens) { return false; } + // get camera image horizontal or vertical field of view in degrees. returns 0 if unknown + float horizontal_fov() const { return MAX(0, _params.hfov); } + float vertical_fov() const { return MAX(0, _params.vfov); } + // handle MAVLink messages from the camera virtual void handle_message(mavlink_channel_t chan, const mavlink_message_t &msg) {} diff --git a/libraries/AP_Camera/AP_Camera_Params.cpp b/libraries/AP_Camera/AP_Camera_Params.cpp index ee3f7796590ab..7b32ca60cf1bb 100644 --- a/libraries/AP_Camera/AP_Camera_Params.cpp +++ b/libraries/AP_Camera/AP_Camera_Params.cpp @@ -87,6 +87,22 @@ const AP_Param::GroupInfo AP_Camera_Params::var_info[] = { // @User: Standard AP_GROUPINFO("_MNT_INST", 11, AP_Camera_Params, mount_instance, 0), + // @Param: _HFOV + // @DisplayName: Camera horizontal field of view + // @Description: Camera horizontal field of view. 0 if unknown + // @Units: deg + // @Range: 0 360 + // @User: Standard + AP_GROUPINFO("_HFOV", 12, AP_Camera_Params, hfov, 0), + + // @Param: _VFOV + // @DisplayName: Camera vertical field of view + // @Description: Camera vertical field of view. 0 if unknown + // @Units: deg + // @Range: 0 180 + // @User: Standard + AP_GROUPINFO("_VFOV", 13, AP_Camera_Params, vfov, 0), + AP_GROUPEND }; diff --git a/libraries/AP_Camera/AP_Camera_Params.h b/libraries/AP_Camera/AP_Camera_Params.h index ca54550fe1ddb..cba713a16319e 100644 --- a/libraries/AP_Camera/AP_Camera_Params.h +++ b/libraries/AP_Camera/AP_Camera_Params.h @@ -23,6 +23,8 @@ class AP_Camera_Params { AP_Float interval_min; // minimum time (in seconds) between shots required by camera AP_Int8 options; // whether to start recording when armed and stop when disarmed AP_Int8 mount_instance; // mount instance to which camera is associated with + AP_Float hfov; // horizontal field of view in degrees + AP_Float vfov; // vertical field of view in degrees // pin number for accurate camera feedback messages AP_Int8 feedback_pin;