APM SITL with FlightGear and Ubuntu

I have ArduPilot Mega Software-In-The-Loop almost working in 64-bit Ubuntu 12.04. Only problem is that there seems to be a lack of MAVLink packet communication. Can anyone help me out?


Following is how I set up the simulation software. I hope this will serve as a tutorial once I get past that final problem.


  1. Open a terminal console window.
  2. Make a new folder for simulation software and enter the directory:

    mkdir sitl
    cd sitl

  3. Install prerequisites, if missing:

    sudo apt-get install git python-serial g++ autoconf libtool automake gawk

  4. Download MAVProxy, mavlink, JSBSim and APM:

    git clone git://github.com/tridge/MAVProxy.git
    git clone git://github.com/tridge/mavlink.git
    git clone git://github.com/tridge/jsbsim.git
    git clone https://code.google.com/p/ardupilot-mega/

  5. Build and install JSBSim:

    cd jsbsim
    ./configure --enable-libraries --enable-shared --prefix=/opt/jsbsim
    sudo make install
    cd ..

  6. Build ArduPlane and ArduCopter binaries and copy them from temporary folder:

    cd ardupilot-mega/ArduPlane
    make -f ../libraries/Desktop/Makefile.desktop
    cd ../..
    cp /tmp/ArduPlane.build/ArduPlane.elf .
    cd ardupilot-mega/ArduCopter
    make -f ../libraries/Desktop/Makefile.desktop
    cd ../..
    cp /tmp/ArduCopter.build/ArduPlane.elf .

  7. Install flightgear:

    sudo apt-get install flightgear

Now, because JSBSim did not install it's binaries in the system folders when I ran "make install", I have to make sure that the binaries can be found by simulation scripts. As a temporary hack, I added the following folder to the $PATH variable: "~/sitl/uav/sitl/jsbsim/src". This is where the compiled but uninstalled JSBSim executable is located.


I tried to run the simulation, following this tutorial. Opening four separate terminal tabs, I launched these executables, in order.

  1. First terminal:

    cd sitl/ardupilot-mega/Tools/autotest

  2. Second:

    cd sitl

  3. Third:

    cd sitl/MAVProxy
    ./mavproxy.py --master tcp: --sitl

  4. Fourth:

    cd sitl/ardupilot-mega/Tools/autotest/jsbsim
    ./runsim.py --home=-35.362938,149.165085,584,270 --script=jsbsim/rascal_test.xml --fgout=

Note that if you execute "./fg_plane_view.sh" last, then FlightGear gets stuck at loading scenery.


This is where I ran into problems. The simulation is not moving. In addition, I discovered that the MAVProxy output is too clean -- it has only ASCII text, no binary MAVLink data. The expected output is described here.

What am I missing?

Edit: It seems that things are working. If I type "auto" into the MAVProxy, as Daniel suggested, the plane starts to fly (and crashes into ground in a minute or two). Still, I see no binary data in MAVProxy output, but this may be a feature.

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

Join diydrones

