Take Flight with H4WK

Part 5: Advanced Flight and Autonomous Missions

Anthony Feizi

Issue 11, May 2018

The on-board GPS module allows automated flight, with pre-planned missions!

ASSUMED KNOWLEDGE: The Complete DIY Quadcopter Project This is Part 5 of our massive H4WK project. If you missed parts 1-4, you can find them in Issue #010. To provide this article with context, and understand the capabilities of our H4WK drone, we recommend reading those parts before moving on to this. If you have a reasonable understanding of Drones already, this article may still be of interest. The principles do apply to any mission-capable drone using Ardupilot / APM Planner, not just our H4WK project.

Flying manually is great but it’s time to get more in-depth with our quadcopter and start to use the more advanced features. Autonomous flying opens up new doors to what we can do with our quadcopter; such as accurately surveying an area, or creating a smooth cinematic flight path to mimic a camera slider. Automated / planned flight will always provide a smoother visual experience than manual controls (unless you have Jedi-like piloting skills).


Before we go into auto missions, I want to introduce you to the full parameter list. This is a complete list of the parameters that can be set to control the behaviour of your aircraft.

parameter list

The full parameter list is handy to make changes to particular parameters you cannot find in the control software itself. To make a change:

  • Find the required parameter
  • Adjust the arguments to your needs
  • Click “Write Parameter” (writes the new values to the autopilot)
  • Click “Refresh Parameter” list

For a full break down on all the parameters for copters visit:


In AUTO mode, the aircraft will follow a pre-programmed mission script stored in the autopilot. These commands are made up of waypoints (navigation commands) and DO commands, which are commands that do not affect the location of the aircraft.

Before attempting the AUTO mode make sure your aircraft is flying well in Althold and Loiter modes, as the AUTO mode uses altitude control and position control from these modes. Also make sure that the vibration levels and compass interference levels are at an acceptable level, and that the GPS is functioning well and the HDOP (which is a measure of position accuracy) is under 2.0. To see how to analyse these levels, check out the documentation at or to learn how to check them, then refer to the info at the end of this article.

auto flight


Before we get into controlling your quad autonomously, it’s good to take a look into how the flight controller communicates to send and receive messages for autonomous control.

Our flight controller and ground station use a communication protocol called MAVLink. It’s a super lightweight, message marshalling library for micro air vehicles, as well as underwater and ground vehicles.

The MAVLink message is basically a stream of bytes that is encoded and sent over USB serial, cellular, radio telemetry, and the like. Each message is structured in the following way:

Message length = 17 bytes (6 bytes header + 9 bytes payload + 2 bytes checksum)

While it’s not important to know what’s inside the message for regular autonomous flight, it will become important once you start playing around with companion computers for the flight controller, or when you want to write your own custom MAVLink messages.

Below is the breakdown of what is sent:

Message PartByteDescription
HEADER0Message header, always 0xFE
HEADER1Message length
HEADER2Sequence number, rolls from 0 to 255
HEADER 3System ID: This is the source (i.e. Mission planner) sending a message. The source conducts a regular check it can make sure that this message is for itself.
HEADER4Component ID: What component of the system is sending the message.
HEADER5Message ID: What is this message about. (e.g. 0 = heartbeat)
PAYLOAD6Variable sized payload
PAYLOAD7-14Variable sized payload


It’s very important to take care when planning your missions, as it’s quite easy to enter incorrect values. Always double check missions before conducting them. And before attempting your first automission, I recommend getting more comfortable with manual and stabilised flight, as well as the AltHold and Loiter flight modes.

For your first flight, head to an open field that is safe to fly in. Be sure to let other pilots and people (if around) know that you will be conducting an automission.

Always be ready to take manual control of the aircraft in the event that anything goes wrong.

Pack list:

The Drone:

Check aircraft is in flight worthy condition, including:

At the site:

Other considerations:

Overview of Flight Plan

overview of flight plan


The autonomous commands listed below are specific to multirotors. Planes and rovers have a slightly different set of instructions.

Navigational commands

Used to control the movement and location of the aircraft. This includes takeoff, landing, waypoints and adjusting altitude.


