0
0
Drone Programmingprogramming~20 mins

Companion computer integration (Raspberry Pi) in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Raspberry Pi Companion Computer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of MAVLink message parsing code
What is the output of this Python code snippet running on a Raspberry Pi receiving MAVLink messages?
Drone Programming
from pymavlink import mavutil

master = mavutil.mavlink_connection('udp:127.0.0.1:14550')
msg = master.recv_match(type='HEARTBEAT', blocking=True)
print(f"System ID: {msg.get_srcSystem()}, Component ID: {msg.get_srcComponent()}")
AAttributeError: 'NoneType' object has no attribute 'get_srcSystem'
BSystem ID: 1, Component ID: 1
CSystem ID: 0, Component ID: 0
DTimeoutError: No message received
Attempts:
2 left
💡 Hint
The code waits for a heartbeat message and prints its source IDs.
🧠 Conceptual
intermediate
1:30remaining
Purpose of companion computer in drone systems
What is the main role of a companion computer like a Raspberry Pi in a drone system?
ATo act as a GPS receiver only
BTo control the drone's motors directly
CTo replace the flight controller entirely
DTo provide advanced processing and run custom algorithms alongside the flight controller
Attempts:
2 left
💡 Hint
Think about tasks that require more computing power than the flight controller.
🔧 Debug
advanced
2:00remaining
Identify the error in MAVLink connection code
What error will this Raspberry Pi Python code produce when trying to connect to a drone via serial port?
Drone Programming
from pymavlink import mavutil

master = mavutil.mavlink_connection('/dev/ttyUSB0', baud=57600)
msg = master.recv_match(type='ATTITUDE', blocking=True)
print(msg)
ASyntaxError: invalid syntax in baud parameter
BAttributeError: 'NoneType' object has no attribute 'recv_match'
CFileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB0'
DTimeoutError: No ATTITUDE message received
Attempts:
2 left
💡 Hint
Check if the serial device path exists on the Raspberry Pi.
📝 Syntax
advanced
2:30remaining
Correct syntax for sending MAVLink command
Which option correctly sends a MAV_CMD_NAV_TAKEOFF command using pymavlink on a Raspberry Pi?
Drone Programming
master = mavutil.mavlink_connection('udp:127.0.0.1:14550')

# Send takeoff command here
Amaster.mav.command_long_send(master.target_system, master.target_component, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 0, 0, 0, 0, 0, 0, 0, 10)
Bmaster.mav.command_long_send(master.target_system, master.target_component, MAV_CMD_NAV_TAKEOFF, 0, 0, 0, 0, 0, 0, 0, 10)
Cmaster.mav.command_long_send(master.target_system, master.target_component, mavutil.MAV_CMD_NAV_TAKEOFF, 0, 0, 0, 0, 0, 0, 0, 10)
Dmaster.mav.command_long_send(master.target_system, master.target_component, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 1, 0, 0, 0, 0, 0, 0, 10)
Attempts:
2 left
💡 Hint
Check the full path and parameters for the MAV_CMD_NAV_TAKEOFF constant and command_long_send signature.
🚀 Application
expert
1:30remaining
Number of GPS fix messages received in 10 seconds
A Raspberry Pi companion computer listens to GPS_RAW_INT MAVLink messages at 5 Hz. How many GPS fix messages will it receive in 10 seconds?
A50
B100
C5
D10
Attempts:
2 left
💡 Hint
Multiply the message frequency by the time interval.