Learning to program the Ardupilot Mega


Learning to program the Ardupilot Mega

A group to discuss the many ways to edit and compile the code for the Ardupilot Mega!

Members: 525
Latest Activity: yesterday

Discussion Forum

Takeoff and Arm from GCS arducopter 2.9.1

Started by Markus Järve. Last reply by Nate Miller Nov 5. 27 Replies

Firstly I would like to apologize for sending takeoff message to all people in "Learning to program the Ardupilot…Continue

Tags: motor, arming, MP, Takeoff

Learning to program Arducopter

Started by Minh Tran Quang. Last reply by صلاح الحكيمي Oct 24. 4 Replies

I tried to explain the control process in Arducopter.pde. The reference is http://ghowen.me/build-your-own-quadcopter-autopilot/.To…Continue

Using an external IMU with the APM

Started by Luke Nyhof. Last reply by Nate Miller Oct 16. 10 Replies

Hi guys,Just wondering is anyone has tried using or interfacing an external IMU or AHRS with the APM x.x?I am interested in using a spare VectorNav VN-100 I have sitting on my desk as it is a decent…Continue

Tags: external, VectorNav, IMU, AHRS

APM servo program

Started by APMlover Aug 11. 0 Replies

Hi all,       I have some question about the APM servo program.The question is that I can debug it correctly,but it can not make a difference.Meanwhile it run very well when I debug it in my arduino.…Continue

Comment Wall


You need to be a member of Learning to program the Ardupilot Mega to add comments!

Comment by Bill Bonney on May 16, 2014 at 5:20am
@AntoineL: post your question here https://groups.google.com/forum/m/#!forum/drones-discuss, its where the APM devs discuss developement topics. I'm sure we can help get your Library working
Comment by Antoine LECESTRE on May 16, 2014 at 2:39am

Hi Guys, 

I've been working for a few days on implementation of CMUcam PIXY to Ardupilot. I have created AP_PIXY library which is available in my GIthub (here) and based on the original Pixy's arduino library  (here).

My objectif is to use the Pixy as an "optical flow" to allow a copter to hover precisely over a target, to land precisely on it or event to recognise color codes and do actions accordingly.

The library works well when I compile the "AP_PIXY_test.pde" example to my APM2.5 through the arduino IDE for Ardupilot.

My problem is when I try to add it to the main code. When I just include all the files there is no problem and the APM works fine. But when I try to define a variable in the UserVariables.h such as : "static AP_OpticalFlow_PIXY Pixy_Flow" the APM doesn't work. It compiles with no errors but the APM doesn't restart, no lights are ON exept the "Alive" one. I've uncomment the "#define USERHOOK_VARIABLES UserVariables.h" in AP_Config.h and disabled the optical flow through "#define OPTFLOW DISABLED" . Nothing else was changed.

what am I suppose to do to make it work? What are my errors?



Comment by Randy on April 15, 2014 at 6:02am


     For arducopter you'll need a minimum of 4hz.  5hz is best though.  1hz definitely won't work I'm afraid.  Inertial nav will get very upset.

Comment by Antonie Kruger on April 15, 2014 at 5:42am

Thanks, Randy. Would it take the NMEA strings at 5Hz as the binary or is 1Hz OK?

RE dual sensors - how are these managed? Are they identical sensors as the on-board IMU's managed through the I2C port or would other sensors be considered?

Comment by Randy on April 15, 2014 at 5:13am


     Those are some big questions and I can't answer them all.

     For the NMEA messages you can find our NMEA driver here.  It seems to be looking for 3 specific messages, GPRMC, GPGGA and GPVTG.  I've never looked at the nmea driver before though.

     Re the IMU, the driver for each accel/gyro chip should convert the output to deg/sec for the gyro or m/s/s for the accelerometer.  In other parts of the code we deal in centi-deg/sec or centimeters/s/s but I don't think that's the case for the IMU sensors.

     Re multiple sensors, we're extending the AC/AP software so that it makes use of the extra sensors (dual-gyro, dual accel, dual compass even dual GPS) on the Pixhawk for AC3.2 and the latest version of plane already support this (except the dual-gps).  My guess is that instead of offloading the attitude processing it makes more sense to offload the higher level navigation processing to a separate processor.  I think this because the communication overhead of pushing all that data around is probably quite high.  Better to keep the attitude processing very close to the IMU.

Comment by Antonie Kruger on April 15, 2014 at 4:03am

Hi Guys, I have a question around the NMEA GPS input stream and the IMU sensor - I apologise if these have been covered, I cant find the answers I'm after.

Firstly, there are many NMEA strings in the NMEA definition, it is not a single string that is generated, but can be a vast amount of string. This depends on the activated requirements on your GPS receiver. Here's my question - what are the minimum NMEA string specs that APM need to function properly and at what rate are these required(Hz)?

Secondly, the IMU sensor. Are there standardised units of measure for the sensors on IMU's(Accel, Gyro, Mag, Baro). As GPS position is generally defined with a degree lat and long, is there a similar definition for IMU's? If so, would it be possible to adopt such a philosophy with the APM development - allow the attitude to be streamed to the flight controller via a port instead of using the on-board sensors. The benefits in having this would be:

1. Moving the attitude processing off the flight controller.

2. Multiple IMU's can be used to improve accuracy and have sensor redundancy. Continuous health polling with reading averaging and standard deviation testing before feeding to the filter can be managed by a attitude processor and a clean attitude stream can be fed to the main flight controller.



Comment by Minh Tran Quang on January 24, 2014 at 1:19am

 Hello, Shyam

You may look at this for information


Comment by Antonie Kruger on January 16, 2014 at 5:05am

Hi Randy, thanks.

Comment by Randy on January 15, 2014 at 10:43pm


     The best way is probably to modify the AP_MotorsQuad.cpp file's so that it adds another motor at the bottom with zero for the roll, pitch and yaw factors.  That alone might do it.  Below is an excerpt of that file with the additional line that I think should be added.

        // X frame set-up
        add_motor(AP_MOTORS_MOT_1,   45, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 1);
        add_motor(AP_MOTORS_MOT_2, -135, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 3);
        add_motor(AP_MOTORS_MOT_3,  -45, AP_MOTORS_MATRIX_YAW_FACTOR_CW,  4);
        add_motor(AP_MOTORS_MOT_4,  135, AP_MOTORS_MATRIX_YAW_FACTOR_CW,  2);
        add_motor_raw(AP_MOTORS_MOT_5, 0.0,  0.0, 0.0, 5);

Comment by Antonie Kruger on January 15, 2014 at 10:25pm

Hey Guys, I need some guidance with the following:

1. I want to take the 4 outputs (Assuming a quad configuration) and get an average. (Mot1.Output + Mot2.Output + Mot3.Output + Mot4.Output)/4

2. From here I want to send the average value to an available out channel - say channel 5.

The purpose for this would be to fit a large central lifting motor on the quad taking the average pwm from the 4 balancing (normal) motors.

I might have to apply a scalefactor / constant to achieve stability. I also foresee a yaw issue considering the torque of a large single main rotor, but will see how to manage that once a prototype is running.

Thanks for any help.



© 2014   Created by Chris Anderson.

Badges  |  Report an Issue  |  Terms of Service