Compile, Deploy and Fly — ArduPilot on Mac OS X.
So I recently started playing around with ArduPilot. The Open source project forms a pretty solid autopilot foundation for both fixed-wing and multi-rotor UAVs, but with over 700K lines of code, it can be a beast to install and learn.
The dev docs are really good, but getting the simulator up and running for Mac OS X Yosemite can be a bit tricky, specially because the code can be compiled and simulated in different ways. For the purpose of this blogpost, we will talk about setting up Software in the Loop (SITL) simulator. A mode in which the autopilot runs in a simulated world — the autopilot hardware, the aircraft and the physical world, everything is simulated.
If you’re using ArduPilot on Mac OS X for the first time, this blogpost is perfect for you.
So here’s a dump of the instructions I followed to compile and run ArduPilot on ArduPilot’s Software in the loop (SITL) simulator.
Get the Virtual Machine (VM)
As of this writing, the ArduPilot simulator is only available for Linux and Windows. To get the simulator working on OS X, download a Virtual Machine and a virtual dev environment:
2. Download and install Vagrant for OS X. Vagrant is a lightweight development environment. Makes the development much easier and more reproducible.
Get the ArduPilot Code
The ArduPilot project source code for Plane, Copter, Rover and Antenna Tracker are all available on GitHub.
1. Get the code by cloning (and optionally forking) the repository:
> git clone https://github.com/ArduPilot/ardupilot
You should now have the repository source code cloned on your local machine with /ardupilot as the root directory.
Wake up Vagrant and Enter into VM
The VM and vagrant are now setup, and there should be a copy of the ardupilot source code on our local machine. Start the VM and ssh into it:
- Navigate to /ardupilot/Tools/vagrant
> cd /ardupilot/Tools/vagrant
2. Start vagrant:
> vagrant up
3. Enter VM by ssh-ing as vagrant with X server enabled, on port 2222:
> ssh -X -p 2222 vagrant@localhost
4. When asked for a password, enter “vagrant” as the password.
> vagrant@localhost’s password: vagrant
You should now be inside the VM, ready to launch the simulator.
Launch the simulator
It’s time to compile the ardupilot code and launch it in the simulator. Exciting times.
- Navigate to directory of the vehicle that you wish to simulate. /vagrant/ArduCopter for example for the Copter:
> cd /vagrant/ArduCopter
2. Launch the simulator from this directory using the complete path of the simulator. *Make sure to use the absolute path as shown below*:
> sudo /vagrant/Tools/autotest/sim_vehicle.sh — console — map
The sim_vehicle.sh script will build the autopilot code located in /vagrant/ArduCopter launch the simulator. Final output should look something like this:
That’s it! Now you can try out some of the autopilot commands in the console to communicate with the autopilot as Ground Control Software (GCS) or go back to /vagrant/Ardu* directories to change the vehicle code.
Having the simulator set up first allows you to understand the different components of the system so that you can slowly start experimenting with the autopilot code.
Learn more by visiting ArduPilot’s dev website: http://ardupilot.org/dev/index.html
Questions for me? Drop me an email on email@example.com