This project includes a self-contained cross-platform library to retrieve data from the quadrotor and send the control commands. You can use this library for a simulated drone in Unreal engine or on real quadrotors such as a MavLink based vehicle platform (and very soon DJI quadrotors such as Matrice).
Here's the taste of how you can use our APIs:
#include <iostream>
#include "control/RpcLibClient.hpp"
int main()
{
using namespace std;
msr::airlib::RpcLibClient client;
cout << "Press Enter to arm the drone" << endl; cin.get();
client.armDisarm(true);
cout << "Press Enter to takeoff" << endl; cin.get();
client.takeoff(1000);
cout << "Press Enter to use offboard control" << endl; cin.get();
client.requestControl();
cout << "Press Enter to move 5 meters with 1 m/s velocity" << endl; cin.get();
client.moveToPosition(5, 0, 2.5f, 1);
cout << "Press Enter to land" << endl; cin.get();
client.land();
return 0;
}
You can find ready to run code in HelloDrone folder in the repository.
Above code uses the RPC client to connect to the RPC server that is automatically started by the AirSim. The RCP server routes all the commands to a class that implements DroneControlBase. In essence, DroneControlBase defines our abstract interface for getting data from the drone and sending it commands. We currently have concrete implementation for DroneControlBase for MavLink based vehicles. The implementation for DJI drone platforms, specifically Matrice, is in works.
Here's sample code. For more information, please see DroneControlBase class.
int playWithImages()
{
using namespace std;
using namespace msr::airlib;
msr::airlib::RpcLibClient client;
vector<uint8_t> image = client.getImageForCamera(0, DroneControlBase::ImageType::Depth);
//do something with images
}
Absolutely! The AirLib is self-contained library that you can put on offboard computing modules such as Gigabyte barebone Mini PC. This modules then can talk to flight controllers such as Pixhawk using exact same code and MavLink protocol (or DJI protocol). The code you write for testing in simulator remains unchanged! We will post more detailed guide on how to do this soon.
We are working on enabling other RPC stack such as ZeroMQ over protobufs so we can enable more languages such as Python. We also hope to release ROS adapters for our APIs with Linux builds.