Complete the code to initialize a MAVLink connection over UDP.
connection = mavutil.mavlink_connection('[1]')
To connect over UDP, the address format is 'udp:IP:port'. Here, 'udp:127.0.0.1:14550' initializes a UDP connection on localhost port 14550.
Complete the code to wait for a heartbeat message from the drone.
connection.[1]()The method wait_heartbeat() waits until a heartbeat message is received from the drone, confirming the connection.
Fix the error in the code to receive a message with a timeout of 5 seconds.
msg = connection.[1](timeout=5)
The correct method to receive any MAVLink message with a timeout is recv_match(). Other options are incorrect or do not support timeout.
Fill both blanks to create a dictionary of message names and their IDs for messages with ID less than 50.
msg_dict = {msg.get_type(): msg.msgid for msg in connection.mav.__dict__.values() if msg.[1] < [2]Each MAVLink message object has a msgid attribute for its ID. We filter messages with msgid < 50.
Fill all three blanks to send a command long message with target system, component, and command ID.
connection.mav.command_long_send([1], [2], [3], 0, 0, 0, 0, 0, 0, 0, 0)
The command_long_send method requires target_system, target_component, and command as the first three parameters to specify the recipient and command.
