Change flight mode mavsdk python


Hi. I’m designing a Gui to control my px4. I want to ask how can i change to guided flight mode with mavsdk-python like QGC. And i also want to ask does offboard can be used with real px4 because when i change to offboard mode, the flight mode which is read is unknown.
Thanks a lot

Hi!

Yes

How do you set the offboard mode and how do you read the mode?

I’m designed a very similar GUI to yours, everything works great.

P.S. I’m using MAVSDK C++.

@Artem_Borisov
image
image
this is how i read and set the offboard mode

Before

await drone.offboard.start()

you must send setpoint:

await drone.offboard.set_velocity_bod(VelocityBodyYawspeed(0.0, 0.0, 0.0, 0.0))

Did you did it?

image

ex

@Artem_Borisov
yes i did. here’s my code. it works well in simulation but with real px4, it can not take off or do any thing, and the Land state which is read is not right.
Please help me to solve this problem, may be you should try on your real px4 to see the trouble.
Thank you so much.

Hi!

Sorry, I don’t have experience with python.

For me your code looks good.

If you get this:

if state.is_connected:
printPxh(f"-- Connected to drone!")

with yout real drone, but can’t do anything with it what can you do in simulation. May be something wrong with real drone? For examle:

  • it in hardware in the loop simulation
  • “not ready” no GPS, no RC, no something else
  • seems stupid, may be your drone Ardupilot not PX4.

What type of pixhawk do you use?
What are you see in QGC when you try your code?