New Products Flash Sale
Thread Tools
Old Jun 21, 2014, 11:02 AM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Mini-HowTo
Ardupilot - Setting up and using Simulation with SITL and HIL

*Update 2015-03-03: Kevin has made a vagrant based SITL installer. See: https://groups.google.com/forum/#!to...ss/PVadRaurYS8
and Hamish put instructions in the wiki here: http://dev.ardupilot.com/wiki/simula...using-vagrant/
(Not tried it myself, but it looks interesting.)*


This thread was created to keep away from discussions on "Real" models to avoid confusion.
It is dedicated to the setup and use of the simulation environments that are available for ArduCopter, ArduPlane and ArduRover.

Link to official APM wiki on SITL: http://dev.ardupilot.com/wiki/settin...tl-on-windows/

The two simulation environments available are:
SITL: Software In The Loop.
and
HITL (a.k.a HIL): Hardware In The Loop

SITL runs as an executable in a linux environment, and uses a full sensor emulation.
HIL runs on the actual APM hardware, using the same code but with modifications to allow a simulation of the sensors.
Both can be used together with a flight simulator, Mission Planner and APM Planner.
JNJO is online now Find More Posts by JNJO
Last edited by JNJO; Mar 03, 2015 at 02:41 PM.
Reply With Quote
Sign up now
to remove ads between posts
Old Jun 21, 2014, 11:03 AM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Downloading the ArduPilot code and setting up SITL in Ubuntu.

Thanks to TheQuestor, there is now a really smooth way for installing and launching SITL.
These Guides contains all you need to get SITL up and running in it's basic form

Update 20141213 - Arming problem in recent Master
If you recently set up SITL, or have recently updated the code, you may find that you can't arm using "arm throttle".
Look here for a work-around until the fix is merged.
https://groups.google.com/forum/#!to...ss/t2RwaRiOO8Y

Update 20141204:
Some users have problems with the default maps not loading.
Work-around solution: Maximize your map-window and select another map provider from the "View -> Service" meny.
EDIT: Fixed in MavProxy 2014 Dec. 03 https://github.com/tridge/MAVProxy/pull/88

Get this one for info on how to get Ubuntu installed, using VMware
SITL_Ubuntu_Installation_...

This one covers installing/running SITL on an Ubuntu machine.
SITL_Installer_launcher_g...

This one details how to connect SITL to MissionPlanner, as well as customizing start-up location.
MP_SITL_and_Location

This one deals with getting FlightGear installed and connected to SITL.
FlightGear_SITL

And here's how to connect a Joystick to SITL. It also covers using an FrSky Taranis as a joystick with SITL.
FrSky Taranis and APM_SIT...

This file is the launcher/installer:
sitl_installer_2.1

To do/Wishlist
Figure out how to run *Hawk or APM versions.
Figure out how to download and run a specific older ArduPilot version. Current installer uses latest code from Master

Update December 4, 2014:
Added info in post#2 on getting around a problem with map loading.

Update September 29, 2014
Updated Installer guide to reflect new installer
Added guide for Ubuntu installation
Added updated SITL_Installer_2.1 (Only minor cosmetic changes from 2.0.)

Update July 26, 2014
Added sitl_installer_2.0.sh
The SITL_installer script has been updated with the following:
- Added "-y"-switch to apt get to remove need to confirm all installation steps.
- Added install-prereqs-ubuntu.sh
- Removed redundant entries
- Added change of copter.parm. Arming_check is now disabled when loading default parameters.
- Added option to load default parameters when starting.
- Added requirement to restart Ubuntu after installation.

Wiki updates to follow, but it is essentially the same procedure.

Updated July 16, 2014.
I've added the guide for control with an FrSky Taranis as a joystick.
That's all for now, until something proves to be wrong or stupidly written.
Feedback, good or bad, is always welcome.
JNJO is online now Find More Posts by JNJO
Last edited by JNJO; Dec 13, 2014 at 06:24 AM.
Reply With Quote
Old Jun 21, 2014, 11:03 AM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
File archive of older versions.
sitl_installer_2.0
sitl_installer_launcher
SITL_Manual_Setup_v3.1
SITL_Installer_launcher_g...

