Definitive Tutorial for Compiling Pixhawk Code on Eclipse

1,541 views
Skip to first unread message

Brian

unread,
Jul 4, 2014, 11:24:46 PM7/4/14
to drones-...@googlegroups.com
Is there a definitive guide out there?  The ones I've found so far just don't work.

Or am I better of just using Notepad+ an make?

Thanks in advance,

Brian

Randy Mackay

unread,
Jul 5, 2014, 2:00:40 AM7/5/14
to drones-...@googlegroups.com
Brian,
     This wiki page, which you've probably seen, should work at least on Windows 7 and 8.
               Editing the code with Eclipse | Developer

     If it doesn't then we should fix it.  So can you clarify how far you got with the procedure on that page and how it failed?
 
 
image
 
 
 
 
 
Editing the code with Eclipse | Developer
Content Editing the code with Eclipse for Pixhawk Starting Eclipse Creating the Project Setting .pde files as C++ Use spaces instead of Tabs Building from Eclipse T...
Preview by Yahoo
 
  -Randy


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Aytek Canak

unread,
Jul 5, 2014, 3:33:11 AM7/5/14
to drones-...@googlegroups.com
Hi Randy,

Do you use code completion (intellisense) on eclipse ?

I couldn't get it working

Thanks

Brian

unread,
Jul 5, 2014, 9:14:40 AM7/5/14
to drones-...@googlegroups.com, rmac...@yahoo.com
I followed the wiki page and it did indeed work.  I'm not sure why, but it didn't work for me the first time (obviously user error).  There is a little twist in the documentation where it jumps from "ArduCopter" in the Project Explorer to "ardupilot" and then back to "ArduCopter".  Here's a link to the image:  http://dev.ardupilot.com/wp-content/uploads/sites/6/2013/12/EditingTheCode_Eclipse6.png

Basically I just ignored the "ardupilot" reference and did the same thing with "ArduCopter".

One other note:  I did associate the *.pde file type with C++ files instead of C files.  It seemed the throw a few less syntax errors that way.  But it still goes crazy with "XYZ could not be resolved".  Is there a way to fix that?

Brian

unread,
Jul 5, 2014, 9:45:55 AM7/5/14
to drones-...@googlegroups.com, rmac...@yahoo.com
I also found the flag to stop all the Eclipse errors.  Here's the link to that setup procedure:  http://dev.ardupilot.com/wp-content/uploads/sites/6/2013/08/UntitledEclipsePrefTurnOffErrors.png

So to summarize:

1) I'd take the original guide you referenced

2) Change the *.pde association to C++ files, not C files

3) Remove the potential "ardupilot" versus "Arducopter" discrepancy when referred to in the Project Explorer window (just need a fresh screenshot)

4) Add the Preferences -> C/C++ -> Code Analysis and uncheck "Syntax and Semantic Errors"

And the guide should work just fine.

Arthur Benemann

unread,
Jul 5, 2014, 10:34:55 AM7/5/14
to drones-...@googlegroups.com

Why the files are still named .PDE? Is it even possible to compile with arduino?

Philip Rowse

unread,
Jul 5, 2014, 1:05:57 PM7/5/14
to drones-...@googlegroups.com
Ardupilot is still compilable with Arduino :)  when we move on from the APM2.x series boards, this may change, but for now, it is there.....

Philip Rowse
Electronics Engineering Dept
3DRobotics
Ballarat
Australia

Brian

unread,
Jul 5, 2014, 2:46:55 PM7/5/14
to drones-...@googlegroups.com
I have it building in both the PX4 console and in Eclipse.  But when I build with "make px4-v2" or "make px4-v2-octa", I appear to get a fresh compile of the quad-only code. 

The compile reports success and I see a new "ArduCopter-v2.px4" file in the appropriate directory.  But for example on the motor test in mission planner, it only gives me four motors to choose from.  Furthermore here is what I observed:

1) I loaded a release version just to get a clean copy of ArduCopter on the Pixhawk.

2) Then I compiled (successfully) the px4-v2-octa version and loaded that custom build.

3) Then I compiled (successfully) the px4-v2 version and tried to load that custom build onto the board -- but it tells me that hex file is already installed.

Why would it only make the quad version, even when I do a "make px4-v2-octa"?  Do I need to do a "make clean" first?

Thanks in advance,

Brian

foobarbecue

unread,
Jul 5, 2014, 3:19:18 PM7/5/14
to drones-...@googlegroups.com
Hi,

I was able to get eclipse working with all the bells and whistles using Kevin Hester's pull request here: https://github.com/diydrones/ardupilot/pull/811 . Of course, that's getting pretty out of date now.

