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.
- Open a terminal console window.
- Make a new folder for simulation software and enter the directory:
mkdir sitl
cd sitl - Install prerequisites, if missing:
sudo apt-get install git python-serial g++ autoconf libtool automake gawk
- 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/ - Build and install JSBSim:
cd jsbsim
./autogen.sh
./configure --enable-libraries --enable-shared --prefix=/opt/jsbsim
make
sudo make install
cd .. - 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 . - 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.
- First terminal:
cd sitl/ardupilot-mega/Tools/autotest
./fg_plane_view.sh - Second:
cd sitl
./ArduPlane.elf - Third:
cd sitl/MAVProxy
./mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 - 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.
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....