Challenge - 5 Problems
Vehicle Connection Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Serial Connection Initialization
What is the output of this code snippet that tries to connect to a vehicle via serial port?
Drone Programming
vehicle = connect('serial:/dev/ttyUSB0:57600') print(vehicle.is_connected)
Attempts:
2 left
💡 Hint
The connect function returns a vehicle object with an is_connected attribute set to True if connection succeeds.
✗ Incorrect
The code connects to the vehicle via serial port and the vehicle object reports connection status as True.
❓ Predict Output
intermediateUDP Connection Port Number
What port number does this UDP connection use to connect to the vehicle?
Drone Programming
vehicle = connect('udp:127.0.0.1:14550') print(vehicle._connection._port)
Attempts:
2 left
💡 Hint
The port number is specified after the IP address in the connection string.
✗ Incorrect
The UDP connection string includes the port 14550, which is used internally by the connection object.
🔧 Debug
advancedIdentify the Error in TCP Connection Code
What error will this code raise when trying to connect to a vehicle via TCP?
Drone Programming
vehicle = connect('tcp:192.168.1.10') print(vehicle.is_connected)
Attempts:
2 left
💡 Hint
The TCP connection string is missing the port number after the IP address.
✗ Incorrect
The connect function expects a port number for TCP connections; missing it causes a ValueError.
🧠 Conceptual
advancedDifference Between Serial and UDP Connections
Which statement correctly describes a key difference between serial and UDP connections to a vehicle?
Attempts:
2 left
💡 Hint
Think about how serial and UDP communicate physically and logically.
✗ Incorrect
Serial connects through physical ports with baud rates; UDP uses network IP addresses and ports.
❓ Predict Output
expertOutput of Connection Status Check with Timeout
What is the output of this code that attempts a TCP connection with a timeout and prints the connection status?
Drone Programming
try: vehicle = connect('tcp:192.168.1.10:5760', timeout=5) print(vehicle.is_connected) except TimeoutError: print('Timeout')
Attempts:
2 left
💡 Hint
If the vehicle is not reachable, the connection will timeout and raise an exception.
✗ Incorrect
The code catches a TimeoutError and prints 'Timeout' if connection fails within 5 seconds.
