-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement new mission opaque ID protocol #20834
base: master
Are you sure you want to change the base?
Conversation
Relevant discussion: mavlink/mavlink#1171 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need GCS implementation and testing
|
||
checksum = 0; | ||
const uint16_t count = mission.num_commands(); | ||
for (uint16_t i=1; i<count; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment on time to run on a F427 with at least 500 WPs.
@peterbarker When do you plan on running a test(s) with many waypoints to evaluate the cost of this operation? A checksum generated on the vehicle is logically the safest way to check missions match, so if this is feasible, it would be a good thing to do. It also depends on how long it takes/whether it might be done in the background. While we'd like an instant update of mission changed, it it took 10 seconds, I'm not sure that this would be the end of the world if this was well understood by implementers. If not, it would be good to know so we can look at other alternatives that meet the same use case. Various ideas have floated around:
We didn't like those options as much because we didn't want to mess with the existing mission items or mission messages, and because using a checksum means that you know two mission/plans are the same without having to trust some data stored in the mission. But if we need to look at these approaches it would be better to know sooner rather than later. |
That's obviously not something we can do in the main thread! That's going to complicate the implementation. Should be feasible to do the calculation in a thread - I'll see how it looks. |
7054e46
to
8d53ee0
Compare
I've modified MAVProxy and pymavlink to use the checksum feature to avoid uploading a mission if it is identical to the one on the vehicle: ArduPilot/MAVProxy#1104
|
8d53ee0
to
61b7d38
Compare
The patches in here are now updating the checksum progressively to avoid the scheduling problems. |
@hamishwillee we discussed this in today's DevCall. This is now end--to-end working. We're not sure of the utility of this in the face of mission-transfer-via-ftp, however. Could you summarize the arguments for this feature, please? |
61b7d38
to
1fe2fd1
Compare
Thanks for taking the time to do this work. MISSION_CHECKSUM is what tells you that the mission, geofence or rally point is different or has changed on the vehicle and needs to be re-synced. Using MAVFTP to upload/download a mission is a lot more efficient than the standard protocol, but:
MAVFTP is great if you only have a single GCS and Vehicle that might affect plans. It's fast enough that on connection you might just decide that you'll either swamp the vehicle mission, or upload the vehicle mission. Upshot,
|
@hamishwillee there should not be a tie between the GCS checksum and autopilot checksum. The checksums just won't match for ArduPilot, as we don't store all the mission item fields in ArduPilot, so the checksum calculated on the GCS for a mission file will not match the one from the autopilot. |
@tridge Thanks very much. That's disappointing. There's an additional complication; if the GCS can't infer the same checksum then it can't know that a particular emitted checksum is the result of a mission it just uploaded. Therefore it would have no way of knowing the checksum matched it. To meet the use case of knowing "has the mission changed" either:
I kind of like option 2 because
The rest of the process could be the same. Might that work? Re option 1 I'm not sure how you'd inform the GCS that it was from "X" system/component ID, and I'm not sure if you're using an opaque checksum of the autopilot mission you might not be just better off using UUIDs. |
It does seem that this is "poor mans signing". For commercial/secure applications, the ideal solution is that the mission should be able to be cryptographically signed on the GCS and the signature validated on the autopilot. If there are data or algorithm issues with this, then those issues should be solved. This is the utopian solution, but the only way in the end to securely, reliably and completely solve the problem. |
@timtuxworth The proposal and use case has nothing to do with signing (at least for me). It is merely a way to allow any system on the network that is interested in the plan on the vehicle to know if it has a matching version or needs to update. I'm not convinced of the value of a signed mission plan. If there is a need for the drone to only accept trusted plans wouldn't it make more sense to establish trust with the supplier and supplying channel than overlay this requirement on any (every) particular data you want to share? If you @tridge @peterbarker strongly feel this is a requirement then let me know, otherwise answer to suggestion at #20834 (comment) appreciated. |
just to clarify with this current PR. A GCS can't create a mission, checksum it, ask the autopilot what checksum it has and expect it to ever match what it came up with. ArduPilot can not round-trip the entire mission_item_int sequence as we don't store the vast majority of the data that can be present in What a GCS can do is checksum a mission it has downloaded from the autopilot, ask the autopilot what it's got on it and expect that to match. This is because once the mission has been round-tripped to the autopilot the GCS has a copy of the mission which has been filtered through the autopilot's storage mechanisms. The suggestion that came out of the DevCall yesterday is to just go fully opaque - so the GCS never checksums anything, just has some sort of autopilot-generated token which can be used to uniquely identify a mission configuration (almost certainly a checksum). Note that a mission can be modifed on the autopilot through many means - e.g. partial upload, scripting, custom patches - so adding a If we were to go down the "autopilot unique token (probably checksum)" route, we could potentially solve the race condition (vs other GCSs changing the mission) issues by having the GCS include an opaque session identifier as an extension in the |
The use cases don't specify the solution @peterbarker - only the requirements. But if you think about the solution for these, it's hard to see how many of these requirements could be satisfied by the GCS only, without some cooperation (and changes) to how the autopilot does things. I'm hoping that these considerations can be taken into account. In the end the goal is to make "ArduPilot" (end to end solution, not just the FC) better. Just a reminder for anyone joining the thread, I've created a forum post here https://discuss.ardupilot.org/t/mission-configuration-data-item/91382 that discusses these requirements. Perhaps I've tagged it wrong, it doesn't seem to be getting much attention :-( |
So does this mean there will also be a "MISSION_TYPE" mission item stored in the vehicle? (I'm assuming that, otherwise I don't see where you store the unique_id value and the other values you are suggesting). If so, you really have just created a cut down version of the "Mission Configuration" I was suggesting, but having done that, why not create a true immutable "unique_id" for the mission, in addition to one that changes when the mission is updated? It would sure help in the long run. |
I don't know the history of this, but just reading this, it seem that if the definition algorithm is changed to only include fields that will be common on the FC and GCS, it should be possible to guarantee the same result for the same mission. What am I missing here? |
The GCS does not know/should not need to know what parameters the autopilot implements for each and every command. If even one command in the mission has one parameter that is not stored the checksum breaks. There are ways this might be fixed, but autopilots aren't willing to pay those either. For example, a flight stack might reject any command that has anything other than the "invalid value" for an unused parameter. That way the mission is either stored with a parameter or is invalid and could be ignored by the algorithm. But flight stacks/GCSs generally don't use the defaults properly and much might break while trying to enforce this. |
@peterbarker Last addition in #20834 (comment) sounds good.
|
9e908c0
to
6cd6283
Compare
6cd6283
to
7598cda
Compare
0c963ba
to
9dd3fd4
Compare
Probably worth adding in some defines for this functionality. If we add support for Fence/Rally it will grow several hundred more bytes. Cost:
|
9dd3fd4
to
7b954e2
Compare
@peterbarker How's this progressing? Note that mavlink/mavlink#2029 is also in play which also affects MISSON_CURRENT. |
7b954e2
to
958e836
Compare
958e836
to
1ed0e0b
Compare
So I rebased and started to look at this again. We should rename Bigger problem is that this doesn't play well with MAVFTP transfer of items AFAICS. Can't transfer the opaque ID in the packed format - there's no extensibility here.
We'd need to adjust the ArduPilot FTP code so that you can request the mission from a slightly different URL to get it with the opaque ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be done as an io callback, where it bails if the mission_change_counter changes, and we increment mission_change_counter on any change
|
||
const uint32_t mission_last_change_time_ms = mission.last_change_time_ms(); | ||
|
||
if (mission_last_change_time_ms == checksum_state.last_calculate_time_ms) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there could be more than one change in a ms, especially with scripting changing missions, or DDS
The current docs indicate this is This is also in PX4 now PX4/PX4-Autopilot#21839
This is stored on the file system as a file right? With MAVFTP you can get the file CRC (CalcFileCRC32) from the vehicle, which implies that it is calculated on the vehicle. Is the theory sound? It might not be complete, but this is the way I was hoping you'd handle it. |
1ed0e0b
to
d81463e
Compare
d81463e
to
84a211e
Compare
This PR (now) fills in new extension fields in several messages, according to discussions here: mavlink/mavlink#2012
The
MISSION_ACK
when you have successfully uploaded a mission now contains an opaque ID for the loaded mission.The
MISSION_CURRENT
message has three extra fields, one for each of the standard threeMAV_MISSION_TYPE
s (mission, rally, fence). We only support this field on mission at this point.The
MISSION_COUNT
message also gets a newopaque_id
field. A GCS can associate the downloaded mission with theopaque_id
in theMISSION_COUNT
message they receive back from the autopilot. The GCS MUST check the opaque ID hasn't changed after they have all the items if it wants to be sure the downloaded mission is intact!Replaces #17370 - nothing changed, I just stuffed up when I went to reopen things.