MAVLink is a communication protocol used in drones. What is its main purpose?
Think about how drones send and receive information during flight.
MAVLink is a lightweight communication protocol that allows drones and ground control stations to exchange commands and telemetry data.
Consider this Python snippet using pymavlink to print a heartbeat message type:
from pymavlink import mavutil master = mavutil.mavlink_connection('udp:127.0.0.1:14550') msg = master.recv_match(type='HEARTBEAT', blocking=True) print(msg.get_type())
Check the method used to get the message type name.
The get_type() method returns the exact MAVLink message type name, which is 'HEARTBEAT'.
Look at this code snippet that tries to connect to a drone using MAVLink:
from pymavlink import mavutil master = mavutil.mavlink_connection('tcp:192.168.2.1:5760') master.wait_heartbeat() print('Heartbeat received')
Think about what happens if the drone is not reachable at the given IP and port.
If no drone is listening at the TCP address, the connection attempt fails, raising a ConnectionRefusedError.
Given a MAVLink connection master, which code correctly sends an arm command?
Check the command constant name and the parameter order for arming.
The correct command is MAV_CMD_COMPONENT_ARM_DISARM with param1 set to 1 to arm the drone.
The MAVLink HEARTBEAT message is essential for drone status. How many bytes does its payload contain?
Refer to the MAVLink common message set documentation for HEARTBEAT.
The HEARTBEAT message payload contains 9 bytes: type (1), autopilot (1), base_mode (1), custom_mode (4), system_status (1), mavlink_version (1).