From 38ea1b40392a1b10c2db3b60544c1567178a5b3b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 22 Nov 2022 14:40:31 +1100 Subject: [PATCH] Rover: factor out handle_manual_control_axes --- Rover/GCS_Mavlink.cpp | 22 +--------------------- Rover/GCS_Mavlink.h | 2 +- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Rover/GCS_Mavlink.cpp b/Rover/GCS_Mavlink.cpp index 49592abcdb..261ba9c760 100644 --- a/Rover/GCS_Mavlink.cpp +++ b/Rover/GCS_Mavlink.cpp @@ -769,9 +769,6 @@ MAV_RESULT GCS_MAVLINK_Rover::handle_command_int_do_reposition(const mavlink_com void GCS_MAVLINK_Rover::handleMessage(const mavlink_message_t &msg) { switch (msg.msgid) { - case MAVLINK_MSG_ID_MANUAL_CONTROL: - handle_manual_control(msg); - break; case MAVLINK_MSG_ID_SET_ATTITUDE_TARGET: handle_set_attitude_target(msg); @@ -796,27 +793,10 @@ void GCS_MAVLINK_Rover::handleMessage(const mavlink_message_t &msg) } } -void GCS_MAVLINK_Rover::handle_manual_control(const mavlink_message_t &msg) +void GCS_MAVLINK_Rover::handle_manual_control_axes(const mavlink_manual_control_t &packet, const uint32_t tnow) { - if (msg.sysid != rover.g.sysid_my_gcs) { // Only accept control from our gcs - return; - } - - mavlink_manual_control_t packet; - mavlink_msg_manual_control_decode(&msg, &packet); - - if (packet.target != rover.g.sysid_this_mav) { - return; // only accept control aimed at us - } - - uint32_t tnow = AP_HAL::millis(); - manual_override(rover.channel_steer, packet.y, 1000, 2000, tnow); manual_override(rover.channel_throttle, packet.z, 1000, 2000, tnow); - - // a manual control message is considered to be a 'heartbeat' from - // the ground station for failsafe purposes - gcs().sysid_myggcs_seen(tnow); } void GCS_MAVLINK_Rover::handle_set_attitude_target(const mavlink_message_t &msg) diff --git a/Rover/GCS_Mavlink.h b/Rover/GCS_Mavlink.h index dab366b730..8f1bd02885 100644 --- a/Rover/GCS_Mavlink.h +++ b/Rover/GCS_Mavlink.h @@ -37,7 +37,7 @@ private: bool handle_guided_request(AP_Mission::Mission_Command &cmd) override; bool try_send_message(enum ap_message id) override; - void handle_manual_control(const mavlink_message_t &msg); + void handle_manual_control_axes(const mavlink_manual_control_t &packet, const uint32_t tnow) override; void handle_set_attitude_target(const mavlink_message_t &msg); void handle_set_position_target_local_ned(const mavlink_message_t &msg); void handle_set_position_target_global_int(const mavlink_message_t &msg);