[cam_gimbal] rewrite the pan/tilt control module (#3538)

- generic pan/tilt gimbal control with several builtin modes
- gimbal position and orientation configurable
- specialization possible for gimbals not matching the default scheme
  (with an example using the Caddx GM3 3 axis gimbal)
- remove all the old unused code using gimbal control
This commit is contained in:
Gautier Hattenberger
2025-09-17 16:55:30 +02:00
committed by GitHub
parent 39ed0bb0b9
commit 528f9a5ade
18 changed files with 702 additions and 1490 deletions
+27
View File
@@ -0,0 +1,27 @@
<joystick>
<input>
<axis index="0" name="roll"/>
<axis index="1" name="pitch"/>
<axis index="2" name="throttle"/>
<button index="0" name="shoot"/>
<button index="1" name="down"/>
<button index="2" name="up"/>
<button index="3" name="left"/>
<button index="4" name="right"/>
<button index="5" name="button6"/>
<button index="6" name="button7"/>
<button index="7" name="button8"/>
<button index="8" name="button9"/>
<button index="9" name="button10"/>
<button index="10" name="button11"/>
</input>
<messages period="0.1">
<message class="datalink" name="JOYSTICK_RAW" send_always="false">
<field name="roll" value="Fit(roll, -126, 126, -9600, 9600)"/>
<field name="pitch" value="Fit(pitch, -126, 126, -9600, 9600)"/>
<field name="yaw" value="0"/>
<field name="throttle" value="Fit(-throttle, -126, 127, 0, 9600)"/>
</message>
</messages>
</joystick>
+38
View File
@@ -0,0 +1,38 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="cam_gimbal" dir="cam_control" task="control">
<doc>
<description>
Generic PAN/TILT camera gimbal control
</description>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="cam control">
<dl_setting MAX="7" MIN="0" STEP="1" module="cam_control/cam_gimbal" VAR="cam_gimbal.mode" shortname="mode" values="OFF|JOYSTICK|ANGLES|NADIR|TARGET|WAYPOINT|AC_TARGET" handler="SetMode"/>
<dl_setting MAX="1" MIN="0" STEP="1" module="cam_control/cam_gimbal" VAR="cam_gimbal.lock" shortname="lock" values="UNLOCK|LOCK" handler="SetLock"/>
<dl_setting MAX="90" MIN="-90" STEP="1" var="cam_gimbal.tilt_angle" shortname="tilt" unit="rad" alt_unit="deg"/>
<dl_setting MAX="180" MIN="-180" STEP="1" var="cam_gimbal.pan_angle" shortname="pan" unit="rad" alt_unit="deg"/>
<dl_setting min="1" max="27" step="1" var="cam_gimbal.target_wp_id" shortname="wp id"/>
<dl_setting min="1" max="255" step="1" var="cam_gimbal.target_ac_id" shortname="ac id"/>
<dl_setting MAX="100." MIN="-100." STEP="1." var="cam_gimbal.target_pos.x" shortname="target x" unit="m"/>
<dl_setting MAX="100." MIN="-100." STEP="1." var="cam_gimbal.target_pos.y" shortname="target y" unit="m"/>
<dl_setting MAX="100." MIN="-100." STEP="1." var="cam_gimbal.target_pos.z" shortname="target z" unit="m"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<recommends>joystick</recommends>
</dep>
<header>
<file name="cam_gimbal.h"/>
</header>
<init fun="cam_gimbal_init()"/>
<periodic fun="cam_gimbal_periodic()" />
<makefile>
<file name="cam_gimbal.c"/>
<test firmware="fixedwing"/>
<test firmware="rotorcraft"/>
<test firmware="rover"/>
</makefile>
</module>
-56
View File
@@ -1,56 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="cam_point" dir="cam_control">
<doc>
<description>Camera control for fixedwing</description>
</doc>
<settings name="complete">
<dl_settings NAME="control">
<dl_settings name="cam">
<dl_setting MAX="7" MIN="0" STEP="1" module="cam_control/cam" VAR="cam_mode" values="0FF|ANGLES|NADIR|XY_TARGET|WP_TARGET|AC_TARGET|STABILIZED|RC">
<strip_button name="AC_TARGET" value="5"/>
<strip_button name="WP_TARGET" value="4"/>
<strip_button name="XY_TARGET" value="3"/>
<strip_button name="NADIR" value="2"/>
<strip_button name="ANGLES" value="1"/>
<strip_button name="OFF" value="0"/>
</dl_setting>
</dl_settings>
<dl_settings name="angles">
<dl_setting MAX="30" MIN="-30" STEP="1" module="cam_control/cam" VAR="cam_tilt_c" unit="rad" alt_unit="deg"/>
<dl_setting MAX="30" MIN="-30" STEP="1" module="cam_control/cam" VAR="cam_pan_c" unit="rad" alt_unit="deg"/>
</dl_settings>
<dl_settings name="target">
<dl_setting min="1" max="27" step="1" module="cam_control/cam" var="cam_target_wp" shortname="wp"/>
</dl_settings>
</dl_settings>
</settings>
<settings name="pitch_only">
<dl_settings NAME="control">
<dl_settings name="cam">
<dl_setting MAX="1" MIN="0" STEP="1" module="cam_control/cam" VAR="cam_mode">
<strip_button name="ANGLES" value="1"/>
</dl_setting>
</dl_settings>
<dl_settings name="angles">
<dl_setting MAX="30" MIN="-30" STEP="1" module="cam_control/cam" VAR="cam_tilt_c" unit="rad" alt_unit="deg">
<strip_button name="Look Foreward" icon="lookfore.png" value="-0.5"/>
<strip_button name="Look Down" icon="lookdown.png" value="0.5"/>
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="cam.h"/>
<file name="point.h"/>
</header>
<init fun="cam_init()"/>
<periodic fun="cam_periodic()" />
<makefile>
<define name="CAM"/>
<define name="MOBILE_CAM"/>
<define name="POINT_CAM"/>
<file name="cam.c"/>
<file name="point.c"/>
</makefile>
</module>
-26
View File
@@ -1,26 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="cam_roll" dir="cam_control">
<doc>
<description>Camera control on roll axis only</description>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="Cam">
<dl_setting MAX="45" MIN="-45" STEP="1" VAR="cam_roll_phi" module="cam_control/cam_roll" shortname="phi" unit="rad" alt_unit="deg" auto="true">
</dl_setting>
<dl_setting MAX="1" MIN="0" STEP="1" VAR="cam_roll_mode" module="cam_control/cam_roll" shortname="manual - stablzd">
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="cam.h"/>
</header>
<init fun="cam_init()"/>
<periodic fun="cam_periodic()" freq="10."/>
<makefile>
<define name="MOBILE_CAM"/>
<file name="cam_roll.c"/>
</makefile>
</module>
-18
View File
@@ -1,18 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="cam_segment" dir="cam_control">
<doc>
<description>Camera control to point a segment</description>
</doc>
<dep>
<depends>cam_point</depends>
</dep>
<header>
<file name="cam_segment.h"/>
</header>
<init fun="cam_segment_init()"/>
<periodic fun="cam_segment_periodic()" stop="cam_segment_stop()" freq="10." autorun="FALSE"/>
<makefile>
<file name="cam_segment.c"/>
</makefile>
</module>
+30
View File
@@ -0,0 +1,30 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="gimbal_caddx_gm3" dir="cam_control" task="control">
<doc>
<description>
Caddx gm3 gimbal control.
Can be used with actuators SBUS (1 wire) or PWM (multiple wires).
Define a servo named GIMBAL_CADDX_ROLL in airframe to activate roll control.
</description>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="gimbal gm3">
<dl_setting MAX="60." MIN="-60." STEP="1." module="cam_control/gimbal_caddx_gm3" VAR="gimbal_caddx_gm3_roll" shortname="roll" unit="rad" alt_unit="deg"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>cam_gimbal</depends>
</dep>
<header>
<file name="gimbal_caddx_gm3.h"/>
</header>
<init fun="gimbal_caddx_gm3_init()"/>
<periodic fun="gimbal_caddx_gm3_periodic()" freq="10.0"/>
<makefile>
<file name="gimbal_caddx_gm3.c"/>
<test/>
</makefile>
</module>