Mavsdk is a C++ based API that is capable of interfacing with PX4. It leverages mavlink alongside plugins written for each specific function (Action, System, Mission, etc.) in PX4 to allow for seemless communication from a programmer written code base. There also exists a Python version of the API which can be researched here
In order to communicate with the VOXL2 from MAVSDK, the user must have the two following voxl2 services actively configured and running:
voxl-vision-hub, the user must edit the following two parameters to:
voxl-mavlink-server, the user must edit the following parameter to:
Once these have been services have been configured properly, enabled, and are running in the background, the user now has the ability to interface with PX4 via MAVSDK.
In order to run MAVSDK on target, you must build the voxl-docker-mavsdk docker container that encompasses all the necessary libraries - you can follow the build steps here
This link above is how we recommend running MAVSDK on target (in this case a VOXL2). We run mavsdk inside a bionic docker container that has the ability to interface with the PX4 instance running outside docker. Once you have finished building the docker instance, proceed to
adb shell into the target/voxl2 and spin up the docker instance. This can be done by running the
run-docker.sh executable in the
/data/docker/mavsdk directory of your voxl2.
Once you are in the Docker environment, you can now leverage the pre-written python and C++ examples of MAVSDK to control the drone. The two examples leveraged for this are the
takeoff_and_land code written both in python and C++. If you wish to inspect the actual MAVSDK code that drives the drone to takeoff and land, Python examples can be found here and the C++ examples can be found here.
It is recommended when starting out with MAVSDK to leverage HITL to test out the communications. In order to setup HITL, follow the documentation here.
Below is a video showing how to setup
voxl-docker-mavsdk in tandem with HITL to get a drone armed and flying in the simulation: