diff --git a/libraries/AP_Mount/AP_Mount.h b/libraries/AP_Mount/AP_Mount.h index 1455e7f1ae39fb..fe5efc153ef302 100644 --- a/libraries/AP_Mount/AP_Mount.h +++ b/libraries/AP_Mount/AP_Mount.h @@ -160,6 +160,9 @@ class AP_Mount // this operation requires 60us on a Pixhawk/PX4 void set_mode_to_default() { set_mode_to_default(_primary); } void set_mode_to_default(uint8_t instance); + + //set operating mode, not to be confused with modes like retracted,usually axis locking modes + void set_mount_mode(uint8_t mount_lock_mode); // set yaw_lock used in RC_TARGETING mode. If true, the gimbal's yaw target is maintained in earth-frame meaning it will lock onto an earth-frame heading (e.g. North) // If false (aka "follow") the gimbal's yaw is maintained in body-frame meaning it will rotate with the vehicle diff --git a/libraries/AP_Mount/AP_Mount_Backend.h b/libraries/AP_Mount/AP_Mount_Backend.h index 16082d58f450b5..20738de43f16d2 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.h +++ b/libraries/AP_Mount/AP_Mount_Backend.h @@ -82,6 +82,10 @@ class AP_Mount_Backend // set yaw_lock used in RC_TARGETING mode. If true, the gimbal's yaw target is maintained in earth-frame meaning it will lock onto an earth-frame heading (e.g. North) // If false (aka "follow") the gimbal's yaw is maintained in body-frame meaning it will rotate with the vehicle void set_yaw_lock(bool yaw_lock) { _yaw_lock = yaw_lock; } + + //set operating mode, not to be confused with modes like retracted,usually axis locking modes + void set_mount_mode( uint8_t mount_lock_mode) { _mount_lock_mode = mount_lock_mode; } ; + uint8_t _mount_lock_mode; // set angle target in degrees // roll and pitch are in earth-frame diff --git a/libraries/AP_Mount/AP_Mount_CADDX.cpp b/libraries/AP_Mount/AP_Mount_CADDX.cpp index 331eb6a5f7bf9d..65567ddf069eb6 100644 --- a/libraries/AP_Mount/AP_Mount_CADDX.cpp +++ b/libraries/AP_Mount/AP_Mount_CADDX.cpp @@ -140,7 +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; + 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 f56901052e2bac..2c667847e6e0aa 100644 --- a/libraries/AP_Mount/AP_Mount_CADDX.h +++ b/libraries/AP_Mount/AP_Mount_CADDX.h @@ -46,10 +46,6 @@ 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 d24215d24ff24c..7317b8466f8cad 100644 --- a/libraries/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/RC_Channel.cpp @@ -1759,13 +1759,13 @@ bool RC_Channel::do_aux_function(const AUX_FUNC ch_option, const AuxSwitchPos ch } switch (ch_flag) { case AuxSwitchPos::LOW: - // nothing + mount->set_mount_mode(0); break; case AuxSwitchPos::MIDDLE: - // nothing + // mount->set_mount_mode(1); break; case AuxSwitchPos::HIGH: - //nothing + // mount->set_mount_mode(2); break; } break;