The current pymavlink documentation and example sections I’m aware of are
- The official documentation
- Currently assumes you’re already familiar with MAVLink, and just want to use Python to interface with it
- The Blue Robotics examples
- Useful snippets that don’t fully cover the nuances of creating full programs
- The Pymavlink source repository
- Includes the ArduPilot examples
- Snippets that aren’t focused on vehicle control, but do make use of some interesting features
- mavutil.py can also be worth a read, for understanding available utility functions
- Includes the ArduPilot examples
- The abstractions used in the ArduPilot test suite
I wouldn’t really class any of those as examples of best practices at the moment, which is part of why I’m planning to revise our examples documentation when I transfer it over - good practice full program examples seem like they would be beneficial. It is somewhat unhelpful that ArduPilot’s examples maintain backwards compatibility with quite old versions of Python, which means newer Python features are only covered in external examples.
I’ve got a reasonably extensive example which takes that approach, but there are some notes at the bottom about why that’s not necessarily recommended, and an alternative (synchronous) approach.
@patrickelectric has also made an example using asyncio. I expect asyncio is likely the best approach for the main thread of more complex MAVLink-based programs going forwards.