Older Guides: Valid in content, but not the easiest way. Kept here for reference. Will not be updated..
The first file is a guide for manually setting up SITL in a virtual Ubuntu machine.
It assumes you are running Windows7, and starts with the VMware installation.
SITL_Manual_Setup_v3.1

This second file guide you through the steps needed for a semi-automatic installation os SITL. It assumes you have Ubuntu 14.04 up and running.
The script it's using saves a lot of typing....
SITL_Semi_Auto_Setup_v1.1
Placeholder for installation script.
sitl_installer

Kudos to TheQuestor and bionicbone for providing essential data for the creation of these guides.

The guide below is for you guys that prefer a quick step-by-step without all the pretty pictures, and/or don't want to run amateur scripts on your machine.
The following assumes you have Ubuntu up and running either as your main operating system or in a virtual machine.
(This guide was shamelessly stolen, and slightly modified, from TheQuestors original post)
In Ubuntu:
Code:
open a command prompt
click the stupid top icon and type term and hit enter

make sure your OS is patched and updated

sudo apt-get update && apt-get dist-upgrade [enter] [this may take a while]

now the stuffs

sudo apt-get install git-core build-essential gnome-session-fallback [enter] [i hate unity]

Then

cd [enter] [sets to your home directory]

git clone git://github.com/diydrones/ardupilot.git [enter]
git clone git://github.com/tridge/jsbsim.git [enter]

sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git [enter]

sudo pip install pymavlink MAVProxy [enter]

nano ~/.bashrc [enter]

[add these at the end of the file]

export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/MavProxy
export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/pymavlink/examples
export PATH=$PATH:$HOME/jsbsim/src
export PATH=/usr/lib/ccache:$PATH
[crtl-x, y, [enter]]

[reload bash]
bash [enter]

cd jsbsim [enter]
./autogen.sh [enter]
make [enter]
cd [enter]
cd ardupilot/ArduCopter [enter]
make configure [enter] [this will take a while]

then
cd [enter]
cd ardupilot/ArduCopter [enter]
or
cd ardupilot/ArduPlane [enter] for you fixedwingers

sim_vehicle.sh -w [first run] [will take a long time]

When you see the text "GPS Lock....", press CTRL-C
Then

sim_vehicle.sh --console --map --aircraft test
Then you can load waypoints and stuff
wp load ../Tools/autotest/ArduPlane-Missions/CMAC-toff-loop.txt

To get the 'Copter in the air, have a look at post #7.

To get the most out of SITL, you really need to get to know MAVProxy.
MAVProxy documentation is here → http://tridge.github.io/MAVProxy/

Plenty fun can be had by connecting APMPlanner or MissionPlanner as well as a flight simulator, like FlightGear.
Once I figure out how to get all that running and can describe it in a coherent way, I will update this thread.

Have fun, and thanks to Tridge and the other Ardupilot developers for all their hard work on this code.


bionicbone used TheQuestors original guide and created a very pretty document with screenshots and all. (I stole plenty from it....)
Trying Again following Th...
JNJO is online now Find More Posts by JNJO
Last edited by JNJO; Oct 04, 2014 at 05:06 AM.
Reply With Quote
Old Jun 21, 2014, 12:35 PM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
HITL together with XPlane 10

My blog on using HITL with X-Plane 10 is here.
http://www.rcgroups.com/forums/showthread.php?t=2034594

I'll edit this post to mirror that info and also test with later firmwares.
JNJO is online now Find More Posts by JNJO
Last edited by JNJO; Jun 22, 2014 at 03:03 AM.
Reply With Quote
Old Jun 21, 2014, 12:35 PM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Place Holder #4
JNJO is online now Find More Posts by JNJO
Reply With Quote
Old Jun 22, 2014, 01:06 AM
bionicbone is online now
Find More Posts by bionicbone
Whoops was it always in 2 bits
bionicbone's Avatar
United Kingdom, England, Rotherham
Joined Oct 2008
1,664 Posts
Some Screen Shots of the Process