Aaron

Arthur Benemann

unread,
Jul 5, 2014, 3:22:18 PM7/5/14
to drones-...@googlegroups.com
I faced the same problem as Brian yesterday when trying to flash an X8. I though the command would be "make px4-v2-octa-quad", but that resulted on only the top motors spinning. 

Also what's the correct way to upload that file? (there is no "make px4-v2-octa-quad-upload" )


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Arthur Benemann
Engineer
3D Robotics

Brian

unread,
Jul 5, 2014, 3:25:38 PM7/5/14
to drones-...@googlegroups.com
I do all my custom uploads via mission planner anyway, so I don't use the "make upload" system at all.  In the "Install Firmware" screen, you'll see an option to "Load custom firmware".

But I still have no idea how to make it compile anything other than a quad.  I wonder if I'm getting the flags out of order.

Brian

Brian

unread,
Jul 5, 2014, 4:21:56 PM7/5/14
to drones-...@googlegroups.com
I found a commented-out set of defines in "APM_Config.h":

//#define FRAME_CONFIG QUAD_FRAME
/*  options:
 *  QUAD_FRAME
 *  TRI_FRAME
 *  HEXA_FRAME
 *  Y6_FRAME
 *  OCTA_FRAME
 *  OCTA_QUAD_FRAME
 *  HELI_FRAME
 *  SINGLE_FRAME
 *  COAX_FRAME
 */

And as you can see they are commented out.

And then in "config.h", I see:

#ifndef FRAME_CONFIG
 # define FRAME_CONFIG   QUAD_FRAME
#endif

So clearly the software is setup to default to a quad.  But what I can't find is where the "px4-v2-octa" would set the FRAME_CONFIG appropriately. 

Do I just need to hit it over the head and set the frame type in APM_Config.h?  
Message has been deleted

Brian DeBusk

unread,
Jul 5, 2014, 6:59:44 PM7/5/14
to drones-...@googlegroups.com
I set FRAME_CONFIG to OCTA_FRAME in "APM_Config.h" and it worked like a charm.  It sees all eight motors now.  I still don't see how to do it from the make command line though.

Here's an open request to the existing Ardupilot (particularly Arducopter) developers:  If you guys would invest a little time getting me up to speed, I'd be glad to be an active developer on this project.  I can send my info via private email, and I believe I could be reasonably helpful.  I bet a 30 minute phone call and a few emails would get me up to speed.

Thanks in advance,

Brian

Randy Mackay

unread,
Jul 5, 2014, 9:45:41 PM7/5/14
to drones-...@googlegroups.com

 

     I think the list of frames is all in the mk/targets.mk file.

 

# cope with copter and hil targets

FRAMES = quad tri hexa y6 octa octa-quad heli single

BOARDS = apm1 apm2 apm2beta apm1-1280 px4 px4-v1 px4-v2 sitl flymaple linux vrbrain vrbrain-v40 vrbrain-v45 vrbrainv-50 vrbrain-v51 vrubrain-v51 vrhero-v10

 

     ..but it may be that to upload a octa-quad a new entry needs to be added to mk/px4_targets.mk.  It may currently only be possible to upload a quad.

px4-v2-upload: px4-v2

                $(RULEHDR)

                $(v) $(PX4_MAKE) px4fmu-v2_APM upload

 

Brian,

     Regarding coming up to speed.  It’s always difficult for the current devs to keep up with the development, support, wiki updates, etc but in any case, feel free to ping me on skype and maybe I can help answer some questions.  I’m rmackay9.

 

-Randy

Randy Mackay

unread,
Jul 5, 2014, 9:50:10 PM7/5/14
to drones-...@googlegroups.com

 

     The problem I find with that pull request is that it means that any changes to the eclipse project will cause git to think you want to update the project file so you constantly need to cache the change to your project file before doing a commit.  Then eclipse starts complaining that the project file has gone missing or has changed, etc.

 

-Randy

--

Brian DeBusk

unread,
Jul 5, 2014, 9:59:11 PM7/5/14
to drones-...@googlegroups.com
Randy:

I'll definitely look into the mk/targtets/file.  And I'll also take you up on that skype offer.  I don't mind sweating through code and doing things the hard way, but I'd appreciate a jump start first.

Brian

Arthur Benemann

unread,
Jul 5, 2014, 10:09:33 PM7/5/14
to drones-...@googlegroups.com
@Randy: I do not follow your comment about eclipse. I have been including the eclipse project file on DroidPlanner since the beginning of the project, and it has almost never changed (except for moving the project folders, and renaming the project ). It makes much easier for users to import the project into their workspace.

Brian DeBusk

