Exteral Coding into APM

So I had a few questions about the coding and algorithms for the APM.

First I beileve the software is all open source if i'm corect. Does anyone know where I can get the raw coding for the different ardrupplane versions?

Also what language is the coding based in?

Thirdly and most importantly, if I was interested in creating and writing my own coding for the apm is this possible and can someone provide a few links on how others have done this in the past?

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

Join diydrones

Email me when people reply –

Replies

  • Hi Al Creigh,

    Yes the software is open source (GNU General Public License).

    The code is available here: https://github.com/diydrones/ardupilot

    Instructions on how to build the code is here: http://dev.ardupilot.com/

     

    • Hi James,

      I'll definitely look into this, so I'm guessing you can write and adjust this coding in any way you like? You can write code to set it up to perhaps use a specific bank angle or hold a certain bank angle when switched into a certain mode?

      • Yes, "the sky is the limit" - you have complete control of the behaviour of the aircraft when you alter the code (for better or for worse....)

        If your goal is to perform some specific manoeuvre then you might also want to look at the scripting facility of MP:

        http://copter.ardupilot.com/wiki/python-scripting/

        This is probably easier to implement for a beginner but a little more restrictive. It also requires a telemetry link to a GCS running MP. 

        • Hi James

          Can you help me with my code which I can not add to the APM code.The follow is my servo code.


          #include <AP_Common.h>
          #include <AP_Math.h>
          #include <AP_Param.h>
          #include <AP_Progmem.h>

          #include <AP_HAL.h>
          #include <AP_HAL_AVR.h>
          #include <AP_HAL_AVR_SITL.h>
          #include <AP_HAL_PX4.h>
          #include <AP_HAL_Empty.h>

          const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;

          uint16_t individualread(AP_HAL::RCInput *in)
          {
          uint16_t channel_7;

          channel_7 = in->read(6);
          hal.console->printf_P( PSTR("individual read: %d\r\n"),channel_7);

          return channel_7;
          }

          bool flag = 1;

          void setup (void)
          {
          hal.console->printf_P(PSTR("Starting AP_HAL::RCOutput test\r\n"));
          }

          void loop (void)
          {
          individualread(hal.rcin);
          uint16_t ctr = individualread(hal.rcin);
          //hal.console->println(ctr);
          if(ctr > 1500)
          {
          if (flag)
          {
          for (int i=500; i<2000; i=i+10)
          {
          hal.rcout->enable_ch(9);
          hal.rcout->write(9,i);
          hal.scheduler->delay(10);
          //hal.rcout->disable_ch(9);
          }
          }
          flag = 0;
          }
          if(ctr < 1500)
          {
          if(flag == 0)
          {
          for (int i=2000; i>500; i=i-10)
          {
          hal.rcout->enable_ch(9);
          hal.rcout->write(9,i);
          hal.scheduler->delay(10);
          //hal.rcout->disable_ch(9);
          }
          }
          flag = 1;
          }

          /*if(ctr > 1500)
          {
          hal.rcout->enable_ch(9);
          hal.rcout->write(9,2000);
          }
          if(ctr < 1500)
          {
          hal.rcout->enable_ch(9);
          hal.rcout->write(9,500);
          hal.scheduler->delay(10);
          }*/
          }

          AP_HAL_MAIN();

          Any help would be greatly appreciate!

          Thanks! APMlover

          • APMLover, I am away from a computer this weekend which makes it hard to help for a couple of days... Can you compile the RCOutput example? 

            • It is OK ,James.

              I have compile the RCOutput example,and I write my servo program according to it

This reply was deleted.

Activity