0
0
Drone Programmingprogramming~20 mins

Waypoint mission creation in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Waypoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of waypoint list creation
What is the output of this code that creates a list of waypoints with latitude and longitude?
Drone Programming
waypoints = []
for i in range(3):
    waypoint = {'lat': 40.0 + i*0.01, 'lon': -74.0 - i*0.01}
    waypoints.append(waypoint)
print(waypoints)
A[{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.01}, {'lat': 40.01, 'lon': -74.01}]
B[{'lat': 40.0, 'lon': -74.0}, {'lat': 40.0, 'lon': -74.0}, {'lat': 40.0, 'lon': -74.0}]
C[{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.0}, {'lat': 40.02, 'lon': -74.0}]
D[{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.01}, {'lat': 40.02, 'lon': -74.02}]
Attempts:
2 left
💡 Hint
Look at how latitude and longitude change with each loop iteration.
🧠 Conceptual
intermediate
1:30remaining
Understanding waypoint altitude setting
In a waypoint mission, why is it important to set the altitude for each waypoint?
ATo ensure the drone flies at the correct height avoiding obstacles and maintaining safety.
BTo make the drone fly faster between waypoints.
CTo reduce the battery consumption by flying lower always.
DTo change the drone's camera angle automatically.
Attempts:
2 left
💡 Hint
Think about what altitude controls in drone flight.
🔧 Debug
advanced
2:30remaining
Identify the error in waypoint mission code
What error will this code produce when creating waypoints for a mission?
Drone Programming
waypoints = [{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.01}]
for wp in waypoints:
    wp['alt'] = 100
    wp = {'lat': 41.0, 'lon': -75.0, 'alt': 150}
print(waypoints)
ATypeError because dictionary assignment is invalid inside loop
BNo error; output is [{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.01, 'lon': -74.01, 'alt': 100}]
CNo error; output is [{'lat': 41.0, 'lon': -75.0, 'alt': 150}, {'lat': 41.0, 'lon': -75.0, 'alt': 150}]
DNo error; output is [{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.01}]
Attempts:
2 left
💡 Hint
Consider what happens when you assign a new dictionary to the loop variable.
📝 Syntax
advanced
1:30remaining
Syntax error in waypoint mission dictionary comprehension
Which option correctly creates a dictionary of waypoints with keys as indices and values as lat-lon tuples?
Drone Programming
waypoints = {i: (40.0 + i*0.01, -74.0 - i*0.01) for i in range(3)}
A{i: (40.0 + i*0.01, -74.0 - i*0.01) for i in range(3)}
B{i: (40.0 + i*0.01, -74.0 - i*0.01) if i < 3 for i in range(3)}
C{i: (40.0 + i*0.01, -74.0 - i*0.01) for i in range(3):}
D{i: (40.0 + i*0.01, -74.0 - i*0.01) for i range(3)}
Attempts:
2 left
💡 Hint
Check the correct syntax for dictionary comprehensions in Python.
🚀 Application
expert
3:00remaining
Calculate total mission distance from waypoints
Given a list of waypoints with latitude and longitude, which code correctly calculates the total straight-line distance (in degrees) between consecutive waypoints?
Drone Programming
waypoints = [{'lat': 40.0, 'lon': -74.0}, {'lat': 40.01, 'lon': -74.01}, {'lat': 40.02, 'lon': -74.02}]
total_distance = 0
for i in range(len(waypoints)-1):
    wp1 = waypoints[i]
    wp2 = waypoints[i+1]
    dist = ((wp2['lat'] - wp1['lat'])**2 + (wp2['lon'] - wp1['lon'])**2)**0.5
    total_distance += dist
print(round(total_distance, 5))
A0.01
B0.02
C0.02828
D0.04
Attempts:
2 left
💡 Hint
Use the Pythagorean theorem to find distance between points.