0
0
Drone Programmingprogramming~15 mins

Range finder for terrain following in Drone Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Range finder for terrain following
📖 Scenario: You are programming a drone to fly safely over uneven terrain. The drone uses a range finder sensor to measure the distance to the ground below. Your task is to process these sensor readings to help the drone maintain a steady height above the ground.
🎯 Goal: Build a simple program that stores range finder readings, sets a safe flying height threshold, filters readings that are too close to the ground, and then prints the safe distances for the drone to follow.
📋 What You'll Learn
Create a list called range_readings with exact distance values from the sensor.
Create a variable called safe_height to represent the minimum safe flying height.
Use a list comprehension to create a new list called safe_readings containing only readings greater than or equal to safe_height.
Print the safe_readings list to show the filtered safe distances.
💡 Why This Matters
🌍 Real World
Drones use range finders to avoid crashing into the ground when flying over hills or uneven surfaces. Processing these readings helps keep the drone at a safe height.
💼 Career
Understanding how to handle sensor data and apply filtering is important for drone programming, robotics, and any job involving real-time data processing.
Progress0 / 4 steps
1
Create the range finder data list
Create a list called range_readings with these exact distance values in meters: 3.5, 2.0, 4.8, 1.5, and 5.0.
Drone Programming
Need a hint?

Use square brackets [] to create a list and separate values with commas.

2
Set the safe flying height threshold
Create a variable called safe_height and set it to the value 3.0 to represent the minimum safe flying height in meters.
Drone Programming
Need a hint?

Assign the number 3.0 to the variable safe_height using the equals sign =.

3
Filter safe range readings
Use a list comprehension to create a new list called safe_readings that contains only the values from range_readings that are greater than or equal to safe_height.
Drone Programming
Need a hint?

Use the format [item for item in list if condition] to filter the list.

4
Display the safe readings
Print the safe_readings list to show the filtered safe distances for the drone.
Drone Programming
Need a hint?

Use print(safe_readings) to display the list.