# Setting up VM & start SITL using Vagrant (Mac) ###### tags: `Drone` ## Install Virtual machine [Click to install VirtualBox](https://www.virtualbox.org/wiki/Downloads) ## Install Vagrant [Click to install Vagrant](https://www.vagrantup.com/downloads.html) ## Manual Intrustions ### Setup * Download Ardupilot repository from GitHub ``` git clone https://github.com/ArduPilot/ardupilot.git ``` * Change directory to ardupilot file ``` cd ardupilot ``` * Start Vagrant ``` vagrant up ``` * Initialise git submodules ``` vagrant ssh ``` ``` cd /vagrant ``` ``` git submodule update --init --recursive ``` ``` exit ``` ### Start running SITL * MultiCopter ``` vagrant ssh -c "sim_vehicle.py -j 2 -v ArduCopter" ``` * Plane ``` vagrant ssh -c "sim_vehicle.py -j 2 -v ArduPlane" ``` * Vehicle ``` vagrant ssh -c "sim_vehicle.py -j 2 -v Rover" ``` ### Shut down simulator ==Ctrl + d== OR ``` vagrant suspend ``` ### Restarting the simulator ``` vagrant up ``` ``` vagrant ssh -c "sim_vehicle.py -j 2" ``` ## SITL Visualization ### Install [Click to install Xquartz](https://www.xquartz.org/) ### Check configuration Check ==Vagrantfile== to setup X11 forwarding. Mine is already set init. ``` Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.forward_x11 = true ``` ### Start vagrent Open the terminal use the Xquartz. ``` vagrant up ``` ``` HOST_IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') ``` ``` xhost + $HOST_IP ``` ``` vagrant ssh -c "sim_vehicle.py -j 2 --console --map --out=$HOST_IP:14550 -v ArduCopter " -- -X ``` ![](https://i.imgur.com/OsEFmB6.jpg) ## Commands * check command list ``` help ``` * check parameters ``` param show ``` * Set parameters ``` param set PARAMNAME VALUE ``` * Restart ``` reboot ``` * Takeoff >takeoff 20 meters ``` takeoff 20 ```` ![](https://i.imgur.com/euzB6Nr.png) * Check mode ``` mode ``` * Change mode >ex. Change to GUIDED mode ``` mode GUIDED ``` * Battery information ``` bat ``` ## Problems When the SITL start initial normally will show Flight battery 100 percent. In my case it start 0% at initial and it shows ==Flight battery warning==. ![](https://i.imgur.com/R9uBo6x.png) First check the parameters of battery. ![](https://i.imgur.com/S6Ba5AB.png) Set the BATT_CAPACITY parameter to 100. Typing bat to check the battery information. ![](https://i.imgur.com/HQB7Hc1.png) ==The problem solve.== ## Reference ### Website * [Setting up SITL using Vagrant](https://ardupilot.org/dev/docs/setting-up-sitl-using-vagrant.html) * [VirtualBox](https://www.virtualbox.org/wiki/Downloads) * [Vagrant](https://www.vagrantup.com/downloads.html) ### Video <i class="fa fa-youtube" aria-hidden="true"></i> {%youtube NEZBF33f2UY%}