This document describes how to connect an ArduPilotMega with qGroundControl via USB (helpful for first tests of your micro controller).
ArduPilotMega
ArduPilotMega is an Arduino based Autopilot micro controller, programmable with C/C++. Arduino based stuff is nice, because it does not require much of hardware knowledge to get started.

qGroundControl
qGroundControl is is a ground station which can be used to fly a UAV/Drone and it can be used to visualize/test/log data from MAVlink compatible devices (for example the ArduPilotMega).

Preparing the ArduPilotMega
There is not much todo on the hardware side as long as you use the official firmware. At the writing of this post, APM 2.1.2 was the firmware used. It can be "flashed" with the Arduino IDE (using avrdude) or with the APM Mission Planner. You have probably already done this.
Secondly, you need to configure your plane. In my case it's a Multiplex funjet. My configuration looks like this.
APM_Config.h:
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-// $Id$
#include "funjet.h"
funjet.h:
// $Id$
// NOTE: set dip 4 HIGH (for elevon mix)
// http://code.google.com/p/ardupilot-mega/wiki/Reversing
//
// DIP Settings for Funjet:
// 1: LOW
// 2: HIGH
// 3: LOW
// 4: HIGH
// Servo channels
// 1: Left Elevon
// 2: Right Elevon
// 3: Throttle
// 4:
// 5: AP Control
// enable HMC5843 - Triple Axis Magnetometer Rev 1.2
#define MAGNETOMETER ENABLED
#define AIRSPEED_SENSOR ENABLED// #define AIRSPEED_RATIO 1.9936
// ALTITUDE_MIX OPTIONAL
// Configures the blend between GPS and pressure altitude.
// 0 = GPS altitude, 1 = Press alt, 0.5 = half and half, etc.
//#define ALTITUDE_MIX 0.5
Once you have compiled and uploaded the code and your configuration you are ready to test sensor data in qGroundControl. Note that no special configuration is needed for the MAVLink protocol on the APM side (as of V 2.1.2) which communicates with qGroundControl.
Make sure that SW2 on the APM is set to flight mode (turned to flight direction) and connect APM via USB cable to your computer.
Flight Mode
You might first test if the APM is sending some binary output over USB. To do this use your favorite terminal program (like hyperterm.exe, minicom or Arduino IDE's Serial Console).
When verified that the binary serial output is sent, start qGroundControl and click on the "Connect Link" Button. The default settings are reasonable, make sure using 115200 baud and select your serial port.

Now change to Engineer's view. You might not get any data yet (left panel with sensor options is empty). In this case APM does not yet know what to transmit. Make sure the «Calibration and Onboard Parameters» widget is shown. Insert 3.3, 10 or 50 Hz in all possible data streams. I read that 50Hz is preferable because the main loop of APM runs on 50Hz. If it causes problems with the serial connection, a lower frequency might help. As soon as these values are set, they are stored in the APM's EEPROM. So these values are present after a reboot of the APM which (I think) is a really nice feature.
Andre: You don't need to access the SVN (and indeed, you shouldn't use it unless you're working on development, since it contains untested alpha code). The Mission Planner will load the latest stable code for you, and if you want the source code it's always zipped up in the downloads section.
Comment by Simon on August 5, 2011 at 2:19am Chris: is it possible to set TAGS in SVN whenever a release occurres? This wold make it possible to check code of any version out of SVN and also would make it very simple to compare different versions.
Simon: we do tag major releases. Why do you want to use the SVN? All safe releases are in downloads section, including all previous versions if you want to compare code.
If people use the code right out the SVN, we end up with a tech support nightmare because they're using code we haven't tested and documented. It just make our job harder and slows development for everyone else.
Comment by Simon on August 5, 2011 at 9:34am Sorry, If these are tagged then I need to look again. With the latest releases the sourcecode release was a little bit delayed (no offence). If it were tagged in SVN i could have fetched it from there and compared it to the last release (I won't lift off with a new version before a code review. Not because I don't trust you, but because I want to know where my codde might break).
I wouldn't want to use code from TRUNK or a BRANCH.
Cheers,
-S
Comment by Andre S on August 6, 2011 at 12:02am Chris, thanks for the comments. I'm challenged OS-wise (linux/Ubuntu or Mac) and also kind of like the arduino IDE and also for trying to understand what's going on it's great to have the sources. That's why I'm not using the windows GUI. Chris, could you please confirm that APM_2.21.zip is the latest version? I had to do some changes to the config to get it from hardware-in-the-loop mode (I believe that's what HIL stands for) into regular flight mode.
Still diagnosing the Xbees. I think I start a separate thread for that since the setup is pretty basic for a Europe based user (APM+Xbee 2.4 series 2+diydrones board on plane/sparkfun USB on ground) and dowlink works fun so I have no clue what's the problem.
Comment by Alain on December 19, 2011 at 4:11am Hello everybody,
I've been following this tutorial, but I must be doing something wrong:
I have a ardupilot mega, loaded with the last code (i did it with mission planner), I uploaded the plane.h file and set the config.h file as explained above.
When I try on my mac (os: snow leopard) to connect via USB, I get some datas in the console, but cannot get the possibility to do any settings in the Calibration and onboard parameter widget, it is empy....
By the way, when I do connect the apm to Qgroundcontrol, I didn't get /dev/ttyusb0 but dev/tty.usbserial-AH00LR5J (see screenshot below...)
Any help would be much appreciated
Have a beautiful day
Alain
Comment by Simon on December 20, 2011 at 12:24am
Comment by Alain on December 20, 2011 at 12:58am @ Simon thanks for your answer, if I understand well, the above tutorial is meant to be done with an older version of the software, correct? But then, how can I get APM and Qgroundcontrol working together using the latest versions of both?
Comment by Simon on December 20, 2011 at 4:43am Alain, as you can see in the screenshots above I have used qGroundControl 0.8.3 at the time of that writing. Some other projects kept me busy so I am not quiet sure how this translates to the qGroundControl 1.0 alpha releases.
You might not run the latest and greatest. If you check the download page of qGroundControl, interestingly older alpha releases have been downloaded more often than the current (and still increasing).
Sorry, I can't say more about that at the moment.
Cheers,
-S
Comment by Alain on December 20, 2011 at 7:20am Simon,
thanks a lot for your time and your advices, I have tried to shift to an older version of Qgroundcontrol as you adviced, it's worse as I do not see any datas flowing in the console.
I think I'll keep borrowing my friend laptop using Mission Planner and keep trying and testing with Qgroundcontrol...
Thanks again
Alain
Comment
Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.1283 members
183 members
675 members
5 members
116 members
© 2013 Created by Chris Anderson.
Powered by

You need to be a member of DIY Drones to add comments!
Join DIY Drones