Chapter 9. ArduPilot Mega (APM) Setup

At this point, the vast majority of your physical build is complete. Now it’s time to jump into Mission Planner and start setting up your autopilot. Once we complete this process, we will have just a few minor things to button up on the build and then our aircraft will be ready to fly!

This chapter will be structured a little different than the rest, as we will go straight into the step-by-step instructions before looking at the rest of the Mission Planner application.

Step-by-Step Build Instructions

For this portion of the build, you will need:

  • A laptop PC running Windows 7 or newer (if you only have a Mac, try setting up a Boot Camp partition to install Windows)
  • The most recent version of the Mission Planner application
  • A Micro “B” USB 1.1/2.0 cable

Step 1: Update Firmware

The very first thing we should do is make sure we are running the most current version of the firmware. Depending on when your APM was made, it could have a number of different versions on it. Don’t take a chance using what it shipped with; go through the process of updating, and then you can be sure you are on the right track:

  1. Power up your laptop and open Mission Planner.
  2. Plug the USB cable into the APM with the other end going into your laptop.
  3. Go to the Initial Setup tab in Mission Planner and click Install Firmware in the left-hand menu.
  4. From the graphic buttons in the middle of the screen, select ArduCopter vX.X Quad (where vX.X is your version number) as the firmware type; see Figure 9-1.
Figure 9-1. Select the type of firmware you need to update (ArduCopter Quad, in our case).
  1. You will be asked to confirm that you do want to update the firmware. Click Yes to continue (see Figure 9-2).
  1. Mission Planner will locate the most recent version of the APM firmware that is available for your hardware and start the update process. Click OK to proceed (see Figure 9-3).
  1. Firmware uploading begins (see Figure 9-4).
  1. After the firmware is uploaded, it needs to be verified (see Figure 9-5).
  1. After the update is complete, Mission Planner alerts you to any additional steps that may need to take place as a result of the update (see Figure 9-6).
Figure 9-2. Confirm that you want to upgrade by clicking YES.
Figure 9-3. Mission Planner automatically finds the most recent firmware version supported by your APM.
Figure 9-4. Firmware upload has begun.
Figure 9-5. Firmware verification in progress.
Figure 9-6. We are all done! Click OK to proceed.

Stay Connected

Do not disconnect the USB cable from your APM until the update is complete. It’s very important that you keep an eye on the progress bar to see when the upgrade is complete and never interrupt the process.

Step 2: Connect and Complete Mandatory Setup

​Now that we have updated our firmware, we have a nice clean slate to start from. Let’s walk through our mandatory setup now and get this bird ready to fly!

There are actually two ways you can complete this step. One is to use the Wizard that is located directly under the Install Firmware button you used in the last step. The second way is to do it manually. We are going to walk through the manual process in this example, but both ways are essentially the same thing; the wizard just forces you to do all the steps together, while manual entry allows you to do only the steps you want. Any time we set up a new copter, we want to complete all of these steps, but there may be times in the future where you also want to revisit just one or two of these steps—such as GPS or IMU calibration—and we want to you show you that from the beginning.

Before we can set anything up, we need to connect our APM to Mission Planner. This requires you to select the COM port and Baud Rate before clicking the Connect button in the upper-right corner of the application. Once you connect, you will notice a new set of menu options appear in the left-hand column, including Mandatory Hardware and Optional Hardware.

Step 2.1: Set frame type

Click the Frame type button from the left-hand column under the Mandatory Hardware heading and select the X copter category (see Figure 9-7).

Ignore the Default Settings

You will notice that next to your frame selections is a drop-down menu titled Default Settings. You can ignore that during this build. It is used as a shortcut for certain off-the-shelf drones. For example, if you owned a 3D Robotics Iris+ quad, you would find settings in this menu geared specifically toward that model. Unfortunately, Mission Planner doesn’t come bundled with default settings for our model, so we have to set them up manually. That’s OK; you learn more doing it that way!

Figure 9-7. Select frame type.

Step 2.2: Calibrate accelerometer

The next substep is to calibrate our accelerometer. This sets a baseline for the APM to understand what direction is up, down, and so forth. Mission Planner will ask you to move the drone into different positions, so be sure you have a nice, clear area on a level work surface to follow the directions as described. It is important that you do this on an area that is as level as possible. If you have one, use a bubble level to confirm that the area you have selected is not out of level. We often use a small TV table because it is easy to shim up to level if it’s off a little bit.

