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
    ./autogen.sh
    ./configure --enable-libraries --enable-shared --prefix=/opt/jsbsim
    make
    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
    ./fg_plane_view.sh

  2. Second:

    cd sitl
    ./ArduPlane.elf

  3. Third:

    cd sitl/MAVProxy
    ./mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501

  4. Fourth:

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

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 –

Replies

  • Hi Rasmus

    So did you find the solution?

    I am blocked in here, can you help me?

    Thanks!

  • 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

    and:

    $ 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:

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

Activity

DIY Robocars via Twitter
RT @knightsautoteam: Hi @diyrobocars, we are Orlando's first Autonomous racing club and would love your support. We are hosting our first K…
Jan 20
DIY Robocars via Twitter
RT @Heavy02011: #VirtualRaceLeague: @DIYRobocars Race #14 - #ParkingLotNerds join us January 15th for #AutonomousRacing #RoboRace ⁦@DAVGtec…
Jan 16
DIY Robocars via Twitter
RT @chr1sa: And after that came our races, 50 in all. This battle between these two Russians was the best we've ever seen -- incredible fig…
Jan 16
DIY Robocars via Twitter
RT @chr1sa: Before our @DIYRobocars virtual race this weekend, we had a presentation from the team that won the Indy Autonomous Challenge i…
Jan 16
DIY Drones via Twitter
Dec 12, 2021
DIY Robocars via Twitter
Dec 12, 2021
DIY Robocars via Twitter
RT @chr1sa: Just a week to go before our next @DIYRobocars race at @circuitlaunch, complete with famous Brazilian BBQ. It's free, fun for k…
Dec 4, 2021
DIY Robocars via Twitter
How to use the new @donkey_car graphical UI to edit driving data for better training https://www.youtube.com/watch?v=J5-zHNeNebQ
Nov 28, 2021
DIY Robocars via Twitter
RT @SmallpixelCar: Wrote a program to find the light positions at @circuitlaunch. Here is the hypothesis of the light locations updating ba…
Nov 26, 2021
DIY Robocars via Twitter
RT @SmallpixelCar: Broke my @HokuyoUsa Lidar today. Luckily the non-cone localization, based on @a1k0n LightSLAM idea, works. It will help…
Nov 25, 2021
DIY Robocars via Twitter
@gclue_akira CC @NVIDIAEmbedded
Nov 23, 2021
DIY Robocars via Twitter
RT @luxonis: OAK-D PoE Autonomous Vehicle (Courtesy of zonyl in our Discord: https://discord.gg/EPsZHkg9Nx) https://t.co/PNDewvJdrb
Nov 23, 2021
DIY Robocars via Twitter
RT @f1tenth: It is getting dark and rainy on the F1TENTH racetrack in the @LGSVLSimulator. Testing out the new flood lights for the racetra…
Nov 23, 2021
DIY Robocars via Twitter
RT @JoeSpeeds: Live Now! Alex of @IndyAChallenge winning @TU_Muenchen team talking about their racing strategy and open source @OpenRobotic…
Nov 20, 2021
DIY Robocars via Twitter
RT @DAVGtech: Live NOW! Alexander Wischnewski of Indy Autonomous Challenge winning TUM team talking racing @diyrobocars @Heavy02011 @Ottawa…
Nov 20, 2021
DIY Robocars via Twitter
Incredible training performance with Donkeycar https://www.youtube.com/watch?v=9yy7ASttw04
Nov 9, 2021
More…