Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
menschel committed Dec 17, 2024
1 parent 3569c2c commit 7c2441b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
11 changes: 6 additions & 5 deletions libraries/GCS_MAVLink/GCS_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7099,18 +7099,19 @@ bool GCS_MAVLINK::mavlink_coordinate_frame_to_location_alt_frame(const MAV_FRAME
uint64_t GCS_MAVLINK::capabilities() const
{
/**
* Basic capabilities December 2024
* - Param float (already there, not checked)
* Basic capabilities, changed December 2024
* - Param float (obsolete, replaced by param encode c cast, therefore removed)
* - Compass calibration (already there, not checked)
* - Mission Int (added, code is there)
* - Command Int (added, code is there)
* - Set Position Target Global Int (added, code is there, used for guided mode)
* - param encode c cast (added, code is there)
*/
uint64_t ret = MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT |
MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION |
uint64_t ret = MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION |
MAV_PROTOCOL_CAPABILITY_MISSION_INT |
MAV_PROTOCOL_CAPABILITY_COMMAND_INT |
MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT;
MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT |
MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST;

const auto mavlink_protocol = uartstate->get_protocol();
if (mavlink_protocol == AP_SerialManager::SerialProtocol_MAVLink2 || mavlink_protocol == AP_SerialManager::SerialProtocol_MAVLinkHL) {
Expand Down
41 changes: 33 additions & 8 deletions libraries/GCS_MAVLink/MissionItemProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void MissionItemProtocol::init_send_requests(GCS_MAVLINK &_link,

mission_item_warning_sent = false;
mission_request_warning_sent = false;
mission_request_int_warning_sent = false;
}

void MissionItemProtocol::handle_mission_clear_all(const GCS_MAVLINK &_link,
Expand Down Expand Up @@ -227,6 +228,16 @@ void MissionItemProtocol::send_mission_item_warning()
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "got MISSION_ITEM; GCS should send MISSION_ITEM_INT");
}

void MissionItemProtocol::send_mission_request_int_warning()
{
if (mission_request_int_warning_sent) {
return;
}
mission_request_int_warning_sent = true;
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "GCS ignored MISSION_REQUEST_INT; fallback to MISSION_REQUEST");
}


void MissionItemProtocol::handle_mission_write_partial_list(GCS_MAVLINK &_link,
const mavlink_message_t &msg,
const mavlink_mission_write_partial_list_t &packet)
Expand Down Expand Up @@ -315,7 +326,10 @@ void MissionItemProtocol::handle_mission_item(const mavlink_message_t &msg, cons
return;
}
// if we have enough space, then send the next WP request immediately
if (HAVE_PAYLOAD_SPACE(link->get_chan(), MISSION_REQUEST_INT)) {
if (HAVE_PAYLOAD_SPACE(link->get_chan(),
mission_request_int_fallback_to_mission_request ? MISSION_REQUEST : MISSION_REQUEST_INT
)
) {
queued_request_send();
} else {
link->send_message(next_item_ap_message_id());
Expand Down Expand Up @@ -368,13 +382,24 @@ void MissionItemProtocol::queued_request_send()
INTERNAL_ERROR(AP_InternalError::error_t::gcs_bad_missionprotocol_link);
return;
}
CHECK_PAYLOAD_SIZE2_VOID(link->get_chan(), MISSION_REQUEST_INT);
mavlink_msg_mission_request_int_send(
link->get_chan(),
dest_sysid,
dest_compid,
request_i,
mission_type());
if (!mission_request_int_fallback_to_mission_request) {
CHECK_PAYLOAD_SIZE2_VOID(link->get_chan(), MISSION_REQUEST_INT);
mavlink_msg_mission_request_int_send(
link->get_chan(),
dest_sysid,
dest_compid,
request_i,
mission_type());
} else {
CHECK_PAYLOAD_SIZE2_VOID(link->get_chan(), MISSION_REQUEST);
mavlink_msg_mission_request_send(
link->get_chan(),
dest_sysid,
dest_compid,
request_i,
mission_type());
}

timelast_request_ms = AP_HAL::millis();
}

Expand Down
6 changes: 6 additions & 0 deletions libraries/GCS_MAVLink/MissionItemProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ class MissionItemProtocol
// then we issue a warning - once per transfer.
bool mission_item_warning_sent = false;

// if the autopilot sends a mission_request_int to a GCS and runs into a timeout,
// it does fallback to mission_request instead, ...
bool mission_request_int_fallback_to_mission_request = false;
// ... and we issue a warning - once per transfer.
bool mission_request_int_warning_sent = false;

// support for GCS getting waypoints etc from us:
virtual MAV_MISSION_RESULT get_item(const GCS_MAVLINK &_link,
const mavlink_message_t &msg,
Expand Down

0 comments on commit 7c2441b

Please sign in to comment.