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: 471
Latest Activity: on Friday

Discussion Forum

Use of UBlox data through an Ardupilot without the use of APM Planner

Started by Brandon Jensen. Last reply by Curt Olson on Friday. 1 Reply

Hi everyone,Sorry if this seems a question with an obvious answer but after playing with it for a few days I've had no luck.The problem is that I would like to use the GPS data from a UBlox connected…Continue

controlling motor speed using APM 2.0

Started by enya. Last reply by Psam on Thursday. 2 Replies

Hello, for a startup, i just want to control the speed of 4 BLDC motors using APM 2.0. which i previously controlled using arduino uno, can anyone help?Continue

Ardupilot source code before APM_HAL

Started by Oliver Buhn. Last reply by enya on Wednesday. 3 Replies

HiWhere can I download the earliest version of Ardupilot for APM 2.0 before they introduced the hardware abstraction layer.I'm thinking that would be a better source to learn developing custom code.Continue

Learning to program Arducopter

Started by Minh Tran Quang. Last reply by Hafidz Apr 12. 2 Replies

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

Comment Wall


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

Comment by Randy on Tuesday


     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 Tuesday

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 Tuesday


     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 Tuesday

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.


Comment by GreenHand on December 28, 2013 at 6:51am

I am a green hand of quadcopter,and I just could not find the main function of the arducoper in the code,forget to say,I do not use the arduino IDE but Source Insight,it can just browse the code but not compile them,where is the main function?many thanks

Comment by Paul Henckel on November 16, 2013 at 3:58am

Hi Shyam

The source code is all available at https://github.com/diydrones/ardupilot


© 2014   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service