Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Waypoint Radius and Acceptance
📖 Scenario: You are programming a drone to follow a set of waypoints during a flight mission. Each waypoint has a position, and the drone should consider the waypoint reached when it is within a certain radius of that point. This radius is called the acceptance radius.Setting the right acceptance radius helps the drone fly smoothly without needing to hit the exact point, which can be difficult due to wind or GPS accuracy.
🎯 Goal: Build a simple program that checks if the drone has reached each waypoint based on the acceptance radius. You will create a list of waypoints, set an acceptance radius, write the logic to check if the drone is close enough to each waypoint, and then print which waypoints are reached.
📋 What You'll Learn
Create a list of waypoints with exact coordinates
Set an acceptance radius variable
Write a loop to check distance from drone position to each waypoint
Print the list of waypoints that are within the acceptance radius
💡 Why This Matters
🌍 Real World
Drones use waypoint radius and acceptance to fly smoothly and safely by not needing to hit exact points, which helps in real missions with GPS errors or wind.
💼 Career
Understanding waypoint acceptance is important for drone programmers, robotics engineers, and anyone working with autonomous vehicles or navigation systems.
Progress0 / 4 steps
1
Create the list of waypoints
Create a list called waypoints with these exact tuples representing coordinates: (10, 10), (20, 20), (30, 30).
Drone Programming
Hint
Use a list with tuples for each waypoint coordinate.
2
Set the acceptance radius
Create a variable called acceptance_radius and set it to 8.
Drone Programming
Hint
Use a simple number variable for the radius.
3
Check which waypoints are reached
Create a list called reached_waypoints. Use a for loop with variables wp_x and wp_y to iterate over waypoints. Inside the loop, calculate the distance from the drone position (15, 15) to the waypoint using the formula distance = ((wp_x - 15)**2 + (wp_y - 15)**2)**0.5. If the distance is less than or equal to acceptance_radius, add the waypoint tuple to reached_waypoints.
Drone Programming
Hint
Use the distance formula and an if statement inside the loop.
4
Print the reached waypoints
Write a print statement to display the reached_waypoints list.
Drone Programming
Hint
Use print(reached_waypoints) to show the result.
Practice
(1/5)
1. What does the waypoint radius define in drone programming?
easy
A. The distance within which the drone considers it has reached a waypoint
B. The maximum speed the drone can fly between waypoints
C. The height at which the drone must fly over a waypoint
D. The time the drone must wait at each waypoint
Solution
Step 1: Understand the waypoint radius concept
The waypoint radius is the area around a waypoint that the drone must enter to consider it reached.
Step 2: Match the definition to options
The distance within which the drone considers it has reached a waypoint correctly describes this as the distance within which the drone accepts the waypoint as reached.
Final Answer:
The distance within which the drone considers it has reached a waypoint -> Option A
Quick Check:
Waypoint radius = acceptance distance [OK]
Hint: Waypoint radius means how close drone must get to accept point [OK]
Common Mistakes:
Confusing radius with speed or height
Thinking drone must stop exactly on the point
Mixing radius with waiting time
2. Which of the following is the correct way to set a waypoint radius of 5 meters in a drone mission script?
easy
A. mission.waypointRadius = '5m'
B. mission.radiusWaypoint = 5
C. setRadius(waypoint=5)
D. mission.setWaypointRadius(5)
Solution
Step 1: Identify correct method syntax
The common method to set waypoint radius is using a function like setWaypointRadius(value).
Step 2: Compare options
mission.setWaypointRadius(5) uses mission.setWaypointRadius(5), which is a clear and correct syntax. Other options use incorrect property names or wrong formats.
Final Answer:
mission.setWaypointRadius(5) -> Option D
Quick Check:
Method call with numeric radius = correct syntax [OK]
Hint: Look for method call with numeric argument for radius [OK]
If the drone is currently at (12, 12), what will be the output?
medium
A. False
B. True
C. Error
D. None
Solution
Step 1: Calculate distance from drone to waypoint
The drone is at (12,12) and waypoint at (10,10). Distance = sqrt((12-10)^2 + (12-10)^2) = sqrt(4+4) = sqrt(8) ≈ 2.83 meters.
Step 2: Compare distance with waypoint radius
The radius is set to 3 meters. Since 2.83 < 3, the drone is inside the radius and should have reached the waypoint.
Step 3: Check output of hasReachedWaypoint()
Since the drone is inside the radius, hasReachedWaypoint() returns True.
Final Answer:
True -> Option B
Quick Check:
Distance 2.83 < radius 3 means reached = True [OK]
Hint: Calculate distance and compare with radius to decide True/False [OK]
Common Mistakes:
Calculating distance incorrectly
Confusing inside/outside radius logic
Assuming exact position match needed
4. Identify the error in this drone waypoint acceptance code:
drone.setWaypointRadius = 4
if drone.distanceToWaypoint() < drone.waypointRadius:
drone.acceptWaypoint()
medium
A. Incorrect method call syntax for setting radius
B. Comparison operator should be > instead of <
C. Missing parentheses in acceptWaypoint call
D. Variable drone.waypointRadius is undefined
Solution
Step 1: Check how waypoint radius is set
The code uses drone.setWaypointRadius = 4, which assigns a number to a method name, overwriting it.
Step 2: Identify correct syntax
The radius should be set by calling the method: drone.setWaypointRadius(4), not by assignment.
Final Answer:
Incorrect method call syntax for setting radius -> Option A
Quick Check:
Method call needs parentheses, not assignment [OK]
Hint: Use parentheses to call methods, not assignment [OK]
Common Mistakes:
Assigning value to method name instead of calling it
Confusing < and > in distance check
Forgetting parentheses on method calls
5. You want a drone to fly through 3 waypoints smoothly without stopping exactly on each. The waypoints are at (0,0), (10,0), and (10,10). You set the waypoint radius to 2 meters. Which statement best describes the drone's behavior?
hard
A. The drone will ignore the radius and stop only when exactly on the waypoint coordinates
B. The drone will stop exactly at each waypoint because radius only affects altitude
C. The drone will consider each waypoint reached when within 2 meters, allowing smooth flight without stopping exactly on points
D. The drone will fly in a straight line ignoring waypoints due to radius setting
Solution
Step 1: Understand waypoint radius effect on flight
Setting a radius of 2 meters means the drone accepts reaching a waypoint once it is within 2 meters of it.
Step 2: Analyze drone behavior with radius
This acceptance allows the drone to continue flying smoothly without stopping exactly on each waypoint, improving flight flow.
Step 3: Eliminate incorrect options
The drone will stop exactly at each waypoint because radius only affects altitude is wrong because radius affects horizontal acceptance, not altitude only. The drone will ignore the radius and stop only when exactly on the waypoint coordinates ignores radius effect. The drone will fly in a straight line ignoring waypoints due to radius setting is incorrect as radius does not cause ignoring waypoints.
Final Answer:
The drone will consider each waypoint reached when within 2 meters, allowing smooth flight without stopping exactly on points -> Option C