Mavlink code in python won't work properly when QGC is not running

The current pymavlink documentation and example sections I’m aware of are

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.

1 Like