From 0e2abb27fd71d3d26e39d12652cdec345e997470 Mon Sep 17 00:00:00 2001 From: Henry Wurzburg Date: Fri, 18 Oct 2024 07:50:20 -0500 Subject: [PATCH] wip3 --- libraries/AP_Mount/AP_Mount_CADDX.cpp | 1 + libraries/AP_Mount/AP_Mount_CADDX.h | 4 ++++ libraries/RC_Channel/RC_Channel.cpp | 22 ++++++++++++++++++++++ libraries/RC_Channel/RC_Channel.h | 1 + 4 files changed, 28 insertions(+) diff --git a/libraries/AP_Mount/AP_Mount_CADDX.cpp b/libraries/AP_Mount/AP_Mount_CADDX.cpp index 374ea89f5684e9..331eb6a5f7bf9d 100644 --- a/libraries/AP_Mount/AP_Mount_CADDX.cpp +++ b/libraries/AP_Mount/AP_Mount_CADDX.cpp @@ -140,6 +140,7 @@ void AP_Mount_CADDX::send_target_angles(const MountTarget& angle_target_rad) //todo: add mode here cmd_set_angles_data.mode = GIMBAL_MODE_TILT_ROLL_LOCK; + cmd_set_angles_data.mode = mount_lock_mode; // CRC here uint16_t crc16 = 0; diff --git a/libraries/AP_Mount/AP_Mount_CADDX.h b/libraries/AP_Mount/AP_Mount_CADDX.h index cc68b71e8fc977..f56901052e2bac 100644 --- a/libraries/AP_Mount/AP_Mount_CADDX.h +++ b/libraries/AP_Mount/AP_Mount_CADDX.h @@ -45,6 +45,10 @@ class AP_Mount_CADDX : public AP_Mount_Backend_Serial // has_pitch_control - returns true if this mount can control its tilt bool has_pitch_control() const override { return pitch_range_valid(); }; + + void set_mount_mode(const uint8_t mount_lock_mode); + + uint8_t mount_lock_mode; protected: diff --git a/libraries/RC_Channel/RC_Channel.cpp b/libraries/RC_Channel/RC_Channel.cpp index 4b4f30d79e2883..d24215d24ff24c 100644 --- a/libraries/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/RC_Channel.cpp @@ -242,6 +242,7 @@ const AP_Param::GroupInfo RC_Channel::var_info[] = { // @Values{Copter}: 178:FlightMode Pause/Resume // @Values{Plane}: 179:ICEngine start / stop // @Values{Copter, Plane}: 180:Test autotuned gains after tune is complete + // @values{Copter,Plane,Rover,Blimp}: 181:Mount Mode // @Values{Rover}: 201:Roll // @Values{Rover}: 202:Pitch // @Values{Rover}: 207:MainSail @@ -756,6 +757,7 @@ void RC_Channel::init_aux_function(const AUX_FUNC ch_option, const AuxSwitchPos case AUX_FUNC::RETRACT_MOUNT1: case AUX_FUNC::RETRACT_MOUNT2: case AUX_FUNC::MOUNT_LOCK: + case AUX_FUNC::MOUNT_MODE: #endif #if HAL_LOGGING_ENABLED case AUX_FUNC::LOG_PAUSE: @@ -891,6 +893,7 @@ const RC_Channel::LookupTable RC_Channel::lookuptable[] = { #endif #if HAL_MOUNT_ENABLED { AUX_FUNC::MOUNT_LRF_ENABLE, "Mount LRF Enable"}, + { AUX_FUNC::MOUNT_MODE, "Mount Mode"}, #endif }; @@ -1748,6 +1751,25 @@ bool RC_Channel::do_aux_function(const AUX_FUNC ch_option, const AuxSwitchPos ch mount->set_rangefinder_enable(0, ch_flag == AuxSwitchPos::HIGH); break; } + + case AUX_FUNC::MOUNT_MODE:{ + AP_Mount *mount = AP::mount(); + if (mount == nullptr) { + break; + } + switch (ch_flag) { + case AuxSwitchPos::LOW: + // nothing + break; + case AuxSwitchPos::MIDDLE: + // nothing + break; + case AuxSwitchPos::HIGH: + //nothing + break; + } + break; + } #endif #if HAL_LOGGING_ENABLED diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 1ad2e284a6ad43..84762f5e81ea8c 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -260,6 +260,7 @@ class RC_Channel { FLIGHTMODE_PAUSE = 178, // e.g. pause movement towards waypoint ICE_START_STOP = 179, // AP_ICEngine start stop AUTOTUNE_TEST_GAINS = 180, // auto tune tuning switch to test or revert gains + MOUNT_MODE = 181, //mount operating mode // inputs from 200 will eventually used to replace RCMAP