Compiling SITL testing on Mac OS X?

1,040 views
Skip to first unread message

Niels Joubert

unread,
Feb 7, 2014, 6:53:15 PM2/7/14
to drones-...@googlegroups.com
Hi guys!

Has anyone managed to get the SITL environment running on Mac OS X 10.9 (Mavericks)? I'm working through trying to get this up and running, but no luck so far.

After fixing the OS inconsistencies in ./sim_arducopter.sh, I'm getting a large amount of errors in compiling the C++ code that appear to be clang-related problems, such as:

/Users/njoubert/Code/THIRD_PARTY/UAVs/ardupilot/libraries/AP_InertialSensor/AP_InertialSensor.cpp:259:18: error: variable length array of non-POD element type 'Vector3f' (aka 'Vector3<float>'); Vector3f prev[num_accels]; 



I'm also not able to run the sim_multicopter.py file:

gnome-terminal -e "../Tools/autotest/pysim/sim_multicopter.py --frame=$frame --home=-35.362938,149.165085,584,180"

Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!

Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Session D-Bus not running. Try running `launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist'.


I'm curious whether anyone else has gotten this to run on OS X?

-Niels 

Jason Short

unread,
Feb 7, 2014, 7:11:59 PM2/7/14
to drones-...@googlegroups.com
Yes, I have it working.

Bill made a few changes to the Inertial and optflow classes to make it complile


Look at his commits and cherrypick the 94cb6fd and 24bf59

Jason

Here is my cheat sheet:

Install just the command line tools for OSX including GCC:

Get modules installed to Python 
sudo easy_install pexpect

sudo easy_install pyserial

sudo easy_install pip

grab Mavlink:

run this setup command in both directories
sudo python setup.py build install
or???
sudo pip install pymavlink MAVProxy

Add this to .profile:
export PATH="$PATH:/Users/jasonshort/Projects/ArduPilot/GIT/MAVProxy"

Setting TMPDIR for Make
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/ArduCopter
TMPDIR=/Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/tmp
make sitl

-------------------------
go to the main Arducopter directory
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/ArduCopter/

Get the elf running:
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/tmp/ArduCopter.build
./ArduCopter.elf

Connect via Telnet
telnet localhost 5760

Connect via mavproxy
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/ArduCopter/
mavproxy.py --master tcp:127.0.0.1:5760
or
mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551 --quadcopter --out 10.25.200.15:14550

Mavproxy : Loading Params into elf - > eeprom.bin
param load ../Tools/autotest/ArduCopter.parm

Mavlink arm check
param set ARMING_CHECK 0
param set FLTMODE1 11

Running Pysim
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/Tools/autotest/pysim
./sim_multicopter.py --frame=+ --home=-35.362938,149.165085,584,180
./sim_multicopter.py --fgout --frame=+ --home=-35.362938,149.165085,584,180
./sim_multicopter.py --frame=+ --home=-35.362938,149.165085,0,0 --fgout=127.0.0.1:5503

Custom autotest command:
cd /Users/jasonshort/Projects/ArduPilot/GIT/Ardupilot/Tools/autotest
./autotest.py build.ArduCopter fly.ArduCopter logs.ArduCopter convertgpx



FAIL GPS
param set SIM_GPS_DISABLE 1

Niels Joubert

unread,
Feb 8, 2014, 12:04:34 AM2/8/14
to drones-...@googlegroups.com
Can we get those commits pull-requested into master?

-Niels

Randy Mackay

unread,
Feb 8, 2014, 12:56:23 AM2/8/14
to drones-...@googlegroups.com

Niels,

 

     The optical flow one is in master now.

 

-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/groups/opt_out.

Andrew Tridgell

unread,
Feb 8, 2014, 3:10:11 AM2/8/14
to Niels Joubert, drones-...@googlegroups.com, billb...@communistech.com
> Can we get those commits pull-requested into master?

The one from Bill for AP_InertialSensor is not correct - it doesn't
handle num_gyros being less than INS_MAX_INSTANCES.

I will push a different form of it to master.

Cheers, Tridge

Andrew Tridgell

unread,
Feb 8, 2014, 3:26:17 AM2/8/14
to drones-...@googlegroups.com
btw, regarding clang support, I think that we should not in general make
changes to ardupilot to support compilers other than gcc. Once we get
into that game then we will quickly end up spending lots of time on
compiler issues and make compromises in the code because some compiler
doesn't support a feature we're using (in this case variable sized stack
arrays).

Making our code portable to multiple boards is worthwhile I think, but
making it portable to multiple compilers for those boards isn't. There
are just too many bad compilers out there and too many ways in which
compiler writers disagree about what is acceptable in C++.

For MacOS SITL what I think should be done is that someone put together
a true gcc/g++ package for recent MacOS versions, or a wiki page
describing how to install it if it already exists. Oh, and if you find
out who decided that installing clang should install an executable
called 'gcc' that calls clang without first making clang support _all_
gcc extensions then please tell them I hate them :-)

Cheers, Tridge

Geoff Stearns

unread,
Mar 26, 2014, 2:57:41 PM3/26/14
to drones-...@googlegroups.com, and...@tridgell.net
I'm trying to set this up now, and came across the following problem when running 'make sitl' (after installing all the other stuff listed above):

HAL_BOARD=HAL_BOARD_AVR_SITL TOOLCHAIN=NATIVE EXTRAFLAGS=-DGIT_VERSION="55c60b8f"
building /var/folders/00/0d8k0000h01000cxqpysvccm001n28/T/ArduCopter.build/ArduCopter.cpp
%% ArduCopter.cpp
make: *** No rule to make target `/Users/user/Documents/git_public/ardupilot/libraries/AP_AHRS/AP_AHRS_HIL.h', needed by `/var/folders/00/0d8k0000h01000cxqpysvccm001n28/T/ArduCopter.build/ArduCopter.o'.  Stop.


