mirror of https://github.com/ArduPilot/ardupilot
APM: fixed fetch of relative altitude waypoints
when we fetch relative altitude waypoints from APM to a file, we need to preserve the altitude
This commit is contained in:
parent
90b74f5bab
commit
e2779523ea
|
@ -1191,7 +1191,7 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
|||
break;
|
||||
|
||||
// send waypoint
|
||||
tell_command = get_cmd_with_index(packet.seq);
|
||||
tell_command = get_cmd_with_index_raw(packet.seq);
|
||||
|
||||
// set frame of waypoint
|
||||
uint8_t frame;
|
||||
|
@ -1218,11 +1218,7 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
|||
// command needs scaling
|
||||
x = tell_command.lat/1.0e7; // local (x), global (latitude)
|
||||
y = tell_command.lng/1.0e7; // local (y), global (longitude)
|
||||
if ((tell_command.options & MASK_OPTIONS_RELATIVE_ALT) && tell_command.id != MAV_CMD_NAV_TAKEOFF) {
|
||||
z = (tell_command.alt - home.alt) / 1.0e2; // because tell_command.alt already includes a += home.alt
|
||||
} else {
|
||||
z = tell_command.alt/1.0e2; // local (z), global/relative (altitude)
|
||||
}
|
||||
z = tell_command.alt/1.0e2;
|
||||
}
|
||||
|
||||
switch (tell_command.id) { // Switch to map APM command fields inot MAVLink command fields
|
||||
|
|
|
@ -38,9 +38,10 @@ static void reload_commands_airstart()
|
|||
decrement_cmd_index();
|
||||
}
|
||||
|
||||
// Getters
|
||||
// -------
|
||||
static struct Location get_cmd_with_index(int16_t i)
|
||||
/*
|
||||
fetch a mission item from EEPROM
|
||||
*/
|
||||
static struct Location get_cmd_with_index_raw(int16_t i)
|
||||
{
|
||||
struct Location temp;
|
||||
uint16_t mem;
|
||||
|
@ -71,6 +72,18 @@ static struct Location get_cmd_with_index(int16_t i)
|
|||
temp.lng = (long)eeprom_read_dword((uint32_t*)(uintptr_t)mem);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/*
|
||||
fetch a mission item from EEPROM. Adjust altitude to be absolute
|
||||
*/
|
||||
static struct Location get_cmd_with_index(int16_t i)
|
||||
{
|
||||
struct Location temp;
|
||||
|
||||
temp = get_cmd_with_index_raw(i);
|
||||
|
||||
// Add on home altitude if we are a nav command (or other command with altitude) and stored alt is relative
|
||||
if ((temp.id < MAV_CMD_NAV_LAST || temp.id == MAV_CMD_CONDITION_CHANGE_ALT) &&
|
||||
(temp.options & MASK_OPTIONS_RELATIVE_ALT) &&
|
||||
|
@ -90,7 +103,7 @@ static void set_cmd_with_index(struct Location temp, int16_t i)
|
|||
|
||||
// Set altitude options bitmask
|
||||
// XXX What is this trying to do?
|
||||
if (temp.options & MASK_OPTIONS_RELATIVE_ALT && i != 0) {
|
||||
if ((temp.options & MASK_OPTIONS_RELATIVE_ALT) && i != 0) {
|
||||
temp.options = MASK_OPTIONS_RELATIVE_ALT;
|
||||
} else {
|
||||
temp.options = 0;
|
||||
|
|
Loading…
Reference in New Issue