unread,
Jul 6, 2014, 6:23:14 PM7/6/14
to drones-...@googlegroups.com
I am pretty sure that make only supports uploading the quad. 

But what I was doing was:

"make px4-v2-otca"

Then verifying that a new .HEX file had been written to the correct directory.

Then manually uploading that custom build through mission planner.  But every time it uploaded, it had compiled the quad code.  I tried compiling -v2-hexa and -v2-octa and it always made quad code (I could tell because my motor test would only let me test four motors).  Then I used MP to load the 3.15 release of the Octa build, and the motor test showed all eight motors.

Could make be broken for the px4-v2-octa configuration?



On Saturday, July 5, 2014 9:45:41 PM UTC-4, Randy Mackay wrote:

Brian DeBusk

unread,
Jul 6, 2014, 9:37:08 PM7/6/14
to drones-...@googlegroups.com
I started with a fresh install of the PX4 tools and from the PX4 console I typed:

make px4-v2
make px4-v2-hexa
make-px4-v2-octa

And while it reported making new files each time (they all had the appropriate date stamp), they were all the same "ArduCopter-v2.px4" file.

Brian DeBusk

unread,
Jul 7, 2014, 5:50:30 AM7/7/14
to drones-...@googlegroups.com
Turns-out if you just scratch one of the files (update a file, even if it's a meaningless change), then it will make the correct version.  But simply going from px4-v2 to px4-v2-hexa on the same code base results in the old configuration being rebuilt.


Tim F40

unread,
Jul 8, 2014, 10:51:55 PM7/8/14
to drones-...@googlegroups.com
I followed the instructions today and got the quad build working via bash and Eclipse. They both give exactly the same resulting build logs, and produce identical ArduCopter-v2.px4 files. HOWEVER, they also produce 18 errors and hundreds of warnings.

e.g.;

comparing floating point with == or != is unsafe [-Wfloat-equal] ArduCopter  line 101, external location: c:\Users\me\Documents\GitHub\ardupilot\libraries\AP_Math\location.cpp C/C++ Problem

cast from function call of type 'void *' to non-matching type 'unsigned int' [-Wbad-function-cast] ArduCopter  line 106 C/C++ Problem

Am I missing some path elements, or something else? I assume everything builds with no warnings/errors normally, correct?

Thanks,

Tim

Message has been deleted

Kevin Hester

unread,
Jul 9, 2014, 12:09:47 AM7/9/14
to drones-discuss
Hmm,

If you are going from the eclipse project file I made some time ago, an "eclipse build" is really just running make (which is what you want) at the bottom. 

Alas - yes, even the regular build where we manually run make results in many warnings.  Did you make the eclipse .projectfile  yourself?  If so, you probably need to turn off their built in running of a C++ compiler for syntax highlighting - or do a lot of tweaking to make it happy.


On Tue, Jul 8, 2014 at 8:06 PM, Tim F40 <tim...@gmail.com> wrote:
I did a clean install today as per the dev site and was able to build the quad file via Bash and Eclipse. They both gave identical build logs and produced identical ArduCopter-v2.px4 files. They also gave 100s of warnings and 18 errors.

e.g.,

cast from function call of type 'void *' to non-matching type 'unsigned int' [-Wbad-function-cast] ArduCopter  line 106 C/C++ Problem

comparing floating point with == or != is unsafe [-Wfloat-equal] ArduCopter  line 108 C/C++ Problem

I assume I'm missing something in the setup instructions and that a normal make builds with no errors/warnings?

Thanks,

Tim

Randy Mackay

unread,
Jul 9, 2014, 12:29:28 AM7/9/14
to drones-...@googlegroups.com

 

     Whenever I have errors building, it can usually be fixed by making  sure the NuttX and PX4Firmware braches are up-to-date and then doing:

         make px4-clean

         make px4-v2

 

-Randy

 

From: drones-...@googlegroups.com [mailto:drones-...@googlegroups.com] On Behalf Of Kevin Hester
Sent: July 9, 2014 1:09 PM
To: drones-discuss
Subject: Re: [drones-discuss] Re: Definitive Tutorial for Compiling Pixhawk Code on Eclipse

 

Hmm,

Tim F40

unread,
Jul 9, 2014, 1:58:47 AM7/9/14
to drones-...@googlegroups.com
Eclipse is just using the standard make file, thus giving identical build results as running make in Bash. I.e., it's not an Eclipse issue. I did not create my own make file. Yes, I've done the clean and make multiple times while gathering data for this post. Many warnings come from non-recent code so they've been there awhile. So either I've got some setting different (I followed the web setup instructions), or there are really hundreds of warnings. The latter doesn't make sense because you guys probably would never RC code with all the issues.

So, when you use Eclipse to make arducopter, the problems tab doesn't show all these issues? The same issues are obviously in the make output, but are harder to pick out unless you're reading it line by line.

If the above doesn't ring a bell, I'll upload the Bash make output I captured via pipe (captured normal and error output).

Seems like if my settings were off, make wouldn't finish and certainly wouldn't generate the FW file at the end.

Thx - Tim

Randy Mackay

unread,
Jul 9, 2014, 4:43:20 AM7/9/14
to drones-...@googlegroups.com
Sorry, I wasn't clear in my previous email, like Kevin says, there are billions of warnings at the moment (but no errors). I don't think you can be seeing any errors if a .px4 firmware file is being generated at the end of it all.

We should clean up those warnings of course. When we were APM2 only we had almost no warnings but with all the new boards they've started to appear. In the few examples that I looked at getting rid of, it was because of #defines in the code which meant that some variables were unused. It's possible to clear them up and all help would be appreciated. It's not a super fun thing to do either I recognise.

-Randy

Brian DeBusk

unread,
Jul 9, 2014, 5:16:34 AM7/9/14
to drones-...@googlegroups.com
In Eclipse, you most definitely have to go into the Preferences and turn off (just uncheck the high-level box) the entire Syntax and Semantic checking or the code is unreadable.  It reports a crazy number of pre-compile errors even though it will actually compile..

Also associate the *.pde file type with C++ even though the tutorial says to use the C file type..

Brian DeBusk

unread,
Jul 9, 2014, 5:32:01 AM7/9/14
to drones-...@googlegroups.com
As of 5:30 AM EST today, there may be something broken (I'm going to guess it's in the makefile)

$ make px4-v2
HAL_BOARD=HAL_BOARD_PX4 TOOLCHAIN=NATIVE EXTRAFLAGS=-DGIT_VERSION="e1a6b07e" -DNUTTX_GIT_VERSION="f2466b87" -DPX4_GIT_VERSION="ae809423"
make[1]: Entering directory `/c/Users/Brian/Documents/GitHub/PX4Firmware'
%% Configuring NuttX for px4fmu-v1
include/arch/board already exists but is not a symbolic link
make[2]: *** [clean_context] Error 1
make[1]: *** [/c/Users/Brian/Documents/GitHub/PX4Firmware/Archives/px4fmu-v1.export] Error 2
make[1]: Leaving directory `/c/Users/Brian/Documents/GitHub/PX4Firmware'
make: *** [/c/Users/Brian/Documents/GitHub/PX4Firmware/Archives/px4fmu-v2.export] Error 2


Brian DeBusk

unread,
Jul 9, 2014, 7:36:40 AM7/9/14
to drones-...@googlegroups.com
I re-cloned all the directories and it compiled just fine.

I swear I think Eclipse breaks things from time to time.  It's good for editing code, but I might use the PX4 console elusively for doing my builds.

Tim F40

unread,
Jul 9, 2014, 12:16:46 PM7/9/14
to drones-...@googlegroups.com
Thanks for all the info. Turns out the so called 18 "errors" are due to an Eclipse bug and don't show in the make output. The make warnings are real, which the above posts have acknowledged, so I know how to proceed. - Tim

Thomas Anderson

unread,
Aug 1, 2014, 1:37:06 PM8/1/14
to drones-...@googlegroups.com
Hi Brian,

 I was wondering if you ever figured out what the issue was ? I have been running into the same problem and re-cloning the code doesn't help too. Would really appreciate any help with this.

Thanks!

On Wednesday, July 9, 2014 5:32:01 AM UTC-4, Brian DeBusk wrote:

Wey Fun

unread,
Nov 27, 2014, 11:13:47 PM11/27/14
to drones-...@googlegroups.com
Hi;
 
Anyone has problem uploading custom .px4 code to Pixhawk?  I built the px4 (amended the quad type in APM-config.h to Y6_Frame) using make and it produces the arducopter-v2.px4 file, but when I tried to upload this custom firmware via APMPlanner 2.0 it just kept going without replying that uploading is complete.  When I upload the generic stable or beta  code for the Y6 it was OK - 100% within seconds.
 
Fun Wey

Randy Mackay

unread,
Nov 28, 2014, 3:10:06 AM11/28/14
to drones-...@googlegroups.com

I have no problem uploading custom .px4 code to Pixhawk.  I compile with Eclipse on Windows but I must upload with Mission Planner’s custom firmware link because I’ve never managed to get the upload from eclipse to work.

 

-Randy

--

Reply all
Reply to author
Forward
0 new messages