From 67f2adc7c3db44eb61fe3d97b7ec7c97416e88b2 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 24 Aug 2023 10:10:29 +1000 Subject: [PATCH 1/3] AP_Mount: add build options for deprecated messages MOUNT_CONTROL/MOUNT_CONFIGURE these are repalced by the command equivalents --- libraries/AP_Mount/AP_Mount.cpp | 8 ++++++++ libraries/AP_Mount/AP_Mount.h | 5 +++++ libraries/AP_Mount/AP_Mount_Backend.cpp | 4 ++++ libraries/AP_Mount/AP_Mount_Backend.h | 6 +++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index 1d2288b0daab0d..5656b35a87df81 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -532,6 +532,7 @@ void AP_Mount::handle_global_position_int(const mavlink_message_t &msg) } } +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED /// Change the configuration of the mount void AP_Mount::handle_mount_configure(const mavlink_message_t &msg) { @@ -546,7 +547,9 @@ void AP_Mount::handle_mount_configure(const mavlink_message_t &msg) // send message to backend backend->handle_mount_configure(packet); } +#endif +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED /// Control the mount (depends on the previously set mount configuration) void AP_Mount::handle_mount_control(const mavlink_message_t &msg) { @@ -561,6 +564,7 @@ void AP_Mount::handle_mount_control(const mavlink_message_t &msg) // send message to backend backend->handle_mount_control(packet); } +#endif // send a GIMBAL_DEVICE_ATTITUDE_STATUS message to GCS void AP_Mount::send_gimbal_device_attitude_status(mavlink_channel_t chan) @@ -863,12 +867,16 @@ void AP_Mount::handle_message(mavlink_channel_t chan, const mavlink_message_t &m case MAVLINK_MSG_ID_GIMBAL_REPORT: handle_gimbal_report(chan, msg); break; +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED case MAVLINK_MSG_ID_MOUNT_CONFIGURE: handle_mount_configure(msg); break; +#endif +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED case MAVLINK_MSG_ID_MOUNT_CONTROL: handle_mount_control(msg); break; +#endif case MAVLINK_MSG_ID_GLOBAL_POSITION_INT: handle_global_position_int(msg); break; diff --git a/libraries/AP_Mount/AP_Mount.h b/libraries/AP_Mount/AP_Mount.h index 7030695728783b..2260d80352b83c 100644 --- a/libraries/AP_Mount/AP_Mount.h +++ b/libraries/AP_Mount/AP_Mount.h @@ -23,6 +23,7 @@ #if HAL_MOUNT_ENABLED +#include #include #include #include @@ -275,8 +276,12 @@ class AP_Mount AP_Mount_Backend *get_instance(uint8_t instance) const; void handle_gimbal_report(mavlink_channel_t chan, const mavlink_message_t &msg); +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED void handle_mount_configure(const mavlink_message_t &msg); +#endif +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED void handle_mount_control(const mavlink_message_t &msg); +#endif MAV_RESULT handle_command_do_mount_configure(const mavlink_command_int_t &packet); MAV_RESULT handle_command_do_mount_control(const mavlink_command_int_t &packet); diff --git a/libraries/AP_Mount/AP_Mount_Backend.cpp b/libraries/AP_Mount/AP_Mount_Backend.cpp index 8d61eeef414c7f..d0e71daffc8466 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.cpp +++ b/libraries/AP_Mount/AP_Mount_Backend.cpp @@ -108,11 +108,13 @@ void AP_Mount_Backend::set_target_sysid(uint8_t sysid) set_mode(MAV_MOUNT_MODE_SYSID_TARGET); } +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED // process MOUNT_CONFIGURE messages received from GCS. deprecated. void AP_Mount_Backend::handle_mount_configure(const mavlink_mount_configure_t &packet) { set_mode((MAV_MOUNT_MODE)packet.mount_mode); } +#endif // send a GIMBAL_DEVICE_ATTITUDE_STATUS message to GCS void AP_Mount_Backend::send_gimbal_device_attitude_status(mavlink_channel_t chan) @@ -212,6 +214,7 @@ void AP_Mount_Backend::send_gimbal_manager_status(mavlink_channel_t chan) 0); // secondary control component id } +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED // process MOUNT_CONTROL messages received from GCS. deprecated. void AP_Mount_Backend::handle_mount_control(const mavlink_mount_control_t &packet) { @@ -247,6 +250,7 @@ void AP_Mount_Backend::handle_mount_control(const mavlink_mount_control_t &packe break; } } +#endif // handle do_mount_control command. Returns MAV_RESULT_ACCEPTED on success MAV_RESULT AP_Mount_Backend::handle_command_do_mount_control(const mavlink_command_int_t &packet) diff --git a/libraries/AP_Mount/AP_Mount_Backend.h b/libraries/AP_Mount/AP_Mount_Backend.h index 61b0e3dff3c5ce..7e5563f44e210b 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.h +++ b/libraries/AP_Mount/AP_Mount_Backend.h @@ -99,12 +99,16 @@ class AP_Mount_Backend // handle do_gimbal_manager_configure. Returns MAV_RESULT_ACCEPTED on success // requires original message in order to extract caller's sysid and compid MAV_RESULT handle_command_do_gimbal_manager_configure(const mavlink_command_int_t &packet, const mavlink_message_t &msg); - + +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED // process MOUNT_CONFIGURE messages received from GCS. deprecated. void handle_mount_configure(const mavlink_mount_configure_t &msg); +#endif +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED // process MOUNT_CONTROL messages received from GCS. deprecated. void handle_mount_control(const mavlink_mount_control_t &packet); +#endif // send a GIMBAL_DEVICE_ATTITUDE_STATUS message to GCS void send_gimbal_device_attitude_status(mavlink_channel_t chan); From 8a0edbaac6fa46c506b63338efd237b9bf18abe9 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 24 Aug 2023 10:10:29 +1000 Subject: [PATCH 2/3] GCS_MAVLink: add build options for deprecated messages MOUNT_CONTROL/MOUNT_CONFIGURE these are repalced by the command equivalents --- libraries/GCS_MAVLink/GCS_Common.cpp | 4 ++++ libraries/GCS_MAVLink/GCS_config.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 7d9f38f5b82072..cd59cbb78220a9 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -3948,14 +3948,18 @@ void GCS_MAVLINK::handle_common_message(const mavlink_message_t &msg) #endif #if HAL_MOUNT_ENABLED +#if AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED case MAVLINK_MSG_ID_MOUNT_CONFIGURE: // deprecated. Use MAV_CMD_DO_MOUNT_CONFIGURE send_received_message_deprecation_warning("MOUNT_CONFIGURE"); handle_mount_message(msg); break; +#endif +#if AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED case MAVLINK_MSG_ID_MOUNT_CONTROL: // deprecated. Use MAV_CMD_DO_MOUNT_CONTROL send_received_message_deprecation_warning("MOUNT_CONTROL"); handle_mount_message(msg); break; +#endif case MAVLINK_MSG_ID_GIMBAL_REPORT: case MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION: case MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS: diff --git a/libraries/GCS_MAVLink/GCS_config.h b/libraries/GCS_MAVLink/GCS_config.h index cea11e107c8ae5..28e8ddd22a5355 100644 --- a/libraries/GCS_MAVLink/GCS_config.h +++ b/libraries/GCS_MAVLink/GCS_config.h @@ -53,3 +53,11 @@ #ifndef AP_MAVLINK_RALLY_POINT_PROTOCOL_ENABLED #define AP_MAVLINK_RALLY_POINT_PROTOCOL_ENABLED HAL_GCS_ENABLED && HAL_RALLY_ENABLED #endif + +#ifndef AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED +#define AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED HAL_GCS_ENABLED +#endif + +#ifndef AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED +#define AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED HAL_GCS_ENABLED +#endif From a0ccf6dca2c93b1df528b61e588de94f1d2891de Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 24 Aug 2023 10:10:29 +1000 Subject: [PATCH 3/3] Tools: add build options for deprecated messages MOUNT_CONTROL/MOUNT_CONFIGURE these are repalced by the command equivalents --- Tools/scripts/build_options.py | 2 ++ Tools/scripts/extract_features.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Tools/scripts/build_options.py b/Tools/scripts/build_options.py index 1ab62da3d8f47b..119857db0f6560 100644 --- a/Tools/scripts/build_options.py +++ b/Tools/scripts/build_options.py @@ -298,6 +298,8 @@ def __init__(self, Feature('MAVLink', 'AP_MAVLINK_AUTOPILOT_VERSION_REQUEST_ENABLED', 'AP_MAVLINK_AUTOPILOT_VERSION_REQUEST_ENABLED', 'Enable old AUTOPILOT_VERSION_REQUEST mesage', 0, None), # noqa Feature('MAVLink', 'AP_MAVLINK_MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES_ENABLED', 'AP_MAVLINK_MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES_ENABLED', 'Enable old REQUEST_AUTOPILOT_CAPABILITIES command', 0, None), # noqa Feature('MAVLink', 'AP_MAVLINK_MSG_RELAY_STATUS_ENABLED', 'AP_MAVLINK_MSG_RELAY_STATUS_ENABLED', 'Enable sending of RELAY_STATUS message', 0, 'RELAY'), # noqa + Feature('MAVLink', 'AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED', 'AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED', 'Enable handling of deprecated MOUNT_CONTROL message', 0, None), # noqa + Feature('MAVLink', 'AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED', 'AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED', 'Enable handling of deprecated MOUNT_CONFIGURE message', 0, None), # noqa Feature('MAVLink', 'AP_MAVLINK_BATTERY2_ENABLED', 'AP_MAVLINK_BATTERY2_ENABLED', 'Enable sending of old BATTERY2 message', 0, None), # noqa Feature('Developer', 'KILL_IMU', 'AP_INERTIALSENSOR_KILL_IMU_ENABLED', 'Allow IMUs to be disabled at runtime', 0, None), diff --git a/Tools/scripts/extract_features.py b/Tools/scripts/extract_features.py index 1b770be5ab3415..55f31e566e60ae 100755 --- a/Tools/scripts/extract_features.py +++ b/Tools/scripts/extract_features.py @@ -210,6 +210,8 @@ def __init__(self, filename, nm="arm-none-eabi-nm"): ('AP_MAVLINK_MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES_ENABLED', 'GCS_MAVLINK::handle_command_request_autopilot_capabilities'), # noqa ('AP_MAVLINK_MSG_RELAY_STATUS_ENABLED', 'GCS_MAVLINK::send_relay_status'), ('AP_MAVLINK_BATTERY2_ENABLED', 'GCS_MAVLINK::send_battery2'), + ('AP_MAVLINK_MSG_MOUNT_CONTROL_ENABLED', 'AP_Mount::handle_mount_control'), + ('AP_MAVLINK_MSG_MOUNT_CONFIGURE_ENABLED', 'AP_Mount::handle_mount_configure'), ] def progress(self, msg):