This is the second post on my GSoC project of integrating AirSim simulator with ArduPilot SITL.
This will also be my submission for the GSoC final evaluation, where links to PRs and code is needed. So the post will have links to my PRs at some places, do excuse me for the same.
In my previous post, I had written about AirSim and the features I would aim to develop over the course of the project. All of the things mentioned henceforth have been merged into ArduPilot & AirSim (unless mentioned otherwise) and documentation for the setup and usage can be found at - http://ardupilot.org/dev/docs/sitl-with-airsim.html
The first thing which was done was to build the interface from both ArduPilot and AirSim’s side for the basic SITL usage. I haven’t personally tested all the flight modes but the common ones such as Stabilize, Guided, Loiter, PosHold, Auto, RTL, Circle, etc. have been tested to be working.
A few key points about the interface -
Lock-Step Scheduling - This is where the Physics runs with a constant timestep, with each step being synchronized with the firmware control. This allows attaching a debugger to either the SITL or even AirSim, stop at breakpoints, resume, all without any effect on the physics.
JSON packets - The sensor data from the simulator to ArduPilot is sent as JSON packets. This allows easy addition or removal of sensors and fields in the packet as needed without breaking the existing interface. This has been used for adding Lidar and RC Control.
Cross-Platform - The setup has been tested to be working on Linux (Ubuntu 16.04) as well as with AirSim on Windows & SITL in WSL Ubuntu 18.04
Running on different machines - AirSim being a more resource-consuming simulator, it can be a common usage to have it run on a separate system than ArduPilot or even different OSes. The ports can also be changed as needed
AirSim has support for Lidar Sensor and adding this was essential for using AirSim as a suitable simulator for working on Obstacle Avoidance and related tasks. Usage instructions are in Wiki.
Note: Very recently, Dijkstra & BendyRuler Avoidance was added in Copter 3.7.0 Dev, haven’t tested it again with these but will do so soon and make changes if needed
PR in ArduPilot - https://github.com/ArduPilot/ardupilot/pull/11835 (Merged, has RC and Multi-Vehicle as well)
3. Manual Flying using RC
RC can be used with AirSim, and the same data is passed to SITL, now you can enjoy flying as crazily as you want in these nice, scenic environments available in Unreal Engine!
Multi-vehicle simulation is another feature which AirSim has, and this works with ArduPilot as well!
An example script is present in libraries/SITL example folder and usage instructions are in the Wiki.
This script spawns 2 copters, with Follow mode enabled in the second one. Both can be controlled from any GCS such as Mavproxy or QGC, and have the second follow the first.
5. AirSim APIs
AirSim has a rich set of Python & C++ APIs for getting information and for controlling the movement of the vehicle.
After some discussion with my mentors, we decided that adding support for the movement APIs isn’t a priority for now since it anyways won’t be used on a real vehicle and there are other alternatives such as DroneKit.
The other APIs not related to the vehicle movement such as the Image APIs work correctly. There are some tutorials on using ROS with AirSim, please check airsim_tutorial_pkgs & airsim_ros_pkgs on using them.
Any method of controlling the movement which connects directly to ArduPilot rather than using AirSim’s API work, examples include DroneKit & ROS with Mavros.
AirSim by default comes with a simple Blocks environment, which is a very lightweight world suited for development. The environment used in the video above is called Landscape Mountains, and there are many such detailed environments available in the Unreal MarketPlace which can be downloaded and used.
This interface would also be present in the next Release of AirSim, which has the AirSim plugin packaged with many different environments, for Windows and Linux, which will allow users to test it out much more easily without going through the entire setup.
Rover Vehicle Coming Soon!
After the work on Copter was done apart from fixes now and then, I started looking at adding support for Rover vehicle and experimenting with it. There are still some problems left to be figured out to get it working, but still, quite a lot of the work has been done!
These past three months with ArduPilot have been a great time for me, from learning new things to being a part of a community, the experience was unparalleled. Especially since it was my first dive-down into working with large codebases, let alone two of them!
@tridge and @peterbarker have been incredibly helpful and considerate as mentors, really could not have asked for better! A huge shoutout to the other developers of ArduPilot, always there to help out when stuck, some of the early users who started using this and gave valuable feedback and lastly the developers of AirSim who gave advice on going about the project & later on reviewed and merged the code.
Though officially my GSoC work with Ardupilot is over, I look forward to continuing working with this team and taking the AirSim integration even further.