0
0
Pcb-designHow-ToBeginner · 4 min read

Drone Project for Mapping and Surveying: Step-by-Step Guide

A drone project for mapping and surveying involves programming the drone to fly predefined GPS waypoints using mission planning, capturing geotagged images with camera control, and processing the images with photogrammetry software to create maps and 3D models.
📐

Syntax

Here is the basic syntax pattern for programming a drone mission for mapping and surveying:

  • Connect to drone: Establish communication with the drone using its API.
  • Define waypoints: Set GPS coordinates for the drone to follow.
  • Set camera commands: Trigger image capture at each waypoint.
  • Start mission: Upload and start the mission on the drone.
  • Monitor mission: Track progress and handle errors.
python
from dronekit import connect, VehicleMode, LocationGlobalRelative
import time

# Connect to the drone
vehicle = connect('127.0.0.1:14550', wait_ready=True)

# Define a waypoint
waypoint = LocationGlobalRelative(37.7749, -122.4194, 50)  # lat, lon, altitude in meters

# Function to arm and takeoff
def arm_and_takeoff(target_altitude):
    vehicle.mode = VehicleMode('GUIDED')
    vehicle.armed = True
    while not vehicle.armed:
        time.sleep(1)
    vehicle.simple_takeoff(target_altitude)
    while True:
        if vehicle.location.global_relative_frame.alt >= target_altitude * 0.95:
            break
        time.sleep(1)

# Arm and takeoff to 50 meters
arm_and_takeoff(50)

# Fly to waypoint
vehicle.simple_goto(waypoint)

# Simulate image capture
print('Capturing image at waypoint')

# Land the drone
vehicle.mode = VehicleMode('LAND')

# Close vehicle object
vehicle.close()
Output
Capturing image at waypoint
💻

Example

This example shows a simple drone mission that takes off, flies to a GPS waypoint, captures an image, and lands. It uses the dronekit Python library to control the drone.

python
from dronekit import connect, VehicleMode, LocationGlobalRelative
import time

# Connect to the drone
vehicle = connect('127.0.0.1:14550', wait_ready=True)

# Define waypoints for mapping
waypoints = [
    LocationGlobalRelative(37.7749, -122.4194, 50),
    LocationGlobalRelative(37.7750, -122.4180, 50),
    LocationGlobalRelative(37.7755, -122.4170, 50)
]

# Arm and takeoff function
def arm_and_takeoff(target_altitude):
    print('Arming motors')
    vehicle.mode = VehicleMode('GUIDED')
    vehicle.armed = True
    while not vehicle.armed:
        time.sleep(1)
    print('Taking off')
    vehicle.simple_takeoff(target_altitude)
    while True:
        if vehicle.location.global_relative_frame.alt >= target_altitude * 0.95:
            print('Reached target altitude')
            break
        time.sleep(1)

# Start mission
arm_and_takeoff(50)

for point in waypoints:
    print(f'Flying to waypoint at {point.lat}, {point.lon}')
    vehicle.simple_goto(point)
    time.sleep(15)  # wait to reach waypoint
    print('Capturing image')

print('Mission complete, landing')
vehicle.mode = VehicleMode('LAND')
vehicle.close()
Output
Arming motors Taking off Reached target altitude Flying to waypoint at 37.7749, -122.4194 Capturing image Flying to waypoint at 37.775, -122.418 Capturing image Flying to waypoint at 37.7755, -122.417 Capturing image Mission complete, landing
⚠️

Common Pitfalls

Common mistakes when programming drone mapping projects include:

  • Not waiting for the drone to arm before takeoff, causing errors.
  • Setting waypoints too close or too far apart, leading to poor map coverage or battery drain.
  • Failing to trigger the camera at each waypoint, missing images.
  • Ignoring drone battery levels and flight time limits.
  • Not handling GPS signal loss or communication errors.

Always test missions in a safe environment and monitor drone status closely.

python
from dronekit import connect, VehicleMode, LocationGlobalRelative
import time

# WRONG: Not waiting for arming
vehicle = connect('127.0.0.1:14550', wait_ready=True)
vehicle.mode = VehicleMode('GUIDED')
vehicle.armed = True
while not vehicle.armed:
    time.sleep(1)
vehicle.simple_takeoff(50)  # May fail if not armed yet

# RIGHT: Wait for arming
while not vehicle.armed:
    time.sleep(1)
vehicle.simple_takeoff(50)
📊

Quick Reference

  • Connect: Use connect() with correct address.
  • Arm: Set mode to GUIDED and wait for armed to be True.
  • Takeoff: Use simple_takeoff(altitude) and wait to reach altitude.
  • Waypoints: Use LocationGlobalRelative(lat, lon, alt) and simple_goto().
  • Camera: Trigger image capture at each waypoint (depends on drone API).
  • Land: Set mode to LAND.

Key Takeaways

Program the drone to fly GPS waypoints and capture images for mapping.
Always wait for the drone to arm before takeoff to avoid errors.
Plan waypoints carefully to cover the survey area efficiently.
Trigger the camera at each waypoint to collect geotagged images.
Monitor battery and GPS signals during the mission for safety.