Code for using the Ardupilot with an onboard computer / USB connection

Hi All,

I've been working on a system for running an APM 2.5 as a sensor and I/O board for a plane with another on-board computer.  I couldn't find existing code for this (although perhaps it does exist and I missed it), so I built my own.

This is close to what I'm doing, although I do not use ROS (it would be easy to add though):

The APM communicates with the on-board computer via USB, to which it publishes sensor readings, and reads messages that contain the servo values.  It also does mux-ing between autonomous and manual modes based on a radio channel input.

I'm using the MAVLINK protocol to go up and down, so it should be relatively compatible with existing code in that regard.  I did have to define a new message or two, but that shouldn't be too bad for anyone else to use.

The system is working pretty well now, and if anyone is interested, I'm happy to provide the code.  I wasn't quite sure what to call it, so it's currently named "ArduRead".  Some of the code is hacked together, but I'm happy with most of it.

Some approximate stats from the last time I turned it on:

IMU message rate: 160Hz

Barometric altitude rate: 70-80Hz

Pitot tube rate: 70-80Hz

GPS rate: 10Hz (although might be duplicated, depending on your GPS)

Battery read rate: should be 10Hz, putting this in this week




Andrew Barry
Ph.D. Candidate in Electrical Engineering & Computer Science
Robot Locomotion Group
Computer Science and Artificial Intelligence Laboratory
Massachusetts Institute of Technology
Stata Center, 32-380
32 Vassar St.
Cambridge, MA 02139

Views: 2588

Reply to This

Replies to This Discussion

Update: I put all of my new code in the "arduread" branch here:

It would need some cleanup to get merged into the main branch, which I'm happy to do if there's interest.

Hi Andy I want to do it with beagleboard xm I am a newbie and I don't know where to start actually. I read about mavlink protocol but I couldn't figure out how to put it in my apm. 

Thank you


Hi Ufuk,

The project is really more in an alpha-stage right now, so if you're a newbie I highly recommend you get something flying before attempting to use my code.  It would require you to write a full control system on your beagleboard, which, while awesome, probably isn't where you want to start!

If you really want to give it a shot, you ought to be able to checkout the code from git, get it to compile, and upload it to your APM.

- Andy

Hi Andy thank you for your quick reply.

I am a newbie in a project which already have continued for more than a year. I want make a contribution. My aim is send some datas to Beagleboard (gps,velocity,angle...) at first. I stduy on your code a little as I understand you make some control on your board also. If I could make suitable changes on your code I can make APM send these datas to beagle board on USB. Please correct me if I am wrong and If you have any suggestion please share with me.

Thank you again


Hi Andy;

I was trying to compile and load your code on Apm but there are so many errors. I couldn't handle them I am using modified arduino for ardupilot to compile the code. I am really appreciate if you could help. I couldn't put errors because so many I guess I am doing wrong some basic stuff. But I coudn't find

Thank you


Hi Ufuk,

It's tough to tell what might be going wrong without the error messages.  Go ahead and paste the full thing here and I'll see if I can help.

Likely something isn't set up quite right on your build system which is causing a bunch of issues.

- Andy

Hi Andy,

Shortly I want to mention what I have done. I downloaded your program and open it with modified arduino program which is (ArduPilot-Arduino-1.0.3-windows). After that I added arduread.pde and compile it and I got the errors which are below. 


Hi Ufuk,

My code isn't a plug-in to the regular ardupilot code, but is a complete replacement.  You should go into the ArduRead directory and build all of the code there.  You shouldn't have to modify any of the code to get it to compile.

You should also be aware that because it replaces the ardupilot code (while using many of the libraries) it will not act like an ardupilot anymore.  It won't work with the ground control software, nor will it fly your plane.

Instead it will report sensor values up via USB and it will take control inputs from USB.

- Andy

Hi Andy;

Thanks again for your interest and help a lot.According to your reply I need to use arduplane code your code isn't for me. I need to add the serial port communication routine. So, let me ask you this way;

Should I write it into arduplane.pde if not where sohuld I implement the code

if I send data from usb does apm still send data from telemetry port simultaneously.

Thank you


Hi Ufuk,

The stock firmware already does the USB communication, just at a much slower rate.  Your best bet is probably to use that for now and only transition to custom firmware if you really need faster rates.

- Andy

just trying to make sure, you are controlling a UAV with Ardupilot from a computer wirelessly, right ? I Or is it the computer also flying with the UAV ? 

I want to control a quadrotoror or any type of UAV  with Ardupilot from a computer wirelessly. Yes, without a remote control . Where can i look for the help ? I would be very thankful. : ) 

This firmware does NOT control wirelessly.  It's designed to be used with another onboard computer that is also flying with the UAV and is connected via USB full time.

- Andy

Reply to Discussion


© 2018   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service