Changing of mode

i have used this for changing mode from manual to stabilize
As mode 0 for stabilize
mode 19 for manual

autopilot.mav.command_long_send(
1, # autopilot system id
1, # autopilot component id
176, # command id, ARM/DISARM
0, # confirmation
192, # MAV_MODE_MANUAL_ARMED
0,0,0,0,0,0 # 0 for stabilize
)

but code is not working.(no errors)
Can anyone help how to change to stabilize mode and Altitude hold using mavlink commands

This is a simple example:

# Import mavutil
from pymavlink import mavutil
 
# Create the connection
master = mavutil.mavlink_connection('udp:0.0.0.0:14550')
 
# Choose a mode
mode = 'MANUAL'
 
# Check if mode is available
if mode not in master.mode_mapping():
    print('Unknown mode : {}'.format(mode))
    print('Try:', list(master.mode_mapping().keys()))
    return
 
# Get mode ID
mode_id = master.mode_mapping()[mode]
# Set new mode
master.set_mode(mode_id)

We are upgrading our documentation to add more pymavlink examples, should release soon.

Here’s the examples: Pymavlink · GitBook

Typo in the Arm/Disarm script?

mavlink.MAV_CMD_COMPONENT_ARM_DISARM

should be

mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM

Thank you Tim ! Fixed.