mirror of https://github.com/ArduPilot/ardupilot
SITL: Numerous improvements to vagrant image and easier SITL for mac/windows
For full instructions/notes see Tools/vagrant/README.md Notes: * Old Vagrantfile updated to run faster and self init with our various build dependancies. * The sim_vehicle.sh script will now implicitly configure if necessary * run_in_terminal_window.sh is now smart enough to use Screen sessions. Or if those are not available to warn the user but run the command with logging going to a file in /tmp.
This commit is contained in:
parent
4ee9575e6d
commit
ad9c3d730c
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This is a helper script for run_in_terminal_window.sh. I'm not sure why Ardupilot.elf exits if not run from inside of a script
|
||||||
|
echo running $*
|
||||||
|
( $* )
|
||||||
|
echo cmd exited
|
|
@ -13,8 +13,14 @@ elif [ -x /usr/bin/konsole ]; then
|
||||||
/usr/bin/konsole --hold -e $*
|
/usr/bin/konsole --hold -e $*
|
||||||
elif [ -x /usr/bin/gnome-terminal ]; then
|
elif [ -x /usr/bin/gnome-terminal ]; then
|
||||||
/usr/bin/gnome-terminal -e "$*"
|
/usr/bin/gnome-terminal -e "$*"
|
||||||
|
elif [ -n "$STY" ]; then
|
||||||
|
# We are running inside of screen, try to start it there
|
||||||
|
/usr/bin/screen -X screen -t $name $*
|
||||||
else
|
else
|
||||||
echo "ERROR: Please install xterm"
|
filename="/tmp/$name.log"
|
||||||
exit 1
|
echo "Window access not found, logging to $filename"
|
||||||
|
cmd="$1"
|
||||||
|
shift
|
||||||
|
( run_cmd.sh $cmd $* &>$filename < /dev/null ) &
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -210,6 +210,10 @@ pushd $autotest/../../$VEHICLE || {
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
if [ ! -f $autotest/../../config.mk ]; then
|
||||||
|
echo Generating a default configuration
|
||||||
|
make configure
|
||||||
|
fi
|
||||||
if [ $CLEAN_BUILD == 1 ]; then
|
if [ $CLEAN_BUILD == 1 ]; then
|
||||||
make clean
|
make clean
|
||||||
fi
|
fi
|
||||||
|
@ -322,6 +326,11 @@ options=""
|
||||||
if [ $START_HIL == 0 ]; then
|
if [ $START_HIL == 0 ]; then
|
||||||
options="--master $MAVLINK_PORT --sitl $SIMOUT_PORT"
|
options="--master $MAVLINK_PORT --sitl $SIMOUT_PORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If running inside of a vagrant guest, then we probably want to forward our mavlink out to the containing host OS
|
||||||
|
if [ $USER == "vagrant" ]; then
|
||||||
|
options="$options --out 10.0.2.2:14550"
|
||||||
|
fi
|
||||||
options="$options --out 127.0.0.1:14550 --out 127.0.0.1:14551"
|
options="$options --out 127.0.0.1:14550 --out 127.0.0.1:14551"
|
||||||
extra_cmd1=""
|
extra_cmd1=""
|
||||||
if [ $WIPE_EEPROM == 1 ]; then
|
if [ $WIPE_EEPROM == 1 ]; then
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Vagrant for SITL and ardupilot development
|
||||||
|
|
||||||
|
We support a vagrant container for _easily_ running SITL (software in the loop simulator) and compling Ardupilot code.
|
||||||
|
This README is mean't to be the instructions on how to run this.
|
||||||
|
|
||||||
|
## Install vagrant for your platform
|
||||||
|
|
||||||
|
Windows, OS-X and Linux are supported. [Download](https://www.vagrantup.com/downloads.html) and install per their instructions.
|
||||||
|
|
||||||
|
## Start a vagrant instance
|
||||||
|
|
||||||
|
* Change the current directory to be any directory inside this source tree and run "vagrant up". It will start running the instance
|
||||||
|
in a VM (the initial time you run this command it will likely need to fetch many things). All the files in this directory tree will
|
||||||
|
magically appear inside the running instance at /vagrant.
|
||||||
|
|
||||||
|
## Start running SITL
|
||||||
|
|
||||||
|
In your vagrant shell run:
|
||||||
|
<pre>
|
||||||
|
vagrant ssh -c "sim_vehicle.sh -j 2"
|
||||||
|
</pre>
|
||||||
|
This will build the Ardupilot code if needed and then run the simulator. The mavlink prompt allows you to monitor vehicle state. To exit
|
||||||
|
the simulation just press control-d to exit the mavlink shell.
|
||||||
|
|
||||||
|
## Run mission planner or mavproxy in your main OS
|
||||||
|
|
||||||
|
You can now connect to the running simulator from your main OS. Just connect to UDP port 14550, either from mission planner or mavproxy.
|
||||||
|
The mavproxy command is "mavproxy.py --master=127.0.0.1:14550"
|
||||||
|
|
||||||
|
## Shutting down the simulator
|
||||||
|
|
||||||
|
* When you are done with the simulator, just press ctrl-d in the vagrant ssh window to exit the special mavproxy that is gluing everything together.
|
||||||
|
* Run "vagrant suspend" to stop the running VM. When you need it again just run "vagrant up" to resume.
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Initial setup of SITL-vagrant instance."
|
||||||
|
sudo apt-get -y update
|
||||||
|
sudo apt-get -y install dos2unix python-wxgtk2.8 python-scipy python-matplotlib python-opencv python-pip g++ g++-4.7 gawk git ccache python-serial python-wxgtk2.8 python-lxml screen
|
||||||
|
|
||||||
|
sudo pip install pymavlink MAVProxy
|
||||||
|
|
||||||
|
echo "source /vagrant/Tools/vagrant/shellinit.sh" >>/home/vagrant/.profile
|
||||||
|
ln -s /vagrant/Tools/vagrant/screenrc /home/vagrant/.screenrc
|
||||||
|
|
||||||
|
echo "NOTE: Currently this vagrant file only support simulating copters and rovers, adding support for plane would be straightforward,"
|
||||||
|
echo "just add JSB sim per Tridge's instructions (and send in a pull-request)"
|
||||||
|
|
||||||
|
#
|
||||||
|
# vagrant ssh -c "screen -d -R"
|
|
@ -0,0 +1,10 @@
|
||||||
|
altscreen on
|
||||||
|
term screen-256color
|
||||||
|
bind ',' prev
|
||||||
|
bind '.' next
|
||||||
|
#
|
||||||
|
#change the hardstatus settings to give an window list at the bottom of the
|
||||||
|
#screen, with the time and date and with the current window highlighted
|
||||||
|
hardstatus alwayslastline
|
||||||
|
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
|
||||||
|
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Init that is run every time a new session starts up
|
||||||
|
|
||||||
|
export APMROOT=/vagrant
|
||||||
|
export PATH=$APMROOT/Tools/autotest:$PATH
|
||||||
|
|
||||||
|
cd $APMROOT/ArduCopter
|
||||||
|
|
||||||
|
echo "Ardupilot environment ready. Run 'sim_vehicle.sh' to start simulating an arducopter instance."
|
||||||
|
echo "or run 'make sitl' to just do a test build."
|
||||||
|
echo "NOTE: This vagrant build environment isn't currently intended for building PX4 loads, but if someone wants"
|
||||||
|
echo "to add that ability it wouldn't be too difficult."
|
|
@ -1,15 +1,35 @@
|
||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
Vagrant::Config.run do |config|
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||||
config.vm.box = "ubuntu-12.04-32bit"
|
VAGRANTFILE_API_VERSION = "2"
|
||||||
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
|
|
||||||
|
|
||||||
config.vm.share_folder("ardupilot", "/home/vagrant/ardupilot", ".")
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
|
|
||||||
# Allow symlinks
|
config.vm.box = "ubuntu/trusty32"
|
||||||
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/cross-compiler", "1"]
|
# push.app = "geeksville/ardupilot-sitl"
|
||||||
# Otherwise the compile will go into swap, making things slow
|
|
||||||
config.vm.customize ["modifyvm", :id, "--memory", "2048"]
|
# Allow symlinks - I think this is no longer needed
|
||||||
|
# config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/cross-compiler", "1"]
|
||||||
|
|
||||||
|
# The following forwarding is not necessary (or possible), because our sim_vehicle.sh is smart enough to send packets
|
||||||
|
# out to the containing OS
|
||||||
|
# config.vm.network "forwarded_port", guest: 14550, host: 14550, protocol: "udp"
|
||||||
|
|
||||||
|
# Provider-specific configuration so you can fine-tune various
|
||||||
|
# backing providers for Vagrant. These expose provider-specific options.
|
||||||
|
# Example for VirtualBox:
|
||||||
|
#
|
||||||
|
config.vm.provider "virtualbox" do |vb|
|
||||||
|
# Don't boot with headless mode
|
||||||
|
# vb.gui = true
|
||||||
|
#
|
||||||
|
# # Use VBoxManage to customize the VM. For example to change memory:
|
||||||
|
vb.customize ["modifyvm", :id, "--memory", "2048"]
|
||||||
|
vb.customize ["modifyvm", :id, "--ioapic", "on"]
|
||||||
|
vb.customize ["modifyvm", :id, "--cpus", "2"]
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.provision :shell, path: "Tools/vagrant/initvagrant.sh"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue