0
0
Drone Programmingprogramming~10 mins

Companion computer integration (Raspberry Pi) in Drone Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the MAVLink library on the Raspberry Pi.

Drone Programming
import [1]
Drag options to blanks, or click blank then click option'
Atime
Bdronekit
Cpymavlink
Dserial
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'dronekit' instead of 'pymavlink' when direct MAVLink communication is needed.
2fill in blank
medium

Complete the code to open a serial connection to the drone on the Raspberry Pi.

Drone Programming
connection = serial.Serial('[1]', 57600)
Drag options to blanks, or click blank then click option'
A/dev/ttyS0
B/dev/ttyAMA0
C/dev/ttyUSB0
D/dev/ttyACM0
Attempts:
3 left
💡 Hint
Common Mistakes
Using USB serial ports like /dev/ttyUSB0 which may not be connected to the flight controller.
3fill in blank
hard

Fix the error in the code to send a heartbeat message to the drone.

Drone Programming
msg = mavutil.mavlink.MAVLink_heartbeat_message([1], 0, 0, 0, 0)
Drag options to blanks, or click blank then click option'
A3
B1
C5
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 which represent other system types and cause communication issues.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps sensor names to their readings only if the reading is above 10.

Drone Programming
sensor_data = {name: [1] for name, [2] in sensors.items() if value > 10}
Drag options to blanks, or click blank then click option'
Avalue
Breading
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for the reading in the comprehension causing errors.
5fill in blank
hard

Fill all three blanks to filter telemetry data where altitude is above 100 and map the drone ID to altitude.

Drone Programming
filtered = [1] for drone_id, [2] in telemetry.items() if [3] > 100
Drag options to blanks, or click blank then click option'
A{drone_id:
Baltitude
Caltitude}
D[drone_id:
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces for dictionary comprehension.