0
0
Drone Programmingprogramming~30 mins

Speed control during mission in Drone Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Speed control during mission
📖 Scenario: You are programming a drone to fly a mission. The drone must adjust its speed based on the distance to the next waypoint to fly safely and efficiently.
🎯 Goal: Build a program that sets the drone's speed for each waypoint based on the distance to that waypoint.
📋 What You'll Learn
Create a dictionary with waypoints and their distances
Add a speed limit variable
Use a loop to set speed based on distance
Print the speed settings for each waypoint
💡 Why This Matters
🌍 Real World
Drones need to adjust their speed during missions to save battery and avoid obstacles safely.
💼 Career
Understanding how to control speed based on conditions is important for drone software developers and robotics engineers.
Progress0 / 4 steps
1
Create waypoints with distances
Create a dictionary called waypoints with these exact entries: 'WP1': 100, 'WP2': 250, 'WP3': 400, 'WP4': 150
Drone Programming
Need a hint?

Use curly braces to create a dictionary with the waypoint names as keys and distances as values.

2
Set maximum speed limit
Create a variable called max_speed and set it to 50 to represent the maximum speed of the drone.
Drone Programming
Need a hint?

Just assign the number 50 to the variable max_speed.

3
Calculate speed for each waypoint
Use a for loop with variables wp and dist to iterate over waypoints.items(). Inside the loop, create a variable called speed that is max_speed if dist is greater than 200, otherwise dist / 4.
Drone Programming
Need a hint?

Use a conditional expression to set speed based on the distance.

4
Print speed settings
Inside the same for loop, write a print statement that outputs: "Waypoint {wp} speed set to {speed}" using an f-string.
Drone Programming
Need a hint?

Use print(f"Waypoint {wp} speed set to {speed}") inside the loop.