Looks like a file was removed, but make (or some other file) expects it to be there. Maybe an easy fix? I'm not familiar enough with Make to debug it.

Jason Short

unread,
Mar 26, 2014, 5:37:43 PM3/26/14
to drones-...@googlegroups.com
Have you successfully compiled before? Make clean forces make to rebuild all the objects which could help.
I don't think anyone knows how to compile for SITL without Clang yet.

Jason


-- 
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.

Geoff Stearns

unread,
Mar 26, 2014, 9:09:49 PM3/26/14
to drones-...@googlegroups.com
I had not, but a make clean and then make sitl fixed it. Thanks!

I had an older (only a few weeks) checkout and had tried to run make, then realized there were changes merged in since the post above, so updated my copy and try to run it again without make clean. Anyway, looks like it's working using the above instructions just without having to cherrypick the two commits.

Geoff Stearns

unread,
Mar 29, 2014, 5:18:34 PM3/29/14
to drones-...@googlegroups.com
Well it builds and I can run things, but I can't figure out how to do a full simulation.

I'd like to be able to connect via Droidplanner so I can test changes I make to that.

Using the above instructions, I've built the .elf using make sitl, all goes well.

Here's what I'm trying (all on a mac running 10.9.2):

From the ArduCopter directory in one terminal window, I start the elf:

ArduCopter$ ./../tmp/ArduCopter.build/ArduCopter.elf

I get: 
Starting sketch 'ArduCopter'
Starting SITL input
bind port 5760 for 0
Serial port 0 on TCP port 5760
Waiting for connection ....

Then I start up the copter simulator (also tried + frame, no difference):
autotest/pysim$ ./sim_multicopter.py --frame=X --home=-35.362938,149.165085,584,180

I get:
Simulating 4 motors for frame X
Starting at lat=-35.362938 lon=149.165085 alt=584.0 heading=180.0

Then, I start up MAVProxy:

autotest$ mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551 --quadcopter --out 10.25.200.15:14550

I get:
Logging to mav.tlog
Loaded module log
Loaded module rally
Loaded module fence
MAV>

Init ArduCopter V3.2-dev (9c5f564d)

Free RAM: 4096
FW Ver: 120
----------------------------------------


Firmware change: erasing EEPROM...
done.
online system 0 component 1
STABILIZE> Mode STABILIZE
APM: Initialising APM...
Entering ESC Calibration: please restart APM.
APM: Initialising APM...
APM: Initialising APM...
[repeats this every second or so forever]

If I try sending a command like 'auto', I get:

STABILIZE> auto
STABILIZE> Got MAVLink msg: COMMAND_ACK {command : 300, result : 0}
AUTO> Mode AUTO
APM: Initialising APM...
[repeats again forever]

Sometimes I see it say something about needing to restart APM 

