0
0
Drone Programmingprogramming~10 mins

goto() command for navigation in Drone Programming - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - goto() command for navigation
Start
Call goto(x, y, z)
Calculate path to (x, y, z)
Move drone step-by-step
Check if reached (x, y, z)?
NoContinue moving
Yes
Stop movement
End
The drone receives a goto(x, y, z) command, calculates the path, moves step-by-step, checks if it reached the target, and stops when it arrives.
Execution Sample
Drone Programming
goto(10, 5, 3)
// Drone moves from current position to (10,5,3)
// Stops when it reaches the target
This code moves the drone from its current position to coordinates (10, 5, 3) and stops when it arrives.
Execution Table
StepCurrent Position (x,y,z)Target Position (x,y,z)Distance to TargetActionOutput
1(0,0,0)(10,5,3)CalculatedStart moving towards targetMoving
2(2,1,0.6)(10,5,3)8.7Continue movingMoving
3(5,2.5,1.5)(10,5,3)5.9Continue movingMoving
4(8,4,2.4)(10,5,3)2.4Continue movingMoving
5(10,5,3)(10,5,3)0Reached target, stopStopped
6---End of navigation-
💡 Drone reached target position (10,5,3), distance is zero, navigation stops.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
current_position(0,0,0)(2,1,0.6)(5,2.5,1.5)(8,4,2.4)(10,5,3)(10,5,3)(10,5,3)
distance_to_targetCalculated8.75.92.4000
statusIdleMovingMovingMovingMovingStoppedStopped
Key Moments - 3 Insights
Why does the drone keep moving even when it is close to the target but not exactly there?
Because the distance to target is not zero yet (see execution_table steps 2-4), the drone continues moving until it exactly reaches the target.
What happens when the drone reaches the exact target coordinates?
At step 5 in the execution_table, distance becomes zero, so the drone stops moving and the navigation ends.
Does the drone jump directly to the target position?
No, the drone moves step-by-step towards the target, updating its position gradually as shown in the variable_tracker.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the drone's position at Step 3?
A(2,1,0.6)
B(8,4,2.4)
C(5,2.5,1.5)
D(10,5,3)
💡 Hint
Check the 'Current Position' column at Step 3 in the execution_table.
At which step does the drone stop moving?
AStep 4
BStep 5
CStep 3
DStep 2
💡 Hint
Look for the 'Action' column where it says 'Reached target, stop'.
If the drone started at (1,1,1) instead of (0,0,0), how would the distance at Step 1 change?
AIt would be smaller
BIt would be zero
CIt would be larger
DIt would be the same
💡 Hint
Distance depends on how far the drone is from the target at start, see variable_tracker for distance changes.
Concept Snapshot
goto(x, y, z) moves the drone to the target coordinates.
The drone moves step-by-step, checking distance each time.
When distance is zero, the drone stops.
Useful for precise navigation in 3D space.
Full Transcript
The goto() command tells the drone to move to a specific point in space. The drone calculates the path and moves step-by-step, updating its position and checking how far it is from the target. It keeps moving until it reaches the exact coordinates, then it stops. This process is shown step-by-step in the execution table and variable tracker, helping beginners see how the drone's position and status change over time.