I'm new in MAVLink, so I'm having problems trying to set up a calibration for different sensors in Python (like it would be done in QGroundControl).
First I established a connection and received a Heartbeat (until here no problem), then I send a message to stream all data, set the preflight mode (not sure if it worked), and start calibrating the magnetometer. The autopilot beeps but it seems nothing else happens. Also I'm not quite sure on how to receive messages regarding the state of the magnetometer calibration.
I'm kind of lost and would appreciate any help to finally start the calibration for the different sensors.
from pymavlink import mavutil
the_connection = mavutil.mavlink_connection('/dev/tty.usbmodem01')
the_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_system),"\n")
the_connection.mav.request_data_stream_send(the_connection.target_system, the_connection.target_component, mavutil.mavlink.MAV_DATA_STREAM_ALL, 10, 1)
the_connection.mav.set_mode_send(the_connection.target_system,
mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
mavutil.mavlink.MAV_MODE_PREFLIGHT)
the_connection.mav.command_long_send(the_connection.target_system, 0,
mavutil.mavlink.MAV_CMD_DO_START_MAG_CAL, 0,
0, 0, 1, 0, 0, 0, 0)