Skip to content
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

RFC-0020 dispersion payload #26

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 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
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
Binary file removed dispersion_protocol/configuration_sequence.png
Binary file not shown.
Binary file modified 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.
180 changes: 99 additions & 81 deletions dispersion_protocol/dispersion.xml

Large diffs are not rendered by default.

Binary file modified 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.
212 changes: 107 additions & 105 deletions dispersion_protocol/messages.md

Large diffs are not rendered by default.

170 changes: 107 additions & 63 deletions dispersion_protocol/microservice.md

Large diffs are not rendered by default.

32 changes: 28 additions & 4 deletions text/0020-dispersion-payload.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,51 @@ A procotol can be very difficult to analyze in isolation so I started by creatin
[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

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?
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. the combined protocol makes sense with the addition of an enum indicating type in the relevant messages
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. eliminate request message in favor of mav command infrastructure
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.

## 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. (I think this will lose a lot of critical information)
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
Expand All @@ -86,3 +103,10 @@ After reviewing other submissions, I think I might have gone too far down this p
- 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