Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2c61f53
RFC-0020 dispersion payload
wes-public-apps Feb 18, 2025
f880e74
add pyka reference
wes-public-apps Feb 18, 2025
18de873
address come typos
wes-public-apps Feb 18, 2025
93e51a9
Remove target component and system since this is a broadcast
wes-public-apps Feb 20, 2025
54ee701
v2 - switch to command infrastructure and document as standalone mavl…
wes-public-apps Feb 25, 2025
6202bb5
rename commands to match naming convention per mission microservice
wes-public-apps Feb 25, 2025
18a18fc
add xml definition
wes-public-apps Feb 25, 2025
fd7519f
dispersion on -> active
wes-public-apps Feb 26, 2025
0f41c41
address comments
wes-public-apps Feb 26, 2025
f7a4092
update missed detector reference
wes-public-apps Feb 26, 2025
bfe8b6a
update logging format to be consistent with message timestamps. micro…
wes-public-apps Feb 26, 2025
9a7862e
update uuid to be 128bit char
wes-public-apps Feb 26, 2025
ff51a20
update logging format
wes-public-apps Feb 27, 2025
8f050db
Add support for COMPONENT_BASIC_INFORMATION
wes-public-apps Feb 27, 2025
18adb1c
v3 major changes to support ground rig systems with independent nozzl…
wes-public-apps Mar 4, 2025
6f046cf
check off test cases
wes-public-apps Mar 4, 2025
9ced6ce
minor cleanup
wes-public-apps Mar 4, 2025
e56be8e
trim excess in status message
wes-public-apps Mar 4, 2025
e5755de
Update lock values
wes-public-apps Mar 4, 2025
5b8735d
remove redundant message definitions
wes-public-apps Mar 5, 2025
95a24f3
Add connected autopilot option to docs.
wes-public-apps Mar 12, 2025
110884a
Add linked to tentative roadmap to production.
wes-public-apps Mar 12, 2025
d9d23d6
Link to log file format definition src rather than maintain a duplicate.
wes-public-apps Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dispersion_protocol/control_sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dispersion_protocol/discovery_sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dispersion_protocol/hardware_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
250 changes: 250 additions & 0 deletions dispersion_protocol/microservice.md

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions text/0020-dispersion-payload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Dispersion Payload Protocol

- Start date: 2025-02-18
- Contributors: Wesley Murray <murraywj97@gmail.com>, ...
- Related issues: N/A

## Summary

The scope of this document is to define a message definition set and protocol for interacting with a dispersion payload to ensure effective control as well as compliance and efficacy reporting. The goal is to create an agreed-on standard for what data is necessary and how it should be used so that there can be more transparency in the UAV crop protection space.