Hi JNJO,

Thanks for setting up this thread, I'm going to delete my posts from the APM thread to ensure this special version of the firmware is not uploaded to an APM by a newbie following the APM thread.

Here's a few screen shots of the process, based on TheQuestors instructions.

Can you alter this line in post count 2, i had to add a few other programs to the required list before the process would work. Strangely TheQuestor did not need to do this but guess it would not hurt if he did.

sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git

Cheers
Kev
bionicbone is online now Find More Posts by bionicbone
Reply With Quote
Old Jun 22, 2014, 01:31 AM
bionicbone is online now
Find More Posts by bionicbone
Whoops was it always in 2 bits
bionicbone's Avatar
United Kingdom, England, Rotherham
Joined Oct 2008
1,664 Posts
What we need to do now is have a How To Use Guide.

Once installed and the -w line had been run then I managed to get the copter to follow a mission:-

cd ardupilot/ArduCopter
sim_vehicle.sh --console --map --aircraft test
wp load ../Tools/autotest/ArduPlane-Missions/CMAC-toff-loop.txt
rc 3 -1 [make sure throttle is low before arming]
mode stabilize [make sure we are in stabilize mode before arming]
param set ARMING_CHECK 0 [make life easier for this first attempt]
arm throttle [do the arming process using throttle, console should say ARMED]
mode auto [change mode to auto]
rc 3 1500 [move throttle to mid stick, do quickly else the APM will disarm]

Take Off


Want to see all the commands available?
help

Want to speed up the action?
param set WPNAV_SPEED 9000 [will only apply when the next command is issued, the UAV will drift a lot though at this speed!]

Want to point towards the next Way Point?
param set WP_YAW_BEHAVIOR 1 [will only apply when the next command is issued]

Want to see all the parameters?
param show

Want to change the mode?
mode auto or mode rtl etc.

Roll Right = rc 1 1800, Roll Left = rc 1 1200, No Input = rc 1 1500 [values 1000 to 2000]
Forward = rc 2 1200, Backward = rc 2 1800, No Input = rc 2 1500 [values 1000 to 2000]
Throttle = rc 3 1500 etc. [values 1000 to 2000]
Yaw Right = rc 4 1800, Yaw Left = rc 4 1200, No Input = rc 4 1500 [values 1000 to 2000]
Mode Switch = rc 5 1500 [switch command is easier values 1000 to 2000]

switch 1 or switch 2 changes modes, Standard Modes are 1 = Circle, 2 = Land, 3 = RTL, 4 = AUTO, 5 = Loiter, 6 = Stabilize, 0 = disable

Crtl + C to exit the terminal.

Now I need to learn how to write a script LOL


Kev
bionicbone is online now Find More Posts by bionicbone
Last edited by bionicbone; Jun 22, 2014 at 02:23 AM.
Reply With Quote
Old Jun 22, 2014, 02:59 AM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Thanks, Kev.
Post 2 updated with the modified line.
+1 on a users guide.
I want to look into connecting SITL to a flightsim, and ideally use a RC TX as input.
HITL can do it with XPlane 10, using a Taranis or any trainer interface that can emulate a joystick.

EDIT: I'm working on a detailed SITL-setup for Windows, starting with VMware installation. Stay tuned.
EDIT2: updated post #2 with the setup-guide I'm working on. Any thoughts and/or critizism will be appreciated.
JNJO is online now Find More Posts by JNJO
Last edited by JNJO; Jun 22, 2014 at 11:10 AM.
Reply With Quote
Old Jun 23, 2014, 03:27 PM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Since I'm inherently lazy, I'm trying to write a simple script to automate the install process.
It works fine right down to the point where I have to append the PATH statements to bashrc.
This is where I'm stuck. I'm sure the answer is out there, but I'm at the end of my Googling skills.

