How to run MAVSDK in a thread from Python


I have a PySide program that uses one thread for communicating with a motion capture system (indoor tracking) and another thread for a sensor on the drone. I need to have MAVSDK play friendly in another thread so that I can send setpoints for offboard control. Ideally, I could tell the thread to arm, “set_position_ned”, and then disarm after it has gone to all of the positions.

Every attempt I have made doesn’t work because of the asyncio requirement. Could somebody please let me know how this can work?

Thanks for your help.

Have you googled how to mix Python asyncio with sync code?

And do you have some example that you tried to show the problem?

Hello Julian -

Yes, I found just a couple examples but was hoping that a MAVSDK user may have solved this before. Unfortunately, we don’t have time to change direction now. We will just have to work with what we have. If the management wants to continue the project, and we are given more time, then we will have to take another look at this.

Thanks for your help.

1 Like