Click the Accel Calibration button from the left-hand menu (see Figure 9-9). This will place a single button labeled Calibrate Accel in the main application window. Click that button and follow the instructions that Mission Planner sets before you. It will ask you to position your drone in a number of different positions before pressing any key to continue. Once the process is done, you will see a notification that the calibration either passed or failed. The positions it will ask you to use are:

Level

Normal position the aircraft would maintain when sitting right side up.

Upside down

Exactly what it sounds like: flip the aircraft upside down from how it would normally sit.

Nose down

The front of the drone pointed straight down toward the ground with the tail sticking straight up.

Nose up

The tail of the aircraft pointed straight down with the nose pointed straight up.

Left

The left side of the aircraft pointing straight down with the right side pointed straight up.

Right

The right side of the aircraft pointed straight down with the left side point straight up.

Figure 9-9. Calibrate accelerometer.

Step 2.3: Set up the compass

Click the Compass button in the left-hand menu. This will present the compass setup screen in the main application window (see Figure 9-10). Setting up the compass is a very important process that involves three basic steps:

  1. Enable auto declination: Find and check the Enable and Auto Dec Declination checkboxes at the top of the main application window. This allows the APM to use its GPS to find the part of the world you are located in and then fine-tune your compass for that location. This allows for offsets between true north and magnetic north.
  2. Select type of compass and orientation: Under the Orientation field in the main application window, select the APM with External Compass option. This should change the text at the bottom of that field to say ROTATION_ROLL_180. This information tells the APM what direction the compass is pointing in, so it has a baseline to start its measurements from.
  3. Perform calibration: Now that we have established the orientation of our compass, we can calibrate it (see Figure 9-11). Click the Live Calibration button at the bottom of the main application window and follow the instructions Mission Planner issues. This step may take a few minutes as the application asks you to rotate the aircraft around all possible axes so that it can take sample points in a virtual sphere. Just take your time and follow the directions until Mission Planner tells you that the calibration has passed. If, for some odd reason, it fails, don’t worry about it. Just run the calibration again and be sure to move around all axes of the compass.
Figure 9-10. Compass setup.
Figure 9-11. Compass calibration.

Step 2.4: Radio calibration

Next up is the radio calibration. APM refers to the transmitter as a radio, so from here on we use the two terms interchangeably. Click the Radio Calibration button in the left-hand menu (see Figure 9-12). This will display the calibration page in the main application window. The general idea here is to allow Mission Planner to talk with your radio and figure out the limits of each channel. During calibration you will be asked to push the sticks, switches, and knobs to their minimum and maximum settings so that the application can learn the range of each channel. A green bar graph will represent each channel of the radio, and they will move with the controls of the radio (see Figure 9-13):

  1. If you haven’t done so already, power up your radio transmitter.
  2. Click the green Calibrate Radio button under the Radio 8 bar graph in the main application window.
  3. When directed, move all radio controls to their maximum and minimum settings. This includes any and all controls that you will use such as sticks, switches, knobs, and sliders (depending on what radio you own) that are on the transmitter. You will notice that fine red lines will appear on the bar graph for each channel showing its min-max setting.
  4. Once this is complete, click the Click when Done button (same as the calibrate button, the label just changed).

After you have completed the calibration, a small pop-up will appear that gives you the min-max values for each channel of the radio (see Figure 9-14). Click OK to get rid of this screen and move on to the next step.

Figure 9-12. Prior to starting the Radio Calibration process.
Figure 9-13. Notice the red lines that indicate the min-max value for each channel.
Figure 9-14. Congrats! Your radio is calibrated.

Step 2.5: Set flight modes

Now that we have our radio calibrated, let’s set the appropriate flight modes on our flight mode switch. To start this process, click the Flight Modes button in the left-hand menu. This will display the flight mode assignment view in the main application window. We will use this to set our Loiter and Stabilize flight modes. If you have a radio that has a three-position switch (some only have two positions), then you can select one additional flight mode such as Auto (waypoint navigation) or RTH (return to home):

  1. With the radio powered on, toggle through the different positions on your flight mode switch while watching Mission Planner. You will notice that each position on your switch will light up a different flight mode menu green in the application. Make note of which switch position lights up which mode menu.
  2. Use the drop down menu for each flight mode to assign the desired mode to that switch position. For example, if you have position 1 on your switch lighting up mode menu 2 in the application, you can assign the Loiter flight mode to that switch position by simply changing it in the drop-down menu (see Figure 9-15). Now change to switch position 2 and assign Stabilize with that mode menu (see Figures 9-16 and 9-17).