What I'm looking for is a command that will open bashrc in an editor, go to end of file, append the five export Path-statements (perhaps from a file?) and then save and close bashrc.

This is what I'm using today. It ends up with opening bashrc in nano:
File: sitl_installer.sh

#!/bin/bash
sudo apt-get update && apt-get dist-upgrade
sudo apt-get install git-core build-essential gnome-session-fallback
cd
git clone git://github.com/diydrones/ardupilot.git
git clone git://github.com/tridge/jsbsim.git
sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git
sudo pip install pymavlink MAVProxy
nano ~/.bashrc
JNJO is online now Find More Posts by JNJO
Reply With Quote
Old Jun 24, 2014, 02:55 AM
TheQuestor is offline
Find More Posts by TheQuestor
Official Stupid Question Asker
TheQuestor's Avatar
United States, TX, San Juan
Joined Mar 2013
5,126 Posts
Quote:
Originally Posted by JNJO View Post
Since I'm inherently lazy, I'm trying to write a simple script to automate the install process.
It works fine right down to the point where I have to append the PATH statements to bashrc.
This is where I'm stuck. I'm sure the answer is out there, but I'm at the end of my Googling skills.

What I'm looking for is a command that will open bashrc in an editor, go to end of file, append the five export Path-statements (perhaps from a file?) and then save and close bashrc.

This is what I'm using today. It ends up with opening bashrc in nano:
File: sitl_installer.sh

#!/bin/bash
sudo apt-get update && apt-get dist-upgrade
sudo apt-get install git-core build-essential gnome-session-fallback
cd
git clone git://github.com/diydrones/ardupilot.git
git clone git://github.com/tridge/jsbsim.git
sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git
sudo pip install pymavlink MAVProxy
nano ~/.bashrc
You can insert the stuff to .bashrc by issuing echo commands

echo "export PATH=$PATH:$HOME/ardupilot/Tools/autotest" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/MavProxy" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/pymavlink/examples" >>~/.bashrc
echo "export PATH=$PATH:$HOME/jsbsim/src" >>~/.bashrc
echo "export PATH=/usr/lib/ccache:$PATH" >>~/.bashrc

The reason i split this into 2 scripts is because when you load bash to load the exports it would stop the script at that point. this way it will run the 1st part and load bash and run the second part.

