Howto: ArduPilotMega + USB + qGroundControl

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.

3689363923?profile=original


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).

3689411775?profile=original

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.

slider.jpg

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.

3689411526?profile=original

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.

3689411797?profile=original

That's it, have fun.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Found my answer - when i plugged in my Ardupilot, it was recognized as a serial device found under /dev/serial/by_id/usb-Arduino__www.arduino.cc__Arduino_Mega_2560_64033333430351709002-if00. I right clicked the file and looked at the properties. It was being mapped to ttyACM0. When I opened minicom and set the serial port to ttyACM0, everything worked fine!

  • "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)."

     

    Can you explain how to do this please? I'm using minicom in Ubuntu

  • I have exactly the same problem as you Alain. I am using QGroundControl V. 1.01 (Alpha RC18) and APM2.0 V2.4.1 flashed with ArduPlane V 2.33. I am connecting using the USB serial port (Com5 in my case Arduino Mega 2560). I have disabled the check box "Only accept MAVs with same protocol version" just to ensure that MAVlink version in ArduPlane 2.33 is not MAVLINK V0.9 as I believe it uses MAVLINK V1.0). Here is a screen shot of that dialog:

    3692413794?profile=original

    I then connect and get confirmation of data in the Communication Console shown here...

    3692414028?profile=original

    and here with hex selected..

    3692414085?profile=original

    When I access the Calibration and Parameters Tool Widget I get nothing in the dialog as explained in Simon's  tutorial. Here is a screen shot ...

    3692414100?profile=original

    I have in fact battled to get Qgroundcontrol to talk via the telemetry port with MAVLINK protocol selected on both the APM2 and UDB4 boards using the default telemetry port (UART0 on APM2 with USB disconnected and UART2 on UDB4). Even trying Happy Killmores GCS SW I keep getting Message Not Recognized but can get comms with the APM2 USB interface). So basically I have two problems one with Qgroundcontrol using the APM2 USB port as well as using the telemetry port and the other with APM2 and UDB4 and all Mavlink compatible GCSs (Qcontrol, HK GCS and AMP Planner) when I try and connect via the telemetry interfaces. Note. On the PC side when using the telemetry interface I/m using a standard USB to serial RS232 converter with prolific driver.

    Assistance from anyone out there will be much appreciated.

    Thank you.

    Grant 

  • 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

  • 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

  • @ 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?

  • /dev/ttyusbX is the device name on linux. Your device name sounds about right for mac os. Aß for no data, the above tests have been made with a much older qgroundcontrol version.
  • 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...)3692321143?profile=originalAny help would be much appreciated

    Have a beautiful day

    Alain

  • 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.

  • 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

This reply was deleted.