TAKEOFF : An aircraft will climb straight up from its current position to a specified altitude. If the aircraft is already at the specified altitude, the autopilot will ignore the takeoff command, mark it as complete, and then move on to the next command.


WAYPOINT (WPs): Aircraft will travel in a straight line to the location at a specified longitude, latitude and altitude.

  • DELAY: The amount of time to wait at that waypoint before moving on
  • LAT, LONG: The latitude and longitude targets. If it is 0, it will hold its current position
  • ALT: The target altitude in metres
spline WP

SPLINE WAYPOINT: The Spline WPs takes in all the same arguments as regular WPs, but when used the aircraft will fly smooth paths. Spline WPs can be mixed with regular WPs.

loiter time

LOITER_TIME: The aircraft will fly to and wait at the location specified, for a specified number of seconds.

  • TIMES: The number of seconds to remain at the location
  • LAT, LONG: The latitude and longitude targets. If it is 0, it will hold its current position
  • ALT: The target altitude in metres
loiter turn

LOITER_TURNS: The aircraft will fly a circle around the specified lat, long and altitude. The radius of the circle cannot be set as part of the mission, and must be set by the CIRCLE_RADIUS Parameter.

  • TURN: The number of full rotations around the point, to complete
  • DIR 1=CW: The direction to turn around the point. Counter clockwise = -1 and clockwise = 1
  • LAT, LONG: The latitude and longitude targets. If it is 0, it will hold its current position
  • ALT: The target altitude in metres
loiter unlimited

LOITER_UNLIMITED: The aircraft will fly to and wait at the specified location indefinitely. The mission will not proceed past this command.

  • LAT, LONG: The latitude and longitude targets. If it is 0, it will hold its current position
  • ALT: The target altitude in metres
return to launch

RETURN-TO-LAUNCH: The aircraft will first climb to the RTL_ALT parameter’s specified altitude (it is set to 15m by default) then returns to the home position. This should generally be the last command of the mission


LAND: The aircraft will land at its current location or at a specified lat/long

  • ALT: The target altitude in metres

DELAY: The aircraft will remain at its current location until a number of seconds have passed, or if absolute time has been reached

  • SECONDS: The number of seconds to delay. Set to -1 to ignore
  • “HOUR UTC”, “MINUTE UTC, “SECOND UTC”: Used to specify an absolute time in UTC. Set the hour or minute to -1 to ignore
payload place

PACKAGE PLACE: The aircraft will travel to the specified location and will descend until it senses that the package has touched the ground. The gripper will then release to unload the package.

  • “MAX DESCENT”: The maximum descent (in metres) that the aircraft should descend. If the package does not reach the ground, the package will not be released, and the aircraft will proceed with the next command

DO Commands

Used for auxiliary functions such as camera triggers or servo values. These do not affect the position of the aircraft.


DO-SET-ROI: Points the nose of the aircraft and camera gimbal to the “region of interest

  • LAT, LONG: The latitude and longitude targets. If it is 0, it will hold its current position
  • ALT: The target altitude in metres

DO-JUMP: Jump to the specified mission command and repeat the number of times specified. Then continue on with the mission.

  • WP #: The mission command to jump to
  • REPEAT: The maximum number of times to jump to that command. -1 means always jump

DO-CHANGE-SPEED: Changes the maximum horizontal velocity (in metres/second) of the aircraft.

  • SPEED M/S: the desired maximum velocity in m/s

DO-SET-CAM-TRIGG-DIST: Trigger the camera shutter at regular distance intervals.

  • DIST (M): Distance interval in metres

DO-SET-RELAY: Set a relay pin voltage high or low

  • RELAY NUMBER: For the first relay set to 0, and for the second relay set to 1
  • ON/OFF: 0 = Off (0V), 1 = On (3.3V)

DO-REPEAT-RELAY: Toggle the relay pin voltage for a specific number of times.

  • RELAY NUMBER: For the first relay set to 0, and for the second relay set to 1
  • REPEAT #: How many times it should be toggled
  • DELAY (S): Number of seconds between each toggle

DO-SET-SERVO: Move a servo to a specific PWM value.

  • SER NO: the output channel that the servo is connected to
  • PWM: PWM value to send to the servo