name this pt1.sh
Code:
#! /bin/bash
sudo apt-get update && apt-get dist-upgrade 
sudo apt-get install git-core build-essential
sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git
sudo pip install pymavlink MAVProxy
cd
git clone git://github.com/diydrones/ardupilot.git
git clone git://github.com/tridge/jsbsim.git
echo "export PATH=$PATH:$HOME/ardupilot/Tools/autotest" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/MavProxy" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/pymavlink/examples" >>~/.bashrc
echo "export PATH=$PATH:$HOME/jsbsim/src" >>~/.bashrc
echo "export PATH=/usr/lib/ccache:$PATH" >>~/.bashrc
bash < pt2.sh
name this pt2.sh
Code:
#! /bin/bash
cd
cd jsbsim
./autogen.sh
make -j4
cd
cd ardupilot/Tools/autotest/
./autotest.py
or just do it without loading the 2nd bash
Code:
#! /bin/bash
sudo apt-get update && apt-get dist-upgrade 
sudo apt-get install git-core build-essential
sudo apt-get install libtool automake autoconf libexpat1-dev python-matplotlib python-serial python-wxgtk2.8 python-scipy python-opencv python-pip ccache g++ g++-4.7 gawk git
sudo pip install pymavlink MAVProxy
cd
git clone git://github.com/diydrones/ardupilot.git
git clone git://github.com/tridge/jsbsim.git
echo "export PATH=$PATH:$HOME/ardupilot/Tools/autotest" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/MavProxy" >>~/.bashrc
echo "export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/pymavlink/examples" >>~/.bashrc
echo "export PATH=$PATH:$HOME/jsbsim/src" >>~/.bashrc
echo "export PATH=/usr/lib/ccache:$PATH" >>~/.bashrc
export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/MavProxy
export PATH=$PATH:/usr/local/lib/python2.7/dist-packages/pymavlink/examples
export PATH=$PATH:$HOME/jsbsim/src
export PATH=/usr/lib/ccache:$PATH
cd
cd jsbsim
./autogen.sh
make -j4
cd
cd ardupilot/Tools/autotest/
./autotest.py
TheQuestor is offline Find More Posts by TheQuestor
RCG Plus Member
Last edited by TheQuestor; Jun 24, 2014 at 03:07 AM.
Reply With Quote
Old Jun 24, 2014, 04:39 AM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Fantastic. Thanks.
I'll have a go tonight.
BTW, insted of ./autotest.py at the end, I use "make configure". It runs quicker.
JNJO is online now Find More Posts by JNJO
Reply With Quote
Old Jun 24, 2014, 04:42 AM
TheQuestor is offline
Find More Posts by TheQuestor
Official Stupid Question Asker
TheQuestor's Avatar
United States, TX, San Juan
Joined Mar 2013
5,126 Posts
Quote:
Originally Posted by JNJO View Post
Fantastic. Thanks.
I'll have a go tonight.
BTW, insted of ./autotest.py at the end, I use "make configure". It runs quicker.
True that would just run the scripts to create the needed makefiles so yah that should work too
TheQuestor is offline Find More Posts by TheQuestor
RCG Plus Member
Latest blog entry: QTipToo.8 Part 5
Reply With Quote
Old Jun 24, 2014, 12:42 PM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
echo did the trick.
I just had to replace "export....." with 'export....', to keep the variables in the text-string from making a mess of .bashrc
Doing a few test runs before I put it in post #2.
JNJO is online now Find More Posts by JNJO
Reply With Quote
Old Jun 24, 2014, 04:59 PM
JNJO is online now
Find More Posts by JNJO
Done Posting, Gone Flying
JNJO's Avatar
Sweden, Uppsala County, Balsta
Joined Jun 2012
1,266 Posts
Post #2 updated with guides for Manual and Scripted SITL setup.
Any guinea-pigs out there?.
JNJO is online now Find More Posts by JNJO
Reply With Quote
Old Jun 25, 2014, 01:58 AM
TheQuestor is offline
Find More Posts by TheQuestor
Official Stupid Question Asker
TheQuestor's Avatar
United States, TX, San Juan
Joined Mar 2013
5,126 Posts
I made a quick and dirty installer/launcher if anyone wants to try it out.

I fixed up a few things in the initial script and tested it a few times on a clean 14.04 ubuntu [thank GOD for VMWare snapshots ]

I still need to work on the colors and see if I can trap control-c but so far it works

sitl installer (2 min 25 sec)


**** ok I trapped control-c so I will do more work on the installer ****

remember when you unzip it [if you don't have zip installed it's sudo apt-get install unzip] you need to make it executable so its chmod +x sitl_installer then ./sitl_installer to run

to download the zip from your nix command prompt you should be able to just wget http://www.rcgroups.com/forums/showa...1&d=1403679192
TheQuestor is offline Find More Posts by TheQuestor
RCG Plus Member
Latest blog entry: QTipToo.8 Part 5
Reply With Quote


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Multirotor Watts Usage Question wildboys Multirotor Talk 13 Nov 02, 2013 03:31 AM
Gallery Hils-Marshonet Sportplane davidterrell80 Scale Drawings and Three Views 0 Oct 26, 2013 12:32 AM
Cool Maynard Hil y su vuelo Transatlantico fbejarano Mexico 0 Jul 22, 2010 12:23 PM
Fly-In 3rd Annual Norm Hils Memorial Fly-In (Colts Neck NJ) stangrob Electric Flight Events 0 May 16, 2006 11:46 AM