I’m new to the MAVSDK library, and I’m trying to wrap my head around how to practically use the telemetry data in conjunction with offboard mode. I’m using the Python library.
Based on the examples, I can see that the telemetry data is exposed through an infinite asynchronous generator. This is combersome when trying to query and use multiple different sensors, since the only way I can figure to query the newest value is to do any awkward async for-break block like this:
async for x in drone.telemetry.imu(): imu = x break
The examples show running these
async for loops in a separate asyncio task, which I’ve thought about using to update a class-variable in the background, but the values are only updated when my current task yields control (e.g. at a
await call), which could cause issues if my control systems requires more frequently updated data. The workaround for that would be littering
await asyncio.sleep(0) throughout the code to manually yield control, but that also seems clunky.
Bottom line, I’m curious if the community can provide guidance on the standard/accepted/intended way for retrieving and using the sensor data so I don’t go down a bad path. Thanks!