Misleading message "Flight plan update rejected" and possible bug in mission count/mission partial list

Hi,
I’m sending a list of mission items to ArduPlane from a companion computer. Everything seems to work, but I’m a bit confused by the warning message I get from AP, so I’m wondering if my understanding is wrong or if the warning message is missleading and there might be a bug in the mission count pack/write partial list interaction.

The scenario (Mostly in GCS_MAVLink/GCS_Common.cpp):

  1. I send a mission count pack, which indicates that my mission has 4 mission items. This results in AP setting waypoint_receiving = true, waypoint_request_i = 0, waypoint_request_last = count (which is 4). But mission.num_command() remains unchanged (0 (at startup), and not 4, since mission.truncate does not extend the size of the mission, it only shortens it if count > num_commands)
  2. I send a write partial list message, with start=0 end=4. Since end>num_commands this only has the effect that a message saying “Flight plan update rejected” is returned. I.e. the start and end indexes are discarded, and waypoint_request_i/last are not updated.
  3. since wp_receiving was set to true in step 1, GCS_MAVLINK::update will send MSG_NEXT_WP, which will request a mission item with seq=waypoint_request_i.
  4. I respond to the mission request by sending the correspoinding mission item back, which is handled by AP in handle_mission_item, which requests a new item or acknowledges the mission upon completion of the transfer (Also sending positive feedback “Flight plan received”)

So: is my understanding correct? If so, I think that the “Flight plan update rejected” message is misleading, since the flight plan is in fact updated. Also; given the above, write partial list seems superfluous when sending a mission that is larger than the current mission, as start/end is discarded, making it impossible to only update a part of the plan.

Appreciate any thoughts/inputs,
Kristoffer

Anyone? :slight_smile: Did I post this in the wrong category, or is there anything else I can do to get any response on this?

Thanks,
Kristoffer

Shouldn’t that be end=3?

Thanks for you reply :slight_smile:
I agree that start=0,end=3 would make more sense for a plan of size 4. However, when I set end=3 my last mission item (#3) is never requested. So this is also strange. Also, I still get the “Flight plan update rejected” message since end>num_commands (which is 0 at startup). Below is an excerpt from my code, where I send the mission_count_pack and mission_write_partial_list_pack, and add the mission items to a queue so that it can be requested by AP later:

            int seq = 0;

// Add mission items to a queue, and make ArduPilot request this,
// by answering with a mission request message
mavlink_msg_mission_count_pack(255, 0, &msg,
							   m_sysid, //! target_system System ID
							   0, //! target_component Component ID
							   4); //! size of Mission

n = mavlink_msg_to_send_buffer(buf, &msg);
sendData(buf, n);

// inform AP of the start/end index of the wps we intend to send
mavlink_msg_mission_write_partial_list_pack(255, 0, &msg,
											m_sysid, //! target_system System ID
											0, //! target_component Component ID
											seq, //! start_index Start index, 0 by default and smaller / equal to the largest index of the current onboard list
											seq+3); //! end_index End index, equal or greater than start index

n = mavlink_msg_to_send_buffer(buf, &msg);
sendData(buf, n);

After this, I generate 4 mission_item_pack messages, that are added to a queue to be sent to AP later. The first mission_item is HOME, the second and third are the start and end of the line I would like to follow, and the fourth is an unlimited loiter placed some safety distance after the end of the line along the line (primarily a safety feature). The complete plan (consisting of lines to follow) is saved/generated on my companion computer, so all of this is run upon completion of a WP, so that the next line can be followed. This is to be able to do planning/replanning.
To be clear: the plan rejection only happens when the new plan is larger than the previous one, so after startup things generally go without problems.

Here are two logs that show this (end3.BIN and end4.BIN, with end=3 and 4 respectively). Please note that I have, for debugging purposes, changed the “Flight plan update rejected”-message to “F pln rejs: 0 e: 4n 3mn 724”, where “s: 0” is the start. “e: 4” is the end, “n 3” is the current length of the mission (mission.num_command()) and “mn 724” is mission.num_command_max().

Kristoffer

Could you test against my PR branch here, please:

I’m reasonably confident of the tests I have against that branch.

Thanks for you reply :slight_smile:
I agree that start=0,end=3 would make more sense for a plan of size 4. However, when I set end=3 my last mission item (#3) is never requested. So this is
also strange. Also, I still get the “Flight plan update rejected” message since end>num_commands (which is 0 at startup). Below is an excerpt from my
code, where I send the mission_count_pack and mission_write_partial_list_pack, and add the mission items to a queue so that it can be requested by AP
later:

Ah… you do realise that you send one of mission_count of
write_partial_list, right? If you send up a count you don’t need to send
the write_partial_list - just answer the requests as they come in.

Appreciate your answer, Peter. I think you are correct; there is probably something that I do not completely understand.

I have now tested it against your PR-branch, with the same outcome: “Flight plan update rejected” when I send the first plan. (The same outcome with respect to what we discussed above at least. I was not able to take off, but that is probably just effects of an old JSBsim et al)

A follow up question to you: How can I add a new mission_item at the end of (aka after) the current mission? Lets say I have 3 WPs and want to add a 4th. So I send write_partial_list with start=4 and end=4, but this will fail since start and end are greater than the current mission size (end>mission.num_commands()). The only way to extend the mission size is through add_cmd, which is called in handle_mission_item if we are receiving, seq == request_i and seq == mission.num_commands(), but this will never be the case for write_partial_list, as it is rejected when start or end > num_commands. So I guess I could start by uploading a dummy plan (to simply set num_commands high), and then updating the wps as I go along, but this seems like a hack. I could also keep track of the entire plan on my side, and re-send the entire plan (with the new wp added to the end), but this seems like a waste of communication. Am I still misunderstanding something, or is this not an intended use-case?

A related question: Is it possible to update a passed wp and/or the current wp? The goal is to track a line where the start and end point are slowly moving. I guess I could update the entire plan (past and current wp) with mission_count, and make sure that the current wp is stil set as current_wp? Could I also do this with write partial list?

Thanks,
Kristoffer

seems like a hack. I could also keep track of the entire plan on my side, and re-send the entire plan (with the new wp added to the end), but this seems
like a waste of communication. Am I still misunderstanding something, or is this not an intended use-case?

I think that’s currently your only option, sadly.

A related question: Is it possible to update a passed wp and/or the current wp? The goal is to track a line where the start and end point are slowly
moving. I guess I could update the entire plan (past and current wp) with mission_count, and make sure that the current wp is stil set as current_wp?
Could I also do this with write partial list?

Probably not as the current waypoint’s location has probably been copied
out of the mission into several other places…

Kristoffer

Peter