do repeat servo
drone in flight

DO-REPEAT-SERVO: Toggles a servo back and forth from the mid-position to the specified PWM value.

  • SER NO: the output channel that the servo is connected to
  • PWM: PWM value to send to the servo
  • REPEAT #: How many times it should be toggled
  • DELAY (S): Number of seconds between each toggle

DO-DIGICAM-CONTROL: Trigger the camera shutter once.


DO-MOUNT-CONTROL: Specify a roll, pitch and yaw angle to control a camera gimbal.


DO-GRIPPER: Allows you to open or close a servo or EPM gripper.

  • DROP/GRAB: to close gripper set to 0 and to open gripper set to 1

Condition Commands

Used to delay DO commands until a condition is met. For example when the aircraft reaches a certain distance away from the waypoint.


CONDITION-DELAY: Delays the start of the next DO command for a specified number of seconds.

  • TIME: Time to delay in seconds

CONDITION-DISTANCE: Delays the next DO command until the aircraft is within the specified number of meters from the next WP.

  • DIST (M): Distance from the next WP in metres before proceeding with the next DO command

CONDITION-YAW: Point the nose of the aircraft to the specified heading by a specified amount.

  • DEG: Desired heading in degrees when “rel/abs = 0 or the change in the heading when “rel/abs = 1.
  • DIR (1=CW, -1=CCW): Used when relative heading is specified (i.e., when “rel/abs = 1”). Lets the flight controller know whether it should add (CW) or subtract (CCW) the degrees (Deg) from the current heading to calculate the target heading.
  • REL/ABS: Whether the heading is an absolute heading (=0) or relative to the current heading (=1)

Conducting An Auto Mission

Connect to the quadcopter via the telemetry radios.

Firstly, we need to set one of the positions of our flight mode switch to AUTO. I recommend using these flight modes and putting them in the following order:

  1. Stabilised
  2. AltHold
  3. AUTO

This ensures that in the event of an emergency while flying in AUTO mode, you can flick the switch to AltHold, which will hold the altitude, enabling you to then carefully switch to Stabilised, so you can guide the quadcopter back home or land it.

Now we need to set the home position. In copter, the home position automatically logged as the location where the copter was armed. This means if you execute the Return to Location (RTL) command it will go back to the location where it was armed. So make sure you arm the copter in the location you want it to return to.

In the Flight Plan window you can also click and drag the home marker to a position you want.

Making A mission

Keep in mind, the altitude is relative to the home position (home altitude = 0).

In the dropdrop down menu in each row, select the command you require. The column heading will change depending on the required arguments of the selected command. Lat and Long can be entered by clicking on the map. Your first command should always be TAKEOFF, and once you are finished designing the mission, add a RTL or LAND command as the last command.

Other important tools:

  • Default Alt is the default altitude when making new waypoints.
  • Verify height will allow Mission Planner to use Google Earth topology data to adjust your desired altitude at each WP, by referencing the ground beneath it.

Once the mission has been made and has checked, select “Write WPs” and it will be sent to the flight board and saved in EEPROM.

We are now ready to start our basic mission.

  1. Arm the motors while in stabilised mode. You cannot enter AUTO mode if your aircraft is not armed.
  2. Switch the flight mode to AUTO.
  3. Raise throttle above 0. The quadcopter will begin its mission.
  4. If you notice anything wrong while the quadcopter is flying, immediately switch it to AltHold.

Note: If you switch to a flight mode other than AUTO during a mission and go back to AUTO, the mission will restart and proceed with the first command. During the mission, the pilot’s inputs for roll, pitch and throttle will be ignored; however, the pilot’s input for yaw will move the aircraft. This allows the pilot to point the nose of the aircraft for hard-mounted cameras.

When the aircraft lands at a given location or returns to the launch position, as the aircraft touches the ground, the pilot should move the throttle stick to zero. The autopilot will disarm the motors when it believes it has landed.

drone hover

NEXT: PART 6: Understanding Brushless Camera Gimbals

PART 1: The Basics

PART 2: Construction

PART 3: Software & Setup

PART 4: Repairing Your Drone