0
0
Drone Programmingprogramming~10 mins

Waypoint radius and acceptance in Drone Programming - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Waypoint radius and acceptance
Start at current position
Calculate distance to waypoint
Is distance <= radius?
NoMove drone closer
|Yes
Waypoint accepted
Proceed to next waypoint or stop
The drone checks if it is within a set radius of the waypoint. If yes, it accepts the waypoint and moves on. If no, it moves closer and checks again.
Execution Sample
Drone Programming
current_pos = (0, 0)
waypoint = (5, 5)
radius = 2
while True:
    dist = distance(current_pos, waypoint)
    if dist <= radius:
        break
    current_pos = move_towards(current_pos, waypoint)
This code moves the drone towards a waypoint until it is within the acceptance radius.
Execution Table
Stepcurrent_posdistance to waypointCondition (dist <= radius)ActionOutput
1(0, 0)7.07FalseMove closerPosition updated
2(1, 1)5.66FalseMove closerPosition updated
3(2, 2)4.24FalseMove closerPosition updated
4(3, 3)2.83FalseMove closerPosition updated
5(4, 4)1.41TrueAccept waypointExit loop
6(4, 4)1.41TrueStop movingWaypoint accepted
💡 At step 5, distance 1.41 <= radius 2, so waypoint is accepted and loop exits.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
current_pos(0, 0)(1, 1)(2, 2)(3, 3)(4, 4)(4, 4)(4, 4)
distance7.075.664.242.831.411.411.41
condition (dist <= radius)FalseFalseFalseFalseTrueTrueTrue
Key Moments - 3 Insights
Why does the drone accept the waypoint when distance is less than or equal to the radius?
Because the acceptance radius defines how close the drone must be to consider the waypoint reached, as shown in step 5 where distance 1.41 <= radius 2 triggers acceptance.
What happens if the drone is exactly on the edge of the radius?
The condition dist <= radius is True, so the waypoint is accepted immediately, just like in step 5 where distance 1.41 is less than radius 2.
Why does the drone keep moving when distance is greater than the radius?
Because the drone must get closer to the waypoint before accepting it, as seen in steps 1 to 4 where distance is greater than radius and the drone moves closer.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the drone's position at step 3?
A(3, 3)
B(2, 2)
C(1, 1)
D(4, 4)
💡 Hint
Check the 'current_pos' column at step 3 in the execution_table.
At which step does the condition dist <= radius become true?
AStep 4
BStep 3
CStep 5
DStep 6
💡 Hint
Look at the 'Condition (dist <= radius)' column in the execution_table.
If the radius was set to 1 instead of 2, at which step would the drone accept the waypoint?
AStep 6
BStep 5
CStep 4
DStep 3
💡 Hint
Compare distances in the execution_table with radius 1 to find when dist <= radius.
Concept Snapshot
Waypoint radius and acceptance:
- The drone moves towards a waypoint.
- It checks distance to waypoint each step.
- If distance <= radius, waypoint is accepted.
- Otherwise, drone moves closer and checks again.
- Radius defines how close is 'close enough'.
Full Transcript
This visual execution shows how a drone moves towards a waypoint and accepts it when within a set radius. Starting at position (0,0), the drone calculates distance to the waypoint at (5,5). It moves closer step by step, updating position and distance. When the distance becomes less than or equal to the radius (2 units), the drone accepts the waypoint and stops moving. The execution table tracks each step's position, distance, condition check, and action. Key moments clarify why the drone accepts the waypoint at the radius boundary and why it moves closer when outside the radius. The quiz questions test understanding of position updates, condition checks, and effects of changing the radius.