0
0
Drone Programmingprogramming~20 mins

Range finder for terrain following in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terrain Following Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Output of range finder distance calculation
What is the output of this code that calculates the distance from the drone to the ground using a range finder reading and drone altitude?
Drone Programming
altitude = 120.5  # meters
range_finder_reading = 15.3  # meters

distance_to_ground = altitude - range_finder_reading
print(f"Distance to ground: {distance_to_ground} meters")
ADistance to ground: 105.2 meters
BDistance to ground: 135.8 meters
CDistance to ground: 120.5 meters
DDistance to ground: 15.3 meters
Attempts:
2 left
💡 Hint
Subtract the range finder reading from the drone's altitude to get the distance to the ground.
🧠 Conceptual
intermediate
1:00remaining
Understanding range finder data for terrain following
Which statement best describes how a range finder helps a drone follow terrain?
AIt measures the distance to the ground so the drone can adjust altitude to maintain a set height.
BIt detects obstacles in front of the drone to avoid collisions.
CIt measures wind speed to stabilize the drone.
DIt records GPS coordinates for navigation.
Attempts:
2 left
💡 Hint
Think about what the range finder measures directly below the drone.
🔧 Debug
advanced
2:00remaining
Identify the error in terrain following altitude adjustment code
What error will this code cause when trying to adjust drone altitude based on range finder data?
Drone Programming
desired_height = 50
range_finder_distance = 45

# Adjust altitude to maintain desired height above ground
new_altitude = desired_height + range_finder_distance
print(f"New altitude: {new_altitude}")
AThe altitude will be set too low because it subtracts instead of adding.
BThe code will cause a syntax error due to missing colon.
CThe code will raise a TypeError because of incompatible types.
DThe altitude will be set too high because it adds desired height and distance instead of subtracting.
Attempts:
2 left
💡 Hint
Think about how altitude relates to desired height and range finder distance.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in range finder data processing
Which option contains the syntax error when trying to create a dictionary of sensor readings?
Drone Programming
sensor_data = {"range_finder": 12.5, "altitude": 100.0, "speed": 5.2}
Asensor_data = {range_finder: 12.5, altitude: 100.0, speed: 5.2}
Bsensor_data = {"range_finder" 12.5, "altitude" 100.0, "speed" 5.2}
Csensor_data = ["range_finder": 12.5, "altitude": 100.0, "speed": 5.2]
Dsensor_data = {"range_finder": 12.5, "altitude": 100.0, "speed": 5.2}
Attempts:
2 left
💡 Hint
Check the punctuation between keys and values in the dictionary.
🚀 Application
expert
2:30remaining
Calculate drone altitude for terrain following with variable terrain
Given a drone flying over terrain where the range finder reading changes as follows: [10, 12, 8, 15, 9] meters, and the drone wants to maintain a constant height of 20 meters above ground, what is the list of altitudes the drone should set to maintain this height?
Drone Programming
range_readings = [10, 12, 8, 15, 9]
desired_height = 20

# Calculate altitudes
altitudes = [reading + desired_height for reading in range_readings]
print(altitudes)
A[20, 20, 20, 20, 20]
B[10, 12, 8, 15, 9]
C[30, 32, 28, 35, 29]
D[-10, -8, -12, -5, -11]
Attempts:
2 left
💡 Hint
Add the desired height to each range finder reading to get the altitude.