-----

I thought maybe I had to load the copter params, but when I try to run:
> param load ArduCopter.parm

I get:
Unknown parameter FRAME
Unknown parameter MAG_ENABLE
Unknown parameter FS_THR_ENABLE
Unknown parameter BATT_MONITOR
Unknown parameter CH7_OPT
Unknown parameter COMPASS_LEARN
[ ... repeated for every param in that file ... ]
Loaded 0 parameters from ArduCopter.parm (changed 0)



So, questions:
Do I need to get the params loaded? Any idea why it's not working when I try via MAVProxy?

See anything else I might be missing or doing wrong here?

Thanks for any help!


Jason Short

unread,
Mar 29, 2014, 6:01:49 PM3/29/14
to drones-...@googlegroups.com
You can't run EKF on OSX SITL. There is an issue with the compiler.

Turn off EKF by adding #define AP_AHRS_NAVEKF_AVAILABLE 0 in Arducopter.pde near the top.
Jason

Geoff Stearns

unread,
Mar 30, 2014, 11:34:11 AM3/30/14
to drones-...@googlegroups.com
Added that line and did a make clean; make sitl and tried it all again, seems about the same:


$ mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551 --quadcopter --out 10.25.200.15:14550
Logging to mav.tlog
Loaded module log
Loaded module rally
Loaded module fence
MAV>

Init ArduCopter V3.2-dev (9c5f564d)

Free RAM: 4096
FW Ver: 120
----------------------------------------


Firmware change: erasing EEPROM...
done.
online system 0 component 1
STABILIZE> Mode STABILIZE
APM: Initialising APM...
Entering ESC Calibration: please restart APM.
APM: Initialising APM...
APM: Initialising APM...
[continues forever]


Any other ideas? The ESC calibration message showed up before as well, but not every time I run it.

--
You received this message because you are subscribed to a topic in the Google Groups "drones-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drones-discuss/kLx9kJAT9As/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drones-discus...@googlegroups.com.

Jason Short

unread,
Mar 30, 2014, 5:07:07 PM3/30/14
to drones-...@googlegroups.com
The EKF work is a work in progress. Maybe my hack doesn't shut it off properly so it falls back on the DCM.  Look around for how it is disabled on APM and try to force that. 
Jason

Sent from my iPhone

Geoff Stearns

unread,
Mar 30, 2014, 5:32:04 PM3/30/14
to drones-...@googlegroups.com
Looks fine to me, everywhere that calls it is either controlled by that flag, or is disabled entirely.

How do you know it's the EKF stuff that's messing it up? Is that a hunch or is there some other troubleshooting I could try to figure out the problem?

Ben Nizette

unread,
Mar 30, 2014, 6:00:13 PM3/30/14
to drones-...@googlegroups.com
I think it's actually something to do with parameters rather than (or in addition to?) EKF, specifically a GCC-ism that we use that isn't correctly implemented by Clang.  The only workaround I've heard of that works at this stage is to install /real/ GCC on your Mac and build with that, rather than Clang pretending to be GCC (use "gcc -v" to tell the difference).

HTH.

--Ben.

Jason Short

unread,
Mar 30, 2014, 6:09:41 PM3/30/14
to drones-...@googlegroups.com
That was my problem two weeks ago. It looked almost identical, always initializing. When I disabled EKF it worked right away.
Jason

Jason Short

unread,
Mar 30, 2014, 6:10:31 PM3/30/14
to drones-...@googlegroups.com
If you could explain how to do that I would be grateful.
Jason

Vũ Nguyễn

unread,
Jun 17, 2014, 11:33:35 PM6/17/14
to drones-...@googlegroups.com
Hi Jason,

I'm new to Ardupilot. Could you please instruct how to disable the EKF?

Many thanks.
Vu

Jason Short

unread,
Jun 18, 2014, 10:53:46 AM6/18/14
to drones-...@googlegroups.com
There is a define in the code you can use to disable EKF. Just put it in Arducopter.pde 
I don't have a computer right in front of me so you'll have to poke around. 
Jason

Sent from my iPhone

Víctor MV

unread,
Nov 16, 2014, 9:06:15 PM11/16/14
to drones-...@googlegroups.com
In case anyone is interested in developing in Mac OS i needed to make these changes to be able to compile SITL.

Cheers
Reply all
Reply to author
Forward
0 new messages