Email me when people reply –


  • Hi Rasmus

    So did you find the solution?

    I am blocked in here, can you help me?


  • Hi Rasmus, I was wondering If it's normal when you compile jsbsim with "make" that appears:

    /usr/bin/ld: cannot find -lexpat
    collect2: ld returned 1 exit status
    make[3]: *** [prep_plot] Error 1
    make[3]: Leaving directory `/home/ubuntu/sitl/uav/sitl/jsbsim/src/utilities'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/ubuntu/sitl/uav/sitl/jsbsim/src/utilities'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/ubuntu/sitl/uav/sitl/jsbsim/src'
    make: *** [all-recursive] Error 1

    Thanks for your reply and excuse me if I'm annoying you making many questions...

  • Hi Rasmus,

    when I try to following step 4, I get this:

    File "./runsim.py", line 162, in <module>
        jsb = pexpect.spawn(cmd, logfile=sys.stdout, timeout=10)
      File "/usr/lib/python2.7/dist-packages/pexpect.py", line 429, in __init__
        self._spawn (command, args)
      File "/usr/lib/python2.7/dist-packages/pexpect.py", line 516, in _spawn
        raise ExceptionPexpect ('The command was not found or was not executable: %s.' % self.command)
    pexpect.ExceptionPexpect: The command was not found or was not executable: JSBSim.

    what should I do?

  • Hi Rasmus,

    I'm trying to build this on Ubuntu 12.10 (64 bit) and, while Arduplane.elf builds fine, I can't seem to run it. I get:

    $ ./ArduPlane.elf
    bash: ./ArduPlane.elf: cannot execute binary file


    $ file ./ArduPlane.elf

    ./ArduPlane.elf: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, not stripped

    Any ideas?

    Cheers, Andrew

  • Like others in this discussion, I've been unable to get the Rascal to successfully take off. HOWEVER, if I start it at an altitude of 500M AGL and then put it into auto mode (or loiter for that matter), I can get it to fly for a substantial amount of time. Altitude appears to be holding well. I've got it working with FlightGear and qGroundStation simultaneously. But it ultimately crashes. Can anyone tell me what I should expect to see? It doesn't appear to be flying on a mission, but it flies within a well defined area.

  • Can you control the plane if you feed ArduPilot RC commands via MAVProxy as described in the link you provided that details the expected output? E.g. what happens if you enter 'rc 3 1400' into your MAVlink connected on 5763?

    Try entering 'auto' into the MAVlink connected on 5763. The plane should start flying counter clockwise and you should get the following feedback:

    MANUAL> APM: command received:
    APM: Returning to Home
    APM: Executing nav command ID #17
    Got MAVLink msg: COMMAND_ACK {command : 300, result : 0}

    Your post actually helped me quite a lot in getting mine going. So thank you for that.

  • hey! is it working now?? I am also having problem with the simulations....

This reply was deleted.


DIY Robocars via Twitter
RT @chr1sa: Donkeycar 4.4 released with tons of new features, including path learning (useful with GPS outdoors), better Web and Lidar supp…
Nov 27, 2022
DIY Robocars via Twitter
RT @NXP: We are already biting our nails in anticipation of the #NXPCupEMEA challenge! 😉 Did you know there are great cash prizes to be won…
Nov 24, 2022
DIY Robocars via Twitter
RT @gclue_akira: レースまであと3日。今回のコースは激ムズかも。あと一歩 #jetracer https://t.co/GKcEjImQ3t
Nov 24, 2022
DIY Robocars via Twitter
UC Berkeley's DIY robocar program https://roar.berkeley.edu/
Nov 24, 2022
DIY Robocars via Twitter
RT @chr1sa: The next @DIYRobocars autonomous car race at @circuitlaunch will be on Sat, Dec 10. Thrills, spills and a Brazilian BBQ. Fun…
Nov 24, 2022
DIY Robocars via Twitter
RT @arthiak_tc: Donkey car platform ... Still training uses behavioral cloning #TCXpo #diyrobocar @OttawaAVGroup https://t.co/PHBYwlFlnE
Nov 20, 2022
DIY Robocars via Twitter
RT @emurmur77: Points for style. @donkeycar racing in @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video. https://t.co/Y2hMyj1…
Nov 20, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Going to @diyrobocars race at @UCSDJacobs https://t.co/Rrf9vDJ8TJ
Nov 8, 2022
DIY Robocars via Twitter
RT @SmallpixelCar: Race @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video. https://t.co/kK686Hb9Ej
Nov 8, 2022
DIY Robocars via Twitter
RT @PiWarsRobotics: Presenting: the Hacky Racers Robotic Racing Series in collaboration with #PiWars. Find out more and register your inter…
Oct 23, 2022
DIY Robocars via Twitter
RT @Hacky_Racers: There will be three classes at this event: A4, A2, and Hacky Racer! A4 and A2 are based around UK paper sizing and existi…
Oct 23, 2022
DIY Robocars via Twitter
Oct 23, 2022
DIY Robocars via Twitter
Oct 19, 2022
DIY Robocars via Twitter
Oct 18, 2022
DIY Robocars via Twitter
RT @NeaveEng: Calling all UK based folks interested in @diyrobocars, @f1tenth, @donkey_car, and similar robot racing competitions! @hacky_r…
Oct 13, 2022
DIY Robocars via Twitter
RT @araffin2: 🏎️ After hours of video editing, I'm happy to share a best of my Twitch videos on learning to race with RL. 🏎️ Each part is…
Oct 13, 2022