From 611fb94660da000ffbc8f3ecb028940c3dff3480 Mon Sep 17 00:00:00 2001 From: laozhou <3177821352@qq.com> Date: Tue, 26 Mar 2024 22:35:29 +0800 Subject: [PATCH] AP_Mount: integrate topotek gimbal driver Co-authored-by: Randy Mackay --- libraries/AP_Mount/AP_Mount.cpp | 9 +++++++++ libraries/AP_Mount/AP_Mount.h | 5 +++++ libraries/AP_Mount/AP_Mount_Params.cpp | 2 +- libraries/AP_Mount/AP_Mount_config.h | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index 94e7a24a1c..811bb9a396 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -15,6 +15,7 @@ #include "AP_Mount_Scripting.h" #include "AP_Mount_Xacti.h" #include "AP_Mount_Viewpro.h" +#include "AP_Mount_Topotek.h" #include #include #include @@ -156,6 +157,14 @@ void AP_Mount::init() serial_instance++; break; #endif // HAL_MOUNT_VIEWPRO_ENABLED + +#if HAL_MOUNT_TOPOTEK_ENABLED + // check for Topotek gimbal + case Type::Topotek: + _backends[instance] = NEW_NOTHROW AP_Mount_Topotek(*this, _params[instance], instance, serial_instance); + _num_instances++; + break; +#endif // HAL_MOUNT_TOPOTEK_ENABLED } // init new instance diff --git a/libraries/AP_Mount/AP_Mount.h b/libraries/AP_Mount/AP_Mount.h index 110267bcc4..f4e36949c7 100644 --- a/libraries/AP_Mount/AP_Mount.h +++ b/libraries/AP_Mount/AP_Mount.h @@ -47,6 +47,7 @@ class AP_Mount_Siyi; class AP_Mount_Scripting; class AP_Mount_Xacti; class AP_Mount_Viewpro; +class AP_Mount_Topotek; /* This is a workaround to allow the MAVLink backend access to the @@ -67,6 +68,7 @@ class AP_Mount friend class AP_Mount_Scripting; friend class AP_Mount_Xacti; friend class AP_Mount_Viewpro; + friend class AP_Mount_Topotek; public: AP_Mount(); @@ -114,6 +116,9 @@ public: #endif #if HAL_MOUNT_VIEWPRO_ENABLED Viewpro = 11, /// Viewpro gimbal using a custom serial protocol +#endif +#if HAL_MOUNT_TOPOTEK_ENABLED + Topotek = 12, /// Topotek gimbal using a custom serial protocol #endif }; diff --git a/libraries/AP_Mount/AP_Mount_Params.cpp b/libraries/AP_Mount/AP_Mount_Params.cpp index 57257eb5e4..e2c727f4b4 100644 --- a/libraries/AP_Mount/AP_Mount_Params.cpp +++ b/libraries/AP_Mount/AP_Mount_Params.cpp @@ -9,7 +9,7 @@ const AP_Param::GroupInfo AP_Mount_Params::var_info[] = { // @Param: _TYPE // @DisplayName: Mount Type // @Description: Mount Type - // @Values: 0:None, 1:Servo, 2:3DR Solo, 3:Alexmos Serial, 4:SToRM32 MAVLink, 5:SToRM32 Serial, 6:Gremsy, 7:BrushlessPWM, 8:Siyi, 9:Scripting, 10:Xacti, 11:Viewpro + // @Values: 0:None, 1:Servo, 2:3DR Solo, 3:Alexmos Serial, 4:SToRM32 MAVLink, 5:SToRM32 Serial, 6:Gremsy, 7:BrushlessPWM, 8:Siyi, 9:Scripting, 10:Xacti, 11:Viewpro, 12:Topotek // @RebootRequired: True // @User: Standard AP_GROUPINFO_FLAGS("_TYPE", 1, AP_Mount_Params, type, 0, AP_PARAM_FLAG_ENABLE), diff --git a/libraries/AP_Mount/AP_Mount_config.h b/libraries/AP_Mount/AP_Mount_config.h index 0a6d38671c..6c0f63509e 100644 --- a/libraries/AP_Mount/AP_Mount_config.h +++ b/libraries/AP_Mount/AP_Mount_config.h @@ -54,6 +54,10 @@ #define AP_MOUNT_POI_TO_LATLONALT_ENABLED HAL_MOUNT_ENABLED && AP_TERRAIN_AVAILABLE && BOARD_FLASH_SIZE > 1024 #endif +#ifndef HAL_MOUNT_TOPOTEK_ENABLED +#define HAL_MOUNT_TOPOTEK_ENABLED AP_MOUNT_BACKEND_DEFAULT_ENABLED +#endif + // set camera source is supported on gimbals that may have more than one lens #ifndef HAL_MOUNT_SET_CAMERA_SOURCE_ENABLED #define HAL_MOUNT_SET_CAMERA_SOURCE_ENABLED HAL_MOUNT_SIYI_ENABLED || HAL_MOUNT_XACTI_ENABLED || HAL_MOUNT_VIEWPRO_ENABLED