Here is the tentative [roadmap](https://docs.google.com/document/d/1s2IZq7PTo6RKCK9s6nvesvSOUHC8mK7Xy0dpXFQYWSA/edit?usp=sharing) for taking this concept from RFC to productions.

## Motivation

There is an increasing demand for using UAVs to deliver chemicals in agriculture for crop protection. This most commonly happens in the form of sprayers or spreaders. Sprayers are typically for liquid payloads and spreaders for granular solids. This has resulted in many indepent solutions to the problem, all using their own version of a black box. This often leaves aerial applicators unable to provide transparency into their service from a regulatory compliance side of things or for customer satisfaction in a situation where very hazardous chemical are frequently applied. This should not be the case.

From the technical side of things, the concept of operations around agricultural applications provide the opportunity to push the techical envelope without a safety risk to people. Thus, expanding MAVLink support into the space will inherently increase adoption of MAVLink which will help validate other aspects of the standard in an unstructured enviornment. So putting a little investment in agriculture specific solutions IMO has out sized benefits.

## Detailed Design

### Background

For those not familiar with aerial application in Agriculture, I strongly recommend using the [Aerial Applicator's Manual](https://www.epa.gov/system/files/documents/2023-11/national-aerial-applicator-manual-2014.pdf). Specifically Chapter 4.

I used the [MAVLink Gimbal Protocol](https://mavlink.io/en/services/gimbal_v2.html) as my template. I must admit, I do not like the concept of splitting the manager and device. I think it over complicates the protocol but I still followed the pattern since there is context I am likely missing. In this PR you will see a proposal that is the device only, but adding on the manager layer is pretty trivial. That being said, I would like to see strong justification for the addition of a manager before I will agree to add it in during the implementation.

### Test Cases

A procotol can be very difficult to analyze in isolation so I started by creating the following set of test cases. These test cases are effectively situations and workflows the protocol must support to provide any value. I then used the proposed protocol to accomplish said test cases. This is an excellent review point for industry specific individuals who might not have a technical background. For those with a technical background this is still a useful starting point because it provides context.

[x] user needs to manually rinse out the system and must be able to control via some sort of interface (physical or digital)
[x] user might need to stop spray mid flight for an emergency without the autopilot being able to override
[x] payload gets overfilled during servicing
[x] payload is not full enough when trying to take off
[x] clogged nozzle during flight
[x] motor (spray pump, or spreader motor) failure during flight
[x] spray system leaks
[x] autopilot control of spray system
[x] aircraft exceeds speed at which the device can keep up
[x] device is turned on before aircraft is at minimum speed
[x] dynamically adjust deposition rate based on aircraft speed
[x] get payload information for planning (ie lead in/out distances, spray leg length, etc)

- Swath width will be configured during planning so OOS

[x] data for compliance and efficancy reporting can be extracted

- Factors that cannot be known by the dispersion device is OOS and can be collected in other parts of the system (ie wind, chemical being applied, etc)

[x] payload is at target fill and ready to go
[x] spot spraying. This happens at the planning level. This protocol supports setting flow rate at specific locations which is enough for spot spraying.
[x] communication buses might be lossy so protocol must handle failure detection.
[x] ability to construct a synchronized timestamp across mavlink nodes to account for latency in commands when generating reports
[x] multiple dispersion devices are connected to the autopilot and need independent control
[x] a single dispersion device has multiple nozzles that require independent nozzle control
[x] the user can adjust droplet size on the ground station during a mission to account for changing wind conditions
[x] a dispersion device could correct flow rate for individual nozzles during turning
[x] a dispersion device can reduce overspray when intersecting an existing not perpendicular spray line by individually turning off one nozzle at a time
[x] protocol supports nozzle count of largest existing sprayer with some additional room for expansion

### Implementation

The target XML content can be found in [this public pull request](https://github.com/flocked-agriculture/mavlink/pull/1).

After reviewing other submissions, I think I might have gone too far down this path but I wanted something complete to get reviewed by industry relevant people in my network before submitting here to the MAVLink community. I created a messages.md file with the full set of message definitions and a microservice.md file detailing how the protocol should work that is submitted with this PR. I have a couple of versions: one with a manager and one without. I used the one without because it is less complex and conveys the same concept.

Every enum that is not a bitmask uses the zero value as a default UNKNOWN value. This, in my experience, results in more robust systems since it is very common to initialize values to zero in the background. Developers can miss this and if zero is a common valid value, the issue often wont surface until late run time. By having a default value that is useless, systems will almost immediately surface an error.

This protocol should at a minimum support the capability of existing systems and then project into the future a little bit to be a timely, durable, and valuable solution. So, this protocol is designed to support a system with multiple dispersion devices and multiple subcomponents on that device. For the sake of this design, we consider a dispersion device to be a system containing one chemical mix and the infrastructure to deliver that to a field. The dipsersion device must have one gateway compute node that is responsible for communicating over a MAVLink interface. In the most simple form, a disperison device could be a microprocessor, tank, esc, motor, and spreader wheel that needs rate assigned at specific GPS locations but it can take on a more complex form factor for large ground based spray systems. These might have multiple feeder tanks with n number of subcomponents allowing independent control of subcomponent droplet size and flow rate to support many powerful features such as spot spraying and turn compenstation.

### Questions

1. ~~This is a combined protocol for spraying and spreading since there are many common elements. Should this be split up?~~
1. ~~For any kind of effective reporting, not only do the messages needs to be defined but there should also be a degree of standardization on how that information gets logged so utilities can interact with it. Making logging suggestions seemed out of scope here but is there anything I should add to nudge people in the right direction?~~
1. ~~Is a dispersion manager needed? I genuinely believe the source should not matter. Anything should be able to send a request and it get processed in the order it is received. The only time any prioritization should occur is manual triggers vs automated. No this could be handled through a manager but it is pretty easy implement with just the deivce using the MANUAL vs AUTO request type. I also expect there to be multiple possible viable sources for manual on/off live at any given moment. All should be immediately respected. I feel like the overhead with a manager only allowign two control sources could make this over complicated.~~
1. Am I missing any critical workflows or test cases? Ie Debug level motor controller and motor information (deemed out of scope, should be a separate protocol for general motor controller and motor information)
1. ~~should we encourage using something like the parameter protocol rather than a command message for configuration?~~
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters are explicitly internal. That means that you can't define param_do_whatever on multiple flight stacks. The implication is that you'll tend to use thing for params that really only matter on the implementation - such as which output is mapped to which dohicky on your device.

If you'll have two flight stacks that want to set the same things, then you probably can't use params, or at least not directly.

A model used for cameras was to separate out the simple things that all cameras do into a core set of commands - zoom, capture image, pan, etc. Then a camera that supports more things can export a camera definition file that references parameters - the UI is generated from this file. I'm not advocating, since it's a lot more work. I guess I'm saying we don't have to invent everything now if we can work out an reasonable extension mechanism - and address 90% of the use cases in MAVLink messages.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I meant this as the dispersion device has its own internal parameter set and parameter protocol server. The parameter protocol would be used to assign values to the device and not the autopilot. My vision for this would not require any autopilot modification. This was also more for convenience than necessity. In most cases, a manufacturer can set a device's parameters, sell that device and it will just work indefinitely. Only in cases where the owner might need more flexibility with nozzle swapping and the system does not have feedback sensors, or they require nozzle repositioning, would they need to modify parameters. I figured that it would be convenient to connect QGC or another util to the component and write the params.

I may be making some assumptions about the mavlink architecture but I think this should work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what you are describing could work, but again, I'd try and reserve this for stuff that is more or less static.

The concerns with parameters is that to MAVLink what gets sent is an id and a value. In order for something that uses the parameters to make any sense of it you need to provide metadata - such as this information in PX4 https://docs.px4.io/main/en/advanced_config/parameter_reference.html#battery-calibration

You need some way to deploy that to your ground stations and keep it in sync - though I guess if it never changes and is the same for all devices you could have a plain list somewhere. ArduPilot provides this kind of metadata to QGC in a file. PX4 has dynamic mechanisms - component metadata - for sharing the file (this might be a good approach for you).
And of course the camera stuff similarly allows a dynamic UI approach.

1. ~~with the device and device component architecture should I switch to manager/device concept~~
1. with the device and device component sharing a message definition should I use FUEL_STATUS to handle fill level since it is only relevant to the device and not subcomponents?

### Tentative Decisions

1. this protocol supports the current state of aerial and ground spray systems
1. the protocol will combine spreader and sprayer into one with the addition of an enum indicating dispersion type in the relevant messages
1. dispersion payloads will be implemented as standalone MAVLink devices
1. a logging infrastructure is proposed
1. a dispersion manager will not be used
1. eliminated request message in favor of mav command infrastructure
1. the parameter protocol will be used for configuration since supporting devices with multiple independent sub components significant increased configuration overhead
1. unix timestamps will be used where possible to ensure accurate reporting on dispersion quality
1. switched status flags and error flags bitmask to continuous enums since almost all of the time the flags would be mutually exclusive. It is worth the size reduction. If multiple codes do happen at the same time, it is common to combine them into a unqiue enum or oscillate between the codes on publish. Warning flags were left as a bit mask since they dont block operation and can be ignored. This makes multiple overlapping warnings likely.
1. I will not be using the fuel status message since this dispersion device is not fuel and I believe the fuel status messages has an unnecessary amount of information.

## Alternatives

1. Do nothing. Solutions are already evolving organically. While the problem will be solved, it is subject to the issues documented in the motivation section.
1. Create documentation on how to use the generic payload messaging infrastructure to accomplish this goal. [ArduPilot Crop Sprayer](https://ardupilot.org/copter/docs/sprayer.html)

## References

- ISOBUS (HSI) Agriculture Comm Standards: https://www.aef-online.org/about-us/activities/high-speed-isobus.html
- Pix4D Spot Spraying Article: https://www.pix4d.com/blog/variable-rate-application-wheat-field/
- Aerial Applicator's Manual: https://www.epa.gov/system/files/documents/2023-11/national-aerial-applicator-manual-2014.pdf
- MAVLink Gimbal Protocol: https://mavlink.io/en/services/gimbal_v2.html
- XAG P150: https://www.xa.com/en/p150
- DJI Agras T40: https://www.dji.com/t40
- Hylio: https://www.hyl.io/
- Rotor: https://rotor.ai/
- Guardian Agriculture: https://guardian.ag/
- PYKA: https://www.flypyka.com/
- TeeJet Dynajet: https://www.teejet.com/precision-farming/application-control-and-monitoring/dynajet
- TeeJet Precision Ag Products: https://www.farmco.com/price%20lists/teejet/2024%2009-01%20teejet%20precision%20picture%20price.pdf
- CPNozzles Accuflow: https://www.cpnozzles.com/products/accu-flo-nozzles/

## TODO

1. um (micron) should be added as an allowed xml unit