This project is the actual Java SDK that gets deployed on Maven Central. It works by connecting to a running instance of mavsdk_server
, that can be downloaded from the MAVSDK release artifacts. By default, it connects on a mavsdk_server
instance running locally (i.e. on 'localhost'), but it can connect on any machine over the network.
Because it is deployed on Maven Central, adding MAVSDK-Java to your project is a matter of adding the dependency to your gradle file:
dependencies {
implementation 'io.mavsdk:mavsdk:2.1.0'
}
In your project, it can then be used to e.g. takeoff with the following (assuming an instance of mavsdk_server
is running):
import io.mavsdk.action.Action
Action action = new Action();
action.arm().andThen(action.takeoff()).subscribe();
Note that the MAVSDK-Java API is using RxJava, for which extensive documentation can be found online. Don't forget to have a look at our examples.
MAVSDK-Java is mainly autogenerated from the MAVSDK proto files, using our protoc-gen-mavsdk plugin and templates. It expects to find protoc-gen-mavsdk
(which can be installed through pip3 install protoc-gen-mavsdk
) in the PATH.
MAVSDK-Java is built using gradle, but protoc-gen-mavsdk
must be in your PATH in order to auto-generate the code. It requires Python 3.6+ and can be installed using:
pip3 install protoc-gen-mavsdk
Make sure to add protoc-gen-mavsdk
to your PATH!
Once the prerequisites are met, the SDK can be built with:
./gradlew build