Bird
Raised Fist0
Drone Programmingprogramming~20 mins

Waypoint radius and acceptance in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

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
Challenge - 5 Problems
🎖️
Waypoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Waypoint acceptance with radius check
What is the output of this code that checks if a drone has reached a waypoint within a given radius?
Drone Programming
def has_reached_waypoint(drone_pos, waypoint_pos, radius):
    dx = drone_pos[0] - waypoint_pos[0]
    dy = drone_pos[1] - waypoint_pos[1]
    distance_squared = dx*dx + dy*dy
    return distance_squared <= radius*radius

print(has_reached_waypoint((10, 10), (13, 14), 5))
ATypeError
BFalse
CSyntaxError
DTrue
Attempts:
2 left
💡 Hint
Remember to compare squared distances to avoid costly square root calculations.
Predict Output
intermediate
2:00remaining
Effect of waypoint radius on acceptance
Given this code, what will be the output when the drone is exactly on the edge of the acceptance radius?
Drone Programming
def check_acceptance(drone_pos, waypoint_pos, radius):
    from math import sqrt
    distance = sqrt((drone_pos[0] - waypoint_pos[0])**2 + (drone_pos[1] - waypoint_pos[1])**2)
    return distance < radius

print(check_acceptance((0, 0), (3, 4), 5))
ATrue
BSyntaxError
CFalse
DTypeError
Attempts:
2 left
💡 Hint
Check the comparison operator used for acceptance.
🔧 Debug
advanced
2:00remaining
Identify the error in waypoint acceptance logic
This code is supposed to return True if the drone is within the radius of the waypoint. What error will it raise or what is the output?
Drone Programming
def is_within_radius(drone, waypoint, radius):
    distance = ((drone.x - waypoint.x)**2 + (drone.y - waypoint.y)**2)**0.5
    if distance <= radius:
        return True
    else:
        return False

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

print(is_within_radius(Point(1,2), Point(4,6), 5))
ASyntaxError
BFalse
CTrue
DAttributeError
Attempts:
2 left
💡 Hint
Check the if-else syntax carefully.
Predict Output
advanced
2:00remaining
Waypoint acceptance with 3D coordinates
What is the output of this code that checks if a drone is within a 3D waypoint radius?
Drone Programming
def within_radius_3d(drone_pos, waypoint_pos, radius):
    dx = drone_pos[0] - waypoint_pos[0]
    dy = drone_pos[1] - waypoint_pos[1]
    dz = drone_pos[2] - waypoint_pos[2]
    dist_sq = dx*dx + dy*dy + dz*dz
    return dist_sq <= radius*radius

print(within_radius_3d((1,2,3), (4,6,7), 6))
AFalse
BTrue
CIndexError
DTypeError
Attempts:
2 left
💡 Hint
Calculate squared distance in 3D and compare with squared radius.
Predict Output
expert
2:00remaining
Dynamic waypoint acceptance with variable radius
What is the output of this code that dynamically adjusts acceptance radius based on drone speed?
Drone Programming
def dynamic_acceptance(drone_pos, waypoint_pos, speed):
    base_radius = 5
    radius = base_radius + speed * 0.5
    dx = drone_pos[0] - waypoint_pos[0]
    dy = drone_pos[1] - waypoint_pos[1]
    dist_sq = dx*dx + dy*dy
    return dist_sq <= radius*radius

print(dynamic_acceptance((0,0), (6,8), 4))
ATypeError
BFalse
CNameError
DTrue
Attempts:
2 left
💡 Hint
Calculate radius including speed factor and compare squared distances.

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

  1. 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.
  2. 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.
  3. Final Answer:

    The distance within which the drone considers it has reached a waypoint -> Option A
  4. 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

  1. Step 1: Identify correct method syntax

    The common method to set waypoint radius is using a function like setWaypointRadius(value).
  2. 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.
  3. Final Answer:

    mission.setWaypointRadius(5) -> Option D
  4. Quick Check:

    Method call with numeric radius = correct syntax [OK]
Hint: Look for method call with numeric argument for radius [OK]
Common Mistakes:
  • Using string instead of number for radius
  • Incorrect property names
  • Missing parentheses for method call
3. Given the code snippet:
drone.setWaypointRadius(3)
drone.moveTo(10, 10)
print(drone.hasReachedWaypoint())

If the drone is currently at (12, 12), what will be the output?
medium
A. False
B. True
C. Error
D. None

Solution

  1. 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.
  2. 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.
  3. Step 3: Check output of hasReachedWaypoint()

    Since the drone is inside the radius, hasReachedWaypoint() returns True.
  4. Final Answer:

    True -> Option B
  5. 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

  1. Step 1: Check how waypoint radius is set

    The code uses drone.setWaypointRadius = 4, which assigns a number to a method name, overwriting it.
  2. Step 2: Identify correct syntax

    The radius should be set by calling the method: drone.setWaypointRadius(4), not by assignment.
  3. Final Answer:

    Incorrect method call syntax for setting radius -> Option A
  4. 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

  1. 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.
  2. 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.
  3. 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.
  4. Final Answer:

    The drone will consider each waypoint reached when within 2 meters, allowing smooth flight without stopping exactly on points -> Option C
  5. Quick Check:

    Radius acceptance enables smooth waypoint transitions [OK]
Hint: Radius lets drone accept waypoint nearby, no exact stop needed [OK]
Common Mistakes:
  • Thinking radius affects altitude only
  • Assuming drone must stop exactly on waypoint
  • Believing radius causes ignoring waypoints