Bird
Raised Fist0
Drone Programmingprogramming~10 mins

Waypoint mission creation in Drone Programming - Step-by-Step Execution

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
Concept Flow - Waypoint mission creation
Start Mission Setup
Define Waypoints List
Add Waypoints One by One
Set Parameters for Each Waypoint
Upload Mission to Drone
Start Mission Execution
Drone Flies to Each Waypoint in Order
Mission Complete
This flow shows how a waypoint mission is created by defining waypoints, setting parameters, uploading to the drone, and then executing the mission.
Execution Sample
Drone Programming
mission = []
mission.append({'lat': 40.0, 'lon': -74.0, 'alt': 100})
mission.append({'lat': 40.1, 'lon': -74.1, 'alt': 120})
upload_mission(mission)
start_mission()
This code creates a mission with two waypoints, uploads it to the drone, and starts the mission.
Execution Table
StepActionWaypoints ListDrone CommandOutput
1Initialize empty mission list[]NoneMission list is empty
2Add first waypoint[{'lat': 40.0, 'lon': -74.0, 'alt': 100}]NoneWaypoint 1 added
3Add second waypoint[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneWaypoint 2 added
4Upload mission to drone[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]upload_mission(mission)Mission uploaded
5Start mission execution[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]start_mission()Drone starts flying to waypoint 1
6Drone reaches waypoint 1[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneReached waypoint 1
7Drone flies to waypoint 2[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneFlying to waypoint 2
8Drone reaches waypoint 2[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneReached waypoint 2
9Mission complete[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneMission finished
10Exit[{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]NoneAll waypoints visited, mission ends
💡 All waypoints visited, mission ends
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5Final
mission[][{'lat': 40.0, 'lon': -74.0, 'alt': 100}][{'lat': 40.0, 'lon': -74.0, 'alt': 100}, {'lat': 40.1, 'lon': -74.1, 'alt': 120}]Same as after step 3Same as after step 3Same as after step 3
Key Moments - 3 Insights
Why do we need to add waypoints one by one instead of all at once?
Adding waypoints one by one (see steps 2 and 3 in execution_table) helps build the mission list gradually and allows setting parameters for each waypoint clearly.
What happens if we start the mission before uploading it?
If you start the mission before uploading (step 5), the drone has no waypoints to follow, so it won't fly the mission. Uploading (step 4) is necessary to send the mission to the drone.
How does the drone know when the mission is complete?
The drone knows the mission is complete after reaching the last waypoint (step 8), then it stops flying the mission (step 9 and 10).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, how many waypoints are in the mission list?
A2
B1
C3
D0
💡 Hint
Check the 'Waypoints List' column at step 3 in the execution_table.
At which step does the drone start flying to the first waypoint?
AStep 4
BStep 6
CStep 5
DStep 7
💡 Hint
Look at the 'Drone Command' and 'Output' columns in the execution_table for when the mission starts.
If we add a third waypoint before uploading, how would the mission list look after step 3?
ATwo waypoints only
BThree waypoints in the list
CEmpty list
DOne waypoint only
💡 Hint
Refer to the variable_tracker and execution_table to understand how waypoints are added.
Concept Snapshot
Waypoint mission creation steps:
1. Create empty mission list
2. Add waypoints with lat, lon, alt
3. Upload mission to drone
4. Start mission execution
5. Drone flies waypoints in order
6. Mission ends after last waypoint
Full Transcript
Waypoint mission creation involves making a list of points the drone will fly to. We start with an empty list, add each waypoint with its location and altitude, then upload this list to the drone. After uploading, we start the mission, and the drone flies to each waypoint one by one. When the drone reaches the last waypoint, the mission is complete and the drone stops flying the mission.

Practice

(1/5)
1. What is the main purpose of creating a waypoint mission for a drone?
easy
A. To make the drone fly automatically through specific GPS points
B. To manually control the drone with a remote
C. To charge the drone's battery faster
D. To change the drone's camera settings

Solution

  1. Step 1: Understand waypoint missions

    Waypoint missions are designed to let drones fly automatically through set GPS points without manual control.
  2. Step 2: Compare options

    Only To make the drone fly automatically through specific GPS points describes automatic flight through GPS points, which matches the purpose of waypoint missions.
  3. Final Answer:

    To make the drone fly automatically through specific GPS points -> Option A
  4. Quick Check:

    Waypoint mission = automatic GPS flight [OK]
Hint: Waypoint missions automate flight through GPS points [OK]
Common Mistakes:
  • Confusing manual control with automatic missions
  • Thinking waypoint missions change camera or battery
  • Assuming speed control is the main purpose
2. Which of the following is the correct way to add a waypoint with latitude, longitude, and altitude in a drone mission code snippet?
easy
A. waypoint_add(100, 34.05, -118.25)
B. add_waypoint(altitude=100, lat=34.05, long=-118.25)
C. addWaypoint(34.05, -118.25)
D. add_waypoint(latitude=34.05, longitude=-118.25, altitude=100)

Solution

  1. Step 1: Identify correct parameter names and order

    The standard is to specify latitude, longitude, and altitude clearly, usually with named parameters or in order.
  2. Step 2: Check each option

    add_waypoint(latitude=34.05, longitude=-118.25, altitude=100) uses clear parameter names and correct order. Others have wrong names, missing altitude, or wrong order.
  3. Final Answer:

    add_waypoint(latitude=34.05, longitude=-118.25, altitude=100) -> Option D
  4. Quick Check:

    Correct parameter names and order = add_waypoint(latitude=34.05, longitude=-118.25, altitude=100) [OK]
Hint: Use clear latitude, longitude, altitude parameters [OK]
Common Mistakes:
  • Using wrong parameter names like lat or long instead of latitude/longitude
  • Omitting altitude
  • Wrong function name or missing parameters
3. Given the following code snippet for a waypoint mission:
mission = []
mission.append({'lat': 40.0, 'lon': -74.0, 'alt': 50})
mission.append({'lat': 40.1, 'lon': -74.1, 'alt': 60})
speed = 10
print(len(mission), mission[1]['alt'], speed)
What will be the output?
medium
A. 2 60 10
B. 2 50 10
C. 1 60 10
D. 2 60 0

Solution

  1. Step 1: Count waypoints in mission list

    Two waypoints are appended, so len(mission) is 2.
  2. Step 2: Access altitude of second waypoint and speed

    mission[1]['alt'] is 60, and speed is set to 10.
  3. Final Answer:

    2 60 10 -> Option A
  4. Quick Check:

    Waypoints=2, altitude=60, speed=10 [OK]
Hint: Count list items and check dictionary keys carefully [OK]
Common Mistakes:
  • Confusing index 0 and 1 for second waypoint
  • Mixing altitude values
  • Ignoring speed variable
4. Identify the error in this waypoint mission code snippet:
mission = []
mission.add({'latitude': 35.0, 'longitude': -120.0, 'altitude': 80})
speed = 15
print(len(mission))
medium
A. Incorrect variable name 'speed'
B. Using 'add' method instead of 'append' for list
C. Missing altitude value in waypoint dictionary
D. Print statement syntax error

Solution

  1. Step 1: Check list method usage

    Python lists use 'append' to add items, not 'add'. Using 'add' causes an error.
  2. Step 2: Verify other parts

    Altitude is present, variable names are correct, and print syntax is valid.
  3. Final Answer:

    Using 'add' method instead of 'append' for list -> Option B
  4. Quick Check:

    List method must be append, not add [OK]
Hint: Use append() to add items to a list [OK]
Common Mistakes:
  • Using set methods like add() on lists
  • Forgetting to include altitude
  • Typos in variable names
5. You want to create a waypoint mission where the drone flies through three points with these coordinates and altitudes using dictionary keys 'latitude', 'longitude', 'altitude': 1) (34.0, -117.0, 100m) 2) (34.1, -117.1, 120m) 3) (34.2, -117.2, 110m) You also want the drone to fly at 8 m/s between points. Which code snippet correctly creates this mission and sets the speed?
hard
A. mission = [{'lat':34.0, 'lon':-117.0, 'alt':100}, {'lat':34.1, 'lon':-117.1, 'alt':120}, {'lat':34.2, 'lon':-117.2, 'alt':110}] speed = 8
B. mission = [] mission.add({'lat':34.0, 'lon':-117.0, 'alt':100}) mission.add({'lat':34.1, 'lon':-117.1, 'alt':120}) mission.add({'lat':34.2, 'lon':-117.2, 'alt':110}) speed = 8
C. mission = [] mission.append({'latitude':34.0, 'longitude':-117.0, 'altitude':100}) mission.append({'latitude':34.1, 'longitude':-117.1, 'altitude':120}) mission.append({'latitude':34.2, 'longitude':-117.2, 'altitude':110}) speed = 8
D. mission = [{'lat':34.0, 'lon':-117.0}, {'lat':34.1, 'lon':-117.1}, {'lat':34.2, 'lon':-117.2}] speed = 8

Solution

  1. Step 1: Check waypoint creation with correct keys

    mission = [] mission.append({'latitude':34.0, 'longitude':-117.0, 'altitude':100}) mission.append({'latitude':34.1, 'longitude':-117.1, 'altitude':120}) mission.append({'latitude':34.2, 'longitude':-117.2, 'altitude':110}) speed = 8 uses 'latitude', 'longitude', and 'altitude' keys consistently, matching the given data.
  2. Step 2: Verify method to add waypoints and speed setting

    mission = [] mission.append({'latitude':34.0, 'longitude':-117.0, 'altitude':100}) mission.append({'latitude':34.1, 'longitude':-117.1, 'altitude':120}) mission.append({'latitude':34.2, 'longitude':-117.2, 'altitude':110}) speed = 8 uses append() correctly to add waypoints and sets speed to 8 m/s as required.
  3. Step 3: Eliminate incorrect options

    mission = [{'lat':34.0, 'lon':-117.0, 'alt':100}, {'lat':34.1, 'lon':-117.1, 'alt':120}, {'lat':34.2, 'lon':-117.2, 'alt':110}] speed = 8 uses different keys ('lat', 'lon', 'alt') which are inconsistent with required keys. mission = [] mission.add({'lat':34.0, 'lon':-117.0, 'alt':100}) mission.add({'lat':34.1, 'lon':-117.1, 'alt':120}) mission.add({'lat':34.2, 'lon':-117.2, 'alt':110}) speed = 8 uses 'add' which is invalid for lists. mission = [{'lat':34.0, 'lon':-117.0}, {'lat':34.1, 'lon':-117.1}, {'lat':34.2, 'lon':-117.2}] speed = 8 misses altitude values.
  4. Final Answer:

    mission = [] mission.append({'latitude':34.0, 'longitude':-117.0, 'altitude':100}) mission.append({'latitude':34.1, 'longitude':-117.1, 'altitude':120}) mission.append({'latitude':34.2, 'longitude':-117.2, 'altitude':110}) speed = 8 -> Option C
  5. Quick Check:

    Correct keys + append() + speed = mission = [] mission.append({'latitude':34.0, 'longitude':-117.0, 'altitude':100}) mission.append({'latitude':34.1, 'longitude':-117.1, 'altitude':120}) mission.append({'latitude':34.2, 'longitude':-117.2, 'altitude':110}) speed = 8 [OK]
Hint: Use append() with full keys and set speed separately [OK]
Common Mistakes:
  • Using add() instead of append()
  • Missing altitude in waypoints
  • Mixing key names inconsistently