Figure 9-15. Switch position 1 lighting up flight mode menu 2.
Figure 9-16. Switch position 2 lighting up flight mode menu 4.
Figure 9-17. Assigning the Stabilize flight mode to mode slot 2 with the drop-down menu.

Step 2.6: Failsafe setup

We are almost done with our mandatory setup. The last thing on our list is the failsafe setup. This allows us to define what actions are taken when certain portions of our aircraft fail, such as when we lose radio connection or if the battery drops below a certain level while we are still flying. To get started on this step, click on the FailSafe button in the left-hand menu:

  1. Find the Battery field on the right side of the main application window. Set the Low Battery option to 10.4 and the Reserved MAH to 0. This allows us to monitor only the voltage and not the capacity of the battery. You should only set the MAH setting if you use the same size battery all the time and know exactly how much you want to “leave in the tank” before you trigger a failsafe. Setting this while using more than one battery size can cause premature failsafe triggers.
  2. Now we need to set the action to take when our Battery FailSafe event takes place. We do this by selecting one from the drop-down menu in the same Battery field (see Figure 9-18). The options are:

    • Disabled
    • Land
    • RTH (return to home)
Figure 9-18. Battery FailSafe options.
  1. In the Radio field just below, select your desired action from the drop-down menu (see Figure 9-19). This will tell the APM what to do any time the radio connection is dropped for a certain amount of time (as decided by APM). Now set the FS PWM text field to a value of 975. This tells APM what the PWM value should be during the RTH event. The options for the Radio FailSafe actions are:

    • Disabled
    • Enabled always RTH
    • Enabled Continue with Mission in Auto Mode
    • Enabled always Land
Figure 9-19. Radio FailSafe options.

Step 3: Optional Hardware

You have made it through the mandatory hardware setup! Now it’s time to move on to the optional hardware. APM allows for a lot of optional hardware to be added on to the autopilot. This is one of the great things about the system and what attracts so many DIYers and tinkerers. The most common add-ons are telemetry radios and battery monitors, but there is a long list of additional options including sonar sensors, airspeed monitors, optical flow sensors, on screen display (OSD), camera gimbals (servo based), antenna trackers, and Bluetooth modules. Most of these add-ons fall outside of the scope of this book. In reality, you could just about write an entire book on these options alone! In this particular step, we will cover the two most popular options: telemetry radios and battery monitors. If you have elected not to install these components, feel free to skip over all of Step 3.

Step 3.1: 3DR radio (telemetry)

In Chapter 7, we installed our telemetry radios for APM. These radios come from the factory paired up in matching sets that are both tuned to the same channel, or Net ID. In theory, you should not have to do anything beyond plug these radios in and hit the connect button. However, it is good to know where the settings for the radio are located and how to change them if need be (see Figure 9-20). It is also a good idea to tune in your own Net ID if you fly with friends so that you aren’t interfering with one another.

Follow these steps to check that your radios are communicating with each other as expected:

  1. Make sure that you are not already connected to Mission Planner over USB. If so, disconnect and unplug the cable.
  2. Power up your radio transmitter and drone with telemetry radio installed.
  3. Connect the ground telemetry radio to your laptop and open Mission Planner.
  4. Set your COM port as needed and your Baud Rate to 57600, then click connect.

If you want to change your Net ID setting so that you can fly with others and not cause interference, simply use the drop-down menu to find a new channel. Be sure to set both the Local (ground) and Remote (air) radios to the same ID number, then click the green Save Settings button in the top of the main application window.

Figure 9-20. Telemetry radio setting loaded.

Step 3.2: Battery monitor

Another optional piece of hardware that many people like to use is a battery monitor. This is a simple device but one that can provide very valuable information and potentially save your aircraft in the event of a battery failure. As we covered in Chapter 5, the battery monitor installs inline between your main power distribution plug and the battery itself. It uses a small chip that communicates with the APM to analyze the current draw and capacity remaining in the battery. This page in Mission Planner allows you to adjust the few settings for the battery monitor. To get to this screen, select Battery Monitor in the left-hand menu. There are three settings that you have control over:

Monitor

This dictates what the battery monitor will keep an eye on. Your options are Disabled, Battery Volts, and Voltage and Current. We recommend using Voltage and Current if you are using the battery monitor (see Figure 9-21). It provides more information, and that is always a good thing.

Sensor

This menu allows you to select the type of battery monitor sensor you are using. If you purchased your kit from the Maker Shed, you want to use the 3DR Power Module option. If you bought your monitor elsewhere, consult the store you purchased it from and find out exactly what type of monitor they sold you, then select that from the list. If you don’t know and have no way of finding out, the Other option will usually work.

APM Version

This is pretty self-explanatory. For this build, select the APM 2.5+ 3DR Power Module option. If you purchased a different flavor of APM (such as the Pixhawk or PX4), then find your model in the options and select it.

Figure 9-21. Battery monitor settings page.

Let’s Explore the Rest of Mission Planner

Good job—you have finished setting up your new APM equipped quadcopter! Let’s take a few minutes now to look over the rest of the Mission Planner application. So far, everything that we have used was in the Initial Setup tab. We will now review some of the features in a few of the other tabs. Some will mirror features we have already discussed, but most of it will be new. Click the Config/Tuning button at the top and let’s explore some of the options that appear in the left-hand menu.

Flight Modes

This screen (see Figure 9-22) is actually identical to the Flight Modes screen we discussed earlier in this chapter. You can use this page to assign the different flight modes to the various switch positions on your radio transmitter.

Figure 9-22. Flight Modes screen.

Geo Fence

Geo Fence can be a pretty cool safety feature for new pilots. It does exactly what its name implies: it sets up a virtual fence around your takeoff point that you are not allowed to fly beyond. Think of it as a way to keep your quad on a virtual leash!

APM will use your initial takeoff location to assign a home point, and from there the options you select on this screen will dictate how far away you can fly and what happens if that fence is breached. If you want to use this feature, simply check the Enable checkbox at the top of the main application window, then set your parameters below as you see fit (see Figure 9-23). Keep in mind that the parameters will be in the metric units, so the numbers indicate meters, not feet.

Figure 9-23. Geo Fence screen.

Basic Tuning

If you spend any time online reading about drones, you are likely to have heard about people tuning their copter to perform one way or another. The idea here is that any number of different drones have different flight characteristics and the autopilot—APM, in our case—needs to be tuned to match. Think of our Little Dipper; this is obviously going to have a different set of characteristics than a 35 lb Octocopter with a DSLR under it. Tuning allows you to use the same autopilot in both aircraft but alter it to work in either environment.

Basic Tuning is the entry point to tuning your APM (see Figure 9-24). One thing that attracts people to using the APM platform is that it has an almost endless set of parameters that you can use to fine-tune it for advanced functionality (most of which will fall outside of the scope of this book). This page allows you to set just a few that alter the “feel” of your aircraft. You can adjust the drone response of your input from the transmitter, how sensitive the drone is to autoleveling, where the aircraft should hover in relation to the throttle input, as well as how aggressively it will climb when given input from the throttle. Each input provides a quick description of what the slider does to the aircraft. If you have a telemetry radio, it’s easy to open Mission Planner while the aircraft is in flight and slightly adjust these to see their effect in real time.

Figure 9-24. Basic Tuning parameters.

Extended Tuning

This Extended Tuning screen allows you to do a much higher level of flight characteristic tuning (see Figure 9-25). Sometimes called PID (Proportional, Integral, Derivative) tuning, the Extended Tuning screen lets you adjust each of the three aircraft movements (roll, pitch, and yaw) with variables that feed into a PID controller algorithm. This type of controller is very popular in large-scale industrial control systems. The process works by creating a control loop feedback that calculates an error value and attempts to correct said error to a desired result.

Luckily, APM comes with standard settings here that seem to work well for most installs right out of the box. If your aircraft is not flying as you would like, and you feel that you need to adjust the PIDs to obtain peak performance, we do recommend that you do some independent research on the topic. PID tuning can become pretty complex pretty quickly, and as such, falls outside of the scope of this book. There are also options to Auto-Tune your PID settings with APM, but we have seen mixed results with this process. Even if this is an option for you, it would still be a good idea to learn more about the theory of PID tuning so that you understand what is going on behind the scenes. If you are interested in learning more, we have a good starting point on the website.

Figure 9-25. Extended Tuning screen.

Standard Params

The Standard Params page starts to show you the extreme flexibility of the APM platform (see Figure 9-26). The screen shows a long list of parameters that can be set to help customize or fine-tune your aircraft for your specific needs. Although this list is much too long to discuss here, we certainly invite you to explore it yourself; however, a word of warning: be careful what you change! If you don’t understand what something does, look it up on the APM website before changing it and attempting to fly. A full list of the Standard and Advanced Parameters can be found on the Ardupilot website.

Figure 9-26. Standard Params.

Flight Data

For a good chunk of this book now, we have talked about telemetry data being shipped back to your ground station over the telemetry radios. The Flight Data screen (see Figure 9-27) is where we actually get to see most of that data. When you open the Flight Data tab you will notice a large map on the right side of the screen. This will give you a real-time update of where your aircraft is located (as long as you have a GPS fix).

On the left side of the application will be a column broken down into two sections top and bottom. The top portion contains an instrument that may look familiar to you. It is essentially an artificial horizon just like you would see in a full-scale airplane. The only difference here is that our horizon has some additional data overlaid on top that pertains directly to our type of aircraft. This instrument will display the attitude of the aircraft as it moves through space by moving our horizon line—separated by green and blue fields—as well as the aircraft heading, flight mode, GPS status, battery levels, and compass heading.

The space below the artificial horizon is used to display a number of data points that are returned from APM to our ground station. These data points can be very useful during flight because they help you gauge things like how fast your aircraft is flying, how far you have flown from your takeoff point, and what your current altitude is.

Figure 9-27. Flight Data screen.

Flight Plan

Finally, we will take a quick look at the Flight Plan screen, which enables you to plan your autonomous flights (see Figure 9-28). At first glance, it looks very similar to our Flight Data screen because it has the same type of map, but this map has a vast amount of additional functionality built into it.

Everything from an entire mission to a single waypoint can be planned from this screen. No matter what the complexity of your mission, they are all made up of a series of waypoints that direct the aircraft to a specific latitude, longitude, and altitude. You will also tell the aircraft what it should do once it reaches each waypoint—for example, you may want it to pause for 30 seconds or move directly on to the next way point—and how fast it should fly in order to get to that waypoint.

It is very important that you have a solid grasp on manual flight before attempting any type of autonomous flight. Every pilot should be able to manually take control and fly the aircraft home in the event of a GPS or sensor failure.

Figure 9-28. Flight Plan screen.

Preparing for Your Maiden Flight

Technically, at this point, you are done with your build. All of the components are installed, your flight controller is set up, and you are just about ready to test it out and see how well you can fly! However, we do want to offer you just a few quick bits of advice first. If you are new to RC flight, we recommend that you finish up the remaining chapters to get a good understanding of how to fly in a safe manner. After you’ve done so, you can proceed with the following steps:

  1. Leave your propellers off and double-check that all your motors are spinning in the right direction. If you remember from earlier in the book, we plugged the bullet connectors from our ESCs into the motors without knowing if we had the correct direction yet. Now is the time to double-check this. Arm your motors (default is left stick down and to the left for three seconds) and check each motor one at at time. If you find it is spinning in the wrong direction, change any two of the three bullet connections to reverse the direction.

  2. With the props still off and the motors spinning in the correct direction, check to see if the APM is autoleveling correctly. You can determine if this is right by spinning up the motors slowly while holding the quad and gently dipping the frame in one direction. If the APM is working as expected, it should automatically increase the speed of the motors that are dropping closer to the ground. If you find this is not correct, double-check that you have all your ESCs plugged into the right output ports on the APM.

  3. If everything is working as expected so far, feel free to put your props on and try to get this bird in the air! Take your time and start off slow. Spin the props up gently and see if you can make the quad just barely come off the ground. Give it some mild stick commands while doing this. Confirm that everything works as it should, such as a Roll Left command actually causing the aircraft to fly to the left. If all seems OK, gently give it a little more throttle until you are a foot or two in the air. Avoid staying too close to ground, where you will get caught up in ground effect, which can cause you trouble. Ground effect occurs when air pushed through your props hits the ground and creates a disturbance that can push your aircraft around a little bit.

  4. Take your time and practice! This isn’t a race and there are no prizes for getting in the air immediately. If you take your time now and get the feeling of your aircraft down, you will be much more successful moving forward.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.178