Controlling PWM Values with Python

Following up on this, because BlueOS has additional MAVLink components for the camera manager and some other systems, there are multiple heartbeats. Accordingly the first heartbeat received through the MAVLink connection is not necessarily a heartbeat from the vehicle, so it’s necessary to wait until a correct one has been found. That can be done with something like the following:

from pymavlink import mavutil

... # create the connection

# wait for vehicle heartbeat before sending commands
ensure_autopilot_heartbeat = (
    f'HEARTBEAT.get_srcSystem() == {master.target_system} and '
    f'HEARTBEAT.get_srcComponent() == {mavutil.mavlink.MAV_COMP_ID_AUTOPILOT1}'
)
master.recv_match(type='HEARTBEAT', condition=ensure_autopilot_heartbeat, blocking=True)

... # rest of the program