Introduction
Flying a drone close to the ground can be tricky because the terrain changes constantly. To keep the drone at a safe and steady height, it needs a way to measure how far it is from the ground below.
Jump into concepts and practice - no test required
Imagine walking through a forest at night with a flashlight pointed at the ground. The light helps you see how far the ground is beneath your feet so you can step safely without tripping or falling.
┌───────────────┐
│ Drone Body │
│ ┌───────┐ │
│ │Range │ │
│ │Finder │ │
│ └───┬───┘ │
│ │ │
│ ↓ │
│ ┌───────┐ │
│ │ Ground│ │
│ └───────┘ │
└───────────────┘
↑
│
Distance Measured
│
┌───────────────┐
│ Flight │
│ Controller │
│ Adjusts Height│
└───────────────┘What is the main purpose of a range finder in drone terrain following?
Which of the following code snippets correctly reads a range finder sensor value in a drone program?
1. distance = range_finder.read()
2. distance = read.range_finder()
3. distance = rangeFinder.readValue()
4. distance = range_finder.get()read() to get current values.range_finder.read(), which is standard and correct. Others use incorrect method names or syntax.What will be the output of this code snippet controlling drone height?
distance = 5
if distance < 3:
action = "ascend"
elif distance > 7:
action = "descend"
else:
action = "hold"
print(action)Find the error in this drone height control code:
distance = range_finder.read()
if distance < 2
action = "ascend"
else:
action = "descend"
print(action)You want the drone to maintain a height of 4 meters above ground using the range finder. Which code snippet correctly adjusts the drone's vertical speed based on the measured distance?
distance = range_finder.read()
if distance < 4:
vertical_speed = 1 # ascend
elif distance > 4:
vertical_speed = -1 # descend
else:
vertical_speed = 0 # hold steady
print(vertical_speed)