# Change Flight Mode using MAVSDK-Python

**URL:** <https://discuss.px4.io/t/change-flight-mode-using-mavsdk-python/30659>\
**Category:** Uncategorized\
**Created:** [February 2, 2023, 6:46am UTC](https://discuss.px4.io/t/change-flight-mode-using-mavsdk-python/30659 "2023-02-02T06:46:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiep\_dao\_hoang](https://discuss.px4.io/user_avatar/discuss.px4.io/hiep_dao_hoang/32/11044_2.png) [@hiep\_dao\_hoang](https://discuss.px4.io/u/hiep_dao_hoang)\
**Post date:** [February 2, 2023, 6:46am UTC](https://discuss.px4.io/t/change-flight-mode-using-mavsdk-python/30659/1 "2023-02-02T06:46:27Z")

</div>

Hi. I’m designing a GUI to control my px4 using tkinter and mavsdk-python libraries  
When i land my real px4 by my GUI, it doesn’t automatically change from LANDED MODE → HOLD MODE when it’s done. So if i want to takeoff again, the px4 denies to arm because it is LANDED MODE  
I want to ask that how can i change flight mode using mavsdk-python like changing flight mode in QGC  
THANKS A LOT

---

<div class="post-metadata">

**Author:** ![Artem\_Borisov](https://discuss.px4.io/user_avatar/discuss.px4.io/artem_borisov/32/9999_2.png) [@Artem\_Borisov](https://discuss.px4.io/u/Artem_Borisov)\
**Post date:** [February 3, 2023, 9:13am UTC](https://discuss.px4.io/t/change-flight-mode-using-mavsdk-python/30659/2 "2023-02-03T09:13:10Z")

</div>

Hi!  
As I know you can set only offboard mode by mavsdk - offboard.start().  
If used MAVSDK C++, it have MavlinkPassthrough plugin, where you can send any command

> mavsdk::MavlinkPassthrough::CommandLong commandLong;  
> commmandLong.command = MAV\_CMD\_DO\_SET\_MODE;  
> commandLong.param1 = MAV\_MODE\_FLAG\_CUSTOM\_MODE\_ENABLED;  
> commandLong.param2 = Hold;  
> commandLong.target\_compid = 0;  
> commandLong.target\_sysid = 0;  
> mavlinkPassthrough-\>send\_command\_long(commandLong);

In mavsdk-python I see that it have [`Action.hold()`](http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/plugins/action.html#mavsdk.action.Action.hold) . May be it is what you looking for, don’t know I’m don’t use mavsdk-python.

Yes… I think it will be work:

“_async_ hold()  
Send command to hold position (a.k.a. “Loiter”).  
Sends a command to drone _ **to change to Hold flight mode** _, causing the vehicle to stop and maintain its current GPS position and altitude.  
Note: this command is specific to the PX4 Autopilot flight stack as it implies a change to a PX4-specific mode.”

---

<div class="post-metadata">

**Author:** ![hiep\_dao\_hoang](https://discuss.px4.io/user_avatar/discuss.px4.io/hiep_dao_hoang/32/11044_2.png) [@hiep\_dao\_hoang](https://discuss.px4.io/u/hiep_dao_hoang)\
**Post date:** [February 5, 2023, 2:36am UTC](https://discuss.px4.io/t/change-flight-mode-using-mavsdk-python/30659/3 "2023-02-05T02:36:45Z")

</div>

Thank you so much!!!
