Browse Source

GCS_MAVLink: move common mission handling up to GCS_MAVLINK

mission-4.1.18
Peter Barker 8 years ago committed by Francisco Ferreira
parent
commit
726007efde
  1. 6
      libraries/GCS_MAVLink/GCS.h
  2. 85
      libraries/GCS_MAVLink/GCS_Common.cpp

6
libraries/GCS_MAVLink/GCS.h

@ -227,7 +227,8 @@ protected: @@ -227,7 +227,8 @@ protected:
// overridable method to check for packet acceptance. Allows for
// enforcement of GCS sysid
virtual bool accept_packet(const mavlink_status_t &status, mavlink_message_t &msg) { return true; }
virtual AP_Mission *get_mission() = 0;
bool waypoint_receiving; // currently receiving
// the following two variables are only here because of Tracker
uint16_t waypoint_request_i; // request index
@ -248,7 +249,7 @@ protected: @@ -248,7 +249,7 @@ protected:
void handle_mission_request_list(AP_Mission &mission, mavlink_message_t *msg);
void handle_mission_request(AP_Mission &mission, mavlink_message_t *msg);
void handle_mission_clear_all(AP_Mission &mission, mavlink_message_t *msg);
void handle_mission_set_current(AP_Mission &mission, mavlink_message_t *msg);
virtual void handle_mission_set_current(AP_Mission &mission, mavlink_message_t *msg);
void handle_mission_count(AP_Mission &mission, mavlink_message_t *msg);
void handle_mission_write_partial_list(AP_Mission &mission, mavlink_message_t *msg);
bool handle_mission_item(mavlink_message_t *msg, AP_Mission &mission);
@ -391,6 +392,7 @@ private: @@ -391,6 +392,7 @@ private:
virtual bool handle_guided_request(AP_Mission::Mission_Command &cmd) = 0;
virtual void handle_change_alt_request(AP_Mission::Mission_Command &cmd) = 0;
void handle_common_mission_message(mavlink_message_t *msg);
void lock_channel(mavlink_channel_t chan, bool lock);

85
libraries/GCS_MAVLink/GCS_Common.cpp

@ -1762,6 +1762,91 @@ void GCS_MAVLINK::handle_common_message(mavlink_message_t *msg) @@ -1762,6 +1762,91 @@ void GCS_MAVLINK::handle_common_message(mavlink_message_t *msg)
case MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS:
DataFlash_Class::instance()->handle_mavlink_msg(*this, msg);
break;
case MAVLINK_MSG_ID_MISSION_REQUEST_LIST:
/* fall through */
case MAVLINK_MSG_ID_MISSION_COUNT:
/* fall through */
case MAVLINK_MSG_ID_MISSION_CLEAR_ALL:
/* fall through */
case MAVLINK_MSG_ID_MISSION_ITEM:
/* fall through */
case MAVLINK_MSG_ID_MISSION_ITEM_INT:
/* fall through */
case MAVLINK_MSG_ID_MISSION_REQUEST_INT:
/* fall through */
case MAVLINK_MSG_ID_MISSION_REQUEST:
/* fall through */
case MAVLINK_MSG_ID_MISSION_ACK:
/* fall through */
case MAVLINK_MSG_ID_MISSION_SET_CURRENT:
handle_common_mission_message(msg);
break;
}
}
void GCS_MAVLINK::handle_common_mission_message(mavlink_message_t *msg)
{
AP_Mission *_mission = get_mission();
if (_mission == nullptr) {
return;
}
switch (msg->msgid) {
case MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST: // MAV ID: 38
{
handle_mission_write_partial_list(*_mission, msg);
break;
}
// GCS has sent us a mission item, store to EEPROM
case MAVLINK_MSG_ID_MISSION_ITEM: // MAV ID: 39
case MAVLINK_MSG_ID_MISSION_ITEM_INT:
{
if (handle_mission_item(msg, *_mission)) {
DataFlash_Class::instance()->Log_Write_EntireMission(*_mission);
}
break;
}
// read an individual command from EEPROM and send it to the GCS
case MAVLINK_MSG_ID_MISSION_REQUEST_INT:
case MAVLINK_MSG_ID_MISSION_REQUEST: // MAV ID: 40, 51
{
handle_mission_request(*_mission, msg);
break;
}
case MAVLINK_MSG_ID_MISSION_SET_CURRENT: // MAV ID: 41
{
handle_mission_set_current(*_mission, msg);
break;
}
// GCS request the full list of commands, we return just the number and leave the GCS to then request each command individually
case MAVLINK_MSG_ID_MISSION_REQUEST_LIST: // MAV ID: 43
{
handle_mission_request_list(*_mission, msg);
break;
}
// GCS provides the full number of commands it wishes to upload
// individual commands will then be sent from the GCS using the MAVLINK_MSG_ID_MISSION_ITEM message
case MAVLINK_MSG_ID_MISSION_COUNT: // MAV ID: 44
{
handle_mission_count(*_mission, msg);
break;
}
case MAVLINK_MSG_ID_MISSION_CLEAR_ALL: // MAV ID: 45
{
handle_mission_clear_all(*_mission, msg);
break;
}
case MAVLINK_MSG_ID_MISSION_ACK:
/* not used */
break;
}
}

Loading…
Cancel
Save