GCS_MAVLink: move handling of get_home_position up

This commit is contained in:
Peter Barker 2018-03-16 14:57:18 +11:00 committed by Randy Mackay
parent 3af4806d38
commit bed3f0c344
2 changed files with 19 additions and 0 deletions

View File

@ -301,6 +301,7 @@ protected:
MAV_RESULT handle_command_camera(const mavlink_command_long_t &packet);
MAV_RESULT handle_command_do_send_banner(const mavlink_command_long_t &packet);
MAV_RESULT handle_command_do_set_mode(const mavlink_command_long_t &packet);
MAV_RESULT handle_command_get_home_position(const mavlink_command_long_t &packet);
// vehicle-overridable message send function
virtual bool try_send_message(enum ap_message id);

View File

@ -2124,6 +2124,20 @@ MAV_RESULT GCS_MAVLINK::handle_command_do_set_mode(const mavlink_command_long_t
return _set_mode_common(base_mode, custom_mode);
}
MAV_RESULT GCS_MAVLINK::handle_command_get_home_position(const mavlink_command_long_t &packet)
{
if (!AP::ahrs().home_is_set()) {
return MAV_RESULT_FAILED;
}
send_home(AP::ahrs().get_home());
Location ekf_origin;
if (AP::ahrs().get_origin(ekf_origin)) {
send_ekf_origin(ekf_origin);
}
return MAV_RESULT_ACCEPTED;
}
MAV_RESULT GCS_MAVLINK::handle_command_long_message(mavlink_command_long_t &packet)
{
MAV_RESULT result = MAV_RESULT_FAILED;
@ -2167,6 +2181,10 @@ MAV_RESULT GCS_MAVLINK::handle_command_long_message(mavlink_command_long_t &pack
break;
}
case MAV_CMD_GET_HOME_POSITION:
result = handle_command_get_home_position(packet);
break;
case MAV_CMD_PREFLIGHT_STORAGE:
if (is_equal(packet.param1, 2.0f)) {
AP_Param::erase_all();