Git Product home page Git Product logo

mavsdk-java's Introduction

MAVSDK-Java

This is the Java frontend implementation to MAVSDK.

It is organized as follows:

  • The examples directory contains Java and Android examples using the sdk.
  • The sdk directory contains the actual SDK.
  • The mavsdk_server directory contains the Android library exposing mavsdk_server.

QuickStart

The fastest way to start is to follow the instructions in the README of the java-client example. For Android, the android-client is the next step.

Please note MavsdkServer currently is not compatible for running on x86 and x86_64 Android images. If you would like to develop using MavsdkServer, you will need to deploy and develop using an ARM-based product or emulator.

MAVSDK-Java is distributed through MavenCentral, meaning that it can be imported using gradle with:

dependencies {
    ...
    implementation 'io.mavsdk:mavsdk:2.1.0'
    ...
}

For Android, mavsdk_server is distributed as an Android library (aar):

dependencies {
    ...
    implementation 'io.mavsdk:mavsdk:2.1.0'
    implementation 'io.mavsdk:mavsdk-server:2.1.0'
    ...
}

ProGuard

ProGuard users may need to add the following rule:

-keep class io.mavsdk.** { *; }

Notes

  1. MAVSDK-Java's plugins initialize on a background thread (mavsdk-event-queue). The initializations happen in a thread-safe manner and the library handles the correct order itself. This is done to provide a simple API to the users.

  2. For Android, run the mavsdk_server as follows:

MavsdkServer server = new MavsdkServer();
MavsdkEventQueue.executor().execute(() -> server.run(SYSTEM_ADDRESS, MAVSDK_SERVER_PORT));

This makes sure that the calling thread (which may be the UI thread) is not blocked as the mavsdk_server discovers a system. This should ideally be done before the user creates the io.mavsdk.System so that MavsdkServer.run() is the first command to run in the mavsdk-event-queue.

To stop the server:

MavsdkEventQueue.executor().execute(() -> server.stop());
  1. Users should avoid using the plugins directly by accessing them only through io.mavsdk.System objects.

The plugins are constructed and initialized lazily upon their first call through System, therefore the users do not bear any runtime overhead for the plugins that they won't be using.

  1. Data streams start flowing in the background once the system is discovered by the mavsdk_server, so they are safe to subscribe to immediately after the creation of a System object. Streams that are not accessed won't start flowing.

  2. One-shot calls like takeoff and land are not added to the mavsdk-event-queue when the user subscribes to them. This is done to avoid their piling up while the mavsdk_server discovers a system. Instead, the onError callback will be triggered after a 100ms delay indicating that no system was available for the command.

Contributing

Coding style

Java/Android coding style is ensured using CheckStyle with the Google style.

Command line

A checkstyle task is defined in the root build.gradle of each project and can be run as follows:

$ ./gradlew checkstyle

The build task depends on checkstyle, meaning that $ ./gradlew build runs the checks as well.

IntelliJ / Android-Studio

There exist a plugin for CheckStyle in JetBrains' IDEs.

Setup
  1. Install the plugin called "CheckStyle-IDEA" in IntelliJ / Android-Studio.
  2. Import the checkstyle configuration as a code style scheme in Settings > Editor > Code Style > Java > Manage... > Import... by selecting "CheckStyle configuration" and then browsing to config/checkstyle/checkstyle.xml.
  3. In Settings > Other Settings > Checkstyle, change the "Scan Scope" to "Only Java sources (including tests)".
  4. Still in Settings > Other Settings > Checkstyle, add a new configuration file and browse to config/checkstyle/checkstyle.xml.
Usage

In IntelliJ / Android-Studio's bottom task bar, you should see a "CheckStyle" tab. It will allow you to select your configuration with the "Rules" dropdown-list, and to run the analysis on your code.

Note that by default, the IDE will not run checkstyle when building the project (whereas $ ./gradlew build always does it).

Troubleshooting

In IntelliJ / Android-Studio, the IDE might force the order of the imports in a way that is not following the checkstyle rules. For some reason, this is not set when importing checkstyle.xml as a code style scheme. However, it can be manually updated in Settings > Code Style > Java > Import Layout.

Releasing

Both sdk and mavsdk_server are released with Maven. Publishing can be done through a gradle task:

./gradlew uploadArchives

This task requires a few secrets in gradle.properties:

signing.keyId=<keyId>
signing.password=<password>
signing.secretKeyRingFile=<ring_file>

ossrhUsername=<username>
ossrhPassword=<password>

Debugging without pushing to maven

Sometimes you just need to rebuild mavsdk_server or even libmavsdk_server.so a couple of times to directly debug a problem.

This can be achieved with the Gradle composite builds. This is already setup in the Android example project here (just uncomment the lines to build sdk and/or mavsdk_server from sources, as described in the Gradle documentation).

Then you can just build the example and it will in turn build mavsdk_server.

To replace the libmavsdk_server.so, you have to build it using dockcross and replace the file for the architecture that you're testing on. This is assuming you have MAVSDK-Java and MAVSDK side to side in the same directory:

cd ../MAVSDK
docker run --rm dockcross/android-arm64 > ./dockcross-android-arm64 && chmod +x ./dockcross-android-arm64
tools/generate_mavlink_headers.sh
./dockcross-android-arm64 cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -Bbuild/android-arm64 -DMAVLINK_HEADERS="mavlink-headers/include" -H. -DCMAKE_INSTALL_PREFIX=build/android-arm64/install
./dockcross-android-arm64 cmake --build build/android-arm64 --target install && cp build/android-arm64/install/lib/libmavsdk_server.so ../mavsdk-android-test/mavsdk_server/src/main/prebuiltLibs/arm64-v8a/libmavsdk_server.so

Now build, install, run the Android app again.

mavsdk-java's People

Contributors

divyanshupundir avatar enymuss avatar hamishwillee avatar jjcetraro avatar jonasvautherin avatar josephm28 avatar julianoes avatar katawann avatar muramura avatar ph0tonic avatar ryanhurst avatar sefibrah avatar simon-ballantyne-online avatar simon-xisystems avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mavsdk-java's Issues

Mission upload progress

It sometimes takes a considerable amount of time to upload large missions or while using slow telemetry modules. Is there a way to get the mission upload progress so that the user may get an estimate of how much time may be required to upload the mission?

Something similar to drone.getMission().getMissionProgress(), that tells x out of n Mission Items have been uploaded.

No System error in android-client

Hello. I have question in android-client example.
I followed java-client README.md (cause of no README file in android-client), but there're some problems in running android-client example.
When running it, the error occurred
"W/System.err: io.reactivex.exceptions.OnErrorNotImplementedException: NO_SYSTEM: No system"
image

I think it's because there's no simulator…… right?
The java README file says run a simulator(I used jMAVSim) mavsdk_server, after running a server. But I think it doesn't work for android example.

Is there any way to run simulator for android or run the example successfully?
Thanks.

[android-client] [grpc-default-executor-4] - Failed to upload the mission

When trying to run the android-client example, the app opens, the mapView loads and pressing on the screen adds waypoints.
After adding the waypints, pressing the fab does nothing visable on screen. Logcat prints
io.mavsdk.androidclient E/MapsViewModel: [grpc-default-executor-4] - Failed to upload the mission
Pressing Land, Return, Kill or Takeoff all kill the app and it closes.

In the uploadMission, translateFromRpc() returns result.result as ERROR and result.resultStr as also Error.

It looks like it is sending something to a ?simulator?, but can't, so I've tried changing the ip addresses, looking for it to connect.

#Things Tried

  • running on a virtual device in android studio, but can't build due to lacking native.so library, so moved to on-device android testing
  • Changing the BACKEND_IP_ADDRESS to a) phone IP and b) to gazebo-headless broadcasting ip network interface eth0, IP: 172.17.0.2.
    This makes the warning disappear, but nothing happens on screen.
  • running docker run --rm -it jonasvautherin/px4-gazebo-headless:v1.10.1 PHONE_IP, but the docker logs never show something connected to it and the error appears.

Running this on Android version 9.

What can I try to get the android-client example working?

mavsdk server acts as bridge to flight controller?

Dear all,

does mavsdk server acts as bridge?
is it limited only for mavsdk or it can act as mavproxy or mavrouter, sending a command packet to it?

for deeper understanding, I sending commands to mavproxy which in return send the command to FC.
my question if mavsdk_server acts the same way?

Remove replay(1) from streams

The replay operator is added to all the flowable streams in the library.

return flowable
  .replay(1)
  .autoConnect();

This creates certain issues while using them.

  1. It is difficult to differentiate between live events and cached ones. For example, if we subscribe to Camera.CaptureInfo at some point in time, the last data point gets sent even if the photo may have been taken 10 minutes ago.

  2. If someone is using LiveData on Android, which does its own caching, the caching on the library side further creates some unexpected behaviour.

Yes, the replay is useful under certain situations, but it requires tricky workarounds to invalidate it downstream once its added. Therefore, I feel that simply returning the flowable without the replay is good enough, and the library should let the user implement the caching on his/her own.

Any thoughts?

Link libc statically for Android

If I use the shared libc, I failed back to the issue I have because I have multiple libc++_shared.so:

More than one file was found with OS independent path 'lib/x86/libc++_shared.so'. If you are using jniLibs and CMake IMPORTED targets, 
see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

I gave more details few weeks ago in a post on the PX4 discussion forum

Originally posted by @Katawann in #65 (comment)

Offboard flight when drone is on mission?

How to send offboard flight commands when UAV is on mission?

Now I'm pausing mission and I'm making PositionNEDYaw object like this:

drone.getMission().pauseMission(); //for pausing
drone.getOffboard().setPositionNed(new Offboard.PositionNEDYaw(0f,0f,10f,45f)); //for offboard flight

SDK build faild

Hello,
I can not build sdk. When I try to build sdk, the result is:

damian@jarvis:~/git/MAVSDK-Java/sdk$ ./gradlew build 

> Task :dronecode-sdk:generateProto FAILED
protoc plugin 'dcsdk' not defined. Trying to use 'protoc-gen-dcsdk' from system path

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dronecode-sdk:generateProto'.
> protoc: stdout: . stderr: protoc-gen-dcsdk: program not found or is not executable
  --dcsdk_out: protoc-gen-dcsdk: Plugin failed with status code 1.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
3 actionable tasks: 1 executed, 2 up-to-date

And running with --info option, gives:

> Task :dronecode-sdk:extractIncludeProto UP-TO-DATE
Skipping task ':dronecode-sdk:extractIncludeProto' as it is up-to-date.
:dronecode-sdk:extractIncludeProto (Thread[Execution worker for ':',5,main]) completed. Took 0.02 secs.
:dronecode-sdk:extractProto (Thread[Execution worker for ':',5,main]) started.

> Task :dronecode-sdk:extractProto UP-TO-DATE
Skipping task ':dronecode-sdk:extractProto' as it is up-to-date.
:dronecode-sdk:extractProto (Thread[Execution worker for ':',5,main]) completed. Took 0.001 secs.
:dronecode-sdk:generateProto (Thread[Execution worker for ':',5,main]) started.

> Task :dronecode-sdk:generateProto FAILED
Task ':dronecode-sdk:generateProto' is not up-to-date because:
  Task has failed previously.
Custom actions are attached to task ':dronecode-sdk:generateProto'.
Resolving artifact: [group:com.google.protobuf, name:protoc-gen-javalite, version:3.0.0, classifier:linux-x86_64, ext:exe]
Resolved artifact: /home/damian/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protoc-gen-javalite/3.0.0/ff5b99fa1e45b51e0350b8da0fa20d47677b3a09/protoc-gen-javalite-3.0.0-linux-x86_64.exe
Resolving artifact: [group:io.grpc, name:protoc-gen-grpc-java, version:1.19.0, classifier:linux-x86_64, ext:exe]
Resolved artifact: /home/damian/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.19.0/f833e69df003f88d975fcb55a464e6e2d1954eb4/protoc-gen-grpc-java-1.19.0-linux-x86_64.exe
Resolving artifact: [group:com.google.protobuf, name:protoc, version:3.6.1, classifier:linux-x86_64, ext:exe]
Resolved artifact: /home/damian/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protoc/3.6.1/f8584d1e86d1adb61d9c559e4b49cedbc97c4d78/protoc-3.6.1-linux-x86_64.exe
file or directory '/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/src/main/proto', not found
protoc plugin 'dcsdk' not defined. Trying to use 'protoc-gen-dcsdk' from system path
[/home/damian/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protoc/3.6.1/f8584d1e86d1adb61d9c559e4b49cedbc97c4d78/protoc-3.6.1-linux-x86_64.exe, -I/home/damian/git/MAVSDK-Java/sdk/proto/protos, -I/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/build/extracted-protos/main, -I/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/build/extracted-include-protos/main, --dcsdk_out=file_ext=java,template_path=/home/damian/git/MAVSDK-Java/sdk/templates/:/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/build/generated/source/proto/main/dcsdk, --plugin=protoc-gen-grpc=/home/damian/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.19.0/f833e69df003f88d975fcb55a464e6e2d1954eb4/protoc-gen-grpc-java-1.19.0-linux-x86_64.exe, --grpc_out=lite:/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/build/generated/source/proto/main/grpc, --plugin=protoc-gen-javalite=/home/damian/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protoc-gen-javalite/3.0.0/ff5b99fa1e45b51e0350b8da0fa20d47677b3a09/protoc-gen-javalite-3.0.0-linux-x86_64.exe, --javalite_out=/home/damian/git/MAVSDK-Java/sdk/dronecode-sdk/build/generated/source/proto/main/javalite, /home/damian/git/MAVSDK-Java/sdk/proto/protos/action/action.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/calibration/calibration.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/camera/camera.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/core/core.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/gimbal/gimbal.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/info/info.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/mission/mission.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/param/param.proto, /home/damian/git/MAVSDK-Java/sdk/proto/protos/telemetry/telemetry.proto]
:dronecode-sdk:generateProto (Thread[Execution worker for ':',5,main]) completed. Took 0.047 secs.

FAILURE: Build failed with an exception.

How to solve it?

Thanks in advance

System.Shell.send(String command) not working

Hello.

First of all, I'd like to say that the MAVSDK team has done an incredible job, especially with MAVSDK-Java.

I have been trying to use the vehicle's system shell to send and receive commands. The setup is as follows:

We have a physical drone running PX4 over NuttX. The telemetry module is connected to my laptop. I am using Mavlink Router to route MavLink messages to QGC, which is running on the same laptop, and my phone, which is connected to the same Wi-Fi network as the laptop.

Now, when I use QGC's MavLink shell to send a command (eg. echo "Hello"), I am able to receive its response on the app through System.Shell.receive(). But when I send a command using System.Shell.send(String command), nothing happens, on both QGS and the app.

Everything else is working fine.

Adding additional metadata to MissionPlan

Is there a way to add custom meta data to the MissionPlan that is uploaded to the UAV? In our case, there are two GCS attached to the drone and we want to retrieve not only the MissionPlan but also our custom metadata uploaded by the first GCS to the second GCS. Both of them are made using MAVSDK-Java. Setting some kind of JSON in the form of String would also work.

`LogFiles#getDownloadLogFile` method doesn't work as expected

This is the signature of the download log file method in log_files package in the Java version:

public Flowable<LogFiles.ProgressData> getDownloadLogFile()

And this is the corresponding one in Python:

async def download_log_file(self, entry, path):

The Java one doesn't have any parameters for entry and path and always throws FILE_OPEN_FAILED: File Open Failed error when I try to use it.

Python-MAVSDK can't retrieve data from Mini Pix after successful connection over serial USB

Hello,

I am trying telemetry.py example python code ( by modifying for serial connection ) to get telemetry data from my Mini Pix . Mavsdk_server can connect to px4 , python code can connect mavsdk_server over tcp connection and i can see that drone discovered with UUID:1 message . But I cant get any data from flight controller.

When i switch to Mission Planer over the same USB connection Mission Planer can access any data in the px4, no problem at all. Very strange thing is that when i close MP and switch back to my python application my application also can get telemetry data without problem.

It seems that MP setting something in the Mini Pix but i dont know what is it ?

Is there a way to solve this problem ?

Thanks

mavsdk java Connection refused: connect

Dear all,

trying to run the java example with mavsdk.
using latest libraries from git.

when starting the software, getting a connection refused: connect

i using herelink controller, and after digging in , i understand that it's getting udp connection and not a tcp connection (as far as i can tall)

in java command

System drone = new System("192.168.50.238",14552);

i dont see how to set udp connection to it.

once it's solved, i have an sdk (tested on sitl) for controlling apm throw mavsdk

any ideas?

Missing filesystem symbols when linking libc on Android

Hello,

The issue I have is when I build the mavsdk_server from source with version v0.38.0-1-2 of mavsdk (I build the mavsdk_server from source because I need to have static library instead of shared). No issue with mavsdk v0.37.0 or version before. The output error I get in Android Studio is:

2021-03-30 19:00:48.493 6573-6685/com.modulesaero41 E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.modulesaero41, PID: 6573
    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNSt6__ndk14__fs10filesystem8__statusERKNS1_4pathEPNS_10error_codeE" referenced by "/data/app/com.modulesaero41-1/lib/arm64/libmavsdk_server.so"...
        at java.lang.Runtime.loadLibrary0(Runtime.java:989)
        at java.lang.System.loadLibrary(System.java:1562)
        at io.mavsdk.mavsdkserver.MavsdkServer.<clinit>(MavsdkServer.java:6)
        at com.modulesaero41.mavsdk.MavsdkModule.<init>(MavsdkModule.java:43)
        at com.modulesaero41.mavsdk.MavsdkPackage.createNativeModules(MavsdkPackage.java:24)
        at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1347)
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1318)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1225)
        at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016)
        at java.lang.Thread.run(Thread.java:761)

I guess the issue can also come from the integration I do into a react-nativ app. I'll try to figure it out on my side and I will come with more accurate description if nobody faced this situation so far.

Usage Examples

Firstly I thank the authors for the amazing work. The examples provided with the repo clearly defines the working of the client applications. However, having examples (and/or) working of drone connectivity, autodiscovery, the architecture of the project would be very helpful.

Thanks in advance

TakeoffAndLand crash

TakeoffAndLand example crashes.
MAVSDK-Java commit 2b83d80
MAVSDK commit e6b98aa1

/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=49942:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/tools.jar:/Users/ryanhurst/work/MAVSDK-Java/examples/java-client/build/classes/java/main:/Users/ryanhurst/work/MAVSDK-Java/sdk/dronecode-sdk/build/classes/java/main:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protobuf-lite/3.0.1/59b5b9c6e1a3054696d23492f888c1f8b583f5fc/protobuf-lite-3.0.1.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.1.7/8c6d3f76a0b8ed49e9d49a5af9c80c5fc2091677/rxjava-2.1.7.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-protobuf-lite/1.19.0/59a8faae44091757f4c2ee541acb9502d7b5f285/grpc-protobuf-lite-1.19.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/org.reactivestreams/reactive-streams/1.0.1/1b1c911686eb40179219466e6a59b634b9d7a748/reactive-streams-1.0.1.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-okhttp/1.19.0/b80265a9029b9d528d771354ea4fe80569717fd4/grpc-okhttp-1.19.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-stub/1.19.0/f9c61fb98a0d5617c430ff3313171072a5b4bca1/grpc-stub-1.19.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-core/1.19.0/48b280ef2c8f42989c65bd61665926c212379660/grpc-core-1.19.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp/okhttp/2.5.0/4de2b4ed3445c37ec1720a7d214712e845a24636/okhttp-2.5.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/26.0-android/ef69663836b339db335fde0df06fb3cd84e3742b/guava-26.0-android.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-context/1.19.0/bb73958187106ef1300b9e47ce5333f40cb913eb/grpc-context-1.19.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.7/751f548c85fa49f330cecbb1875893f971b33c4e/gson-2.7.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.2.0/88e3c593e9b3586e1c6177f89267da6fc6986f0c/error_prone_annotations-2.2.0.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/org.codehaus.mojo/animal-sniffer-annotations/1.17/f97ce6decaea32b36101e37979f8b647f00681fb/animal-sniffer-annotations-1.17.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.opencensus/opencensus-contrib-grpc-metrics/0.19.2/f01f5d7f6689abf980bb0649d6673f286a77f61/opencensus-contrib-grpc-metrics-0.19.2.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/io.opencensus/opencensus-api/0.19.2/5c052b432727b1da381b52e263cbcb7463c43378/opencensus-api-0.19.2.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-compat-qual/2.5.2/dc0b20906c9e4b9724af29d11604efa574066892/checker-compat-qual-2.5.2.jar:/Users/ryanhurst/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.1/976d8d30bebc251db406f2bdb3eb01962b5685b3/j2objc-annotations-1.1.jar io.dronecore.example.TakeoffAndLand
09:53:03.987 [main] DEBUG io.dronecore.example.TakeoffAndLand - Starting example: takeoff and land...
09:53:03.992 [main] DEBUG io.dronecode_sdk.action.Action - Building channel to 127.0.0.1:50051
io.reactivex.exceptions.OnErrorNotImplementedException: UNIMPLEMENTED
        at io.reactivex.internal.observers.EmptyCompletableObserver.onError(EmptyCompletableObserver.java:51)
        at io.reactivex.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:96)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableDelay$Delay$OnError.run(CompletableDelay.java:90)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: io.grpc.StatusRuntimeException: UNIMPLEMENTED
        at io.grpc.Status.asRuntimeException(Status.java:532)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        ... 3 more
Exception in thread "RxComputationThreadPool-1" io.reactivex.exceptions.OnErrorNotImplementedException: UNIMPLEMENTED
        at io.reactivex.internal.observers.EmptyCompletableObserver.onError(EmptyCompletableObserver.java:51)
        at io.reactivex.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:96)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableDelay$Delay$OnError.run(CompletableDelay.java:90)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
        at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: io.grpc.StatusRuntimeException: UNIMPLEMENTED
        at io.grpc.Status.asRuntimeException(Status.java:532)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        ... 3 more

goToLocation causing landing

I've got the drone taking off, and then I'm calling the goToLocation action to get the drone to fly to a specified latitude and longitude. Instead, the drone lands - mavsdk detects a landing. No flying to the location, just landing.

My code:
drone.getAction() .gotoLocation(waypoint.latitudeInDigitalDegrees, waypoint.longitudeInDigitalDegrees, (float) waypoint.altitudeInMeters, Float.NaN) .doOnError(throwable -> { LOGGER.error("Failed to go to next waypoint: " + ((Action.ActionException) throwable).getCode()); success.set(false); }).subscribe();

Any information would be greatly appreciated!

Solution: Dependency resolution problems (NoClassDefFoundError or duplicate class error)

Dependency resolution is a known problem in protobuf javalite projects. There are two situations when a user will be using the mavsdk library in their applications:

  1. The users build the jar themselves and use something like implementation(files("libs/mavsdk-<version>.jar"))

In this case, since the metadata of the libraries used by mavsdk internally is not included in the form of the pom file (which Gradle uses to add the internal dependencies), the users will have to add all mavsdk dependencies themselves.

Declaring dependencies like this should work:

def grpcVersion = "1.36.2"
implementation "io.grpc:grpc-okhttp:${grpcVersion}"
implementation("io.grpc:grpc-protobuf-lite:${grpcVersion}")  {
    exclude group: "com.google.protobuf", module: "protobuf-javalite"
}
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation 'org.slf4j:slf4j-api:1.7.25'
// Other mavsdk dependencies
  1. The users use the published artefact:

Internal dependencies need not be included again. Simply doing this will work:

implementation("io.mavsdk:mavsdk:<versison>")  {
    exclude group: "com.google.protobuf", module: "protobuf-javalite"
}

Adding the virtual joysticks to the android app

Hello everyone, I am new at this. But I would like to add an opportunity to control the drone through the joysticks. Can I do it through the MAVSDK Java? And could someone tell the guideline of how should I implement it? What data should I work with?

Download Mission triggers User callback queue overflown error

Hello,

I am running into an issue where calling the downloadMission() api leads to User callback queue overflown error error on the mavsdk console causing the System's Core plugin connection state to disconnect

The issue occurs with a large mission uploaded to Gazebo headless docker instance. There are 2 different instances of error I see:

  1. On an area of 160 acre with around 2000 waypoints - User callback queue overflown error
  2. On an area of 10 acre with around 500 waypoints - User callback queue too slow

Below is the code I am using:

mav.getMission().downloadMission().subscribe({ MissionProto.MissionPlan plan -> println('Downloaded')}, {})

I was initially using the blockingGet() api and I thought the error could be because this blocking api. But the results are same with subscribe() too

mav.getMission().downloadMission().blockingGet()

Please advise.

Thank You

Timeout while uploading MissionPlan in Android

I am currently testing my Android app using jMAVSim and PX4_SITL. While trying to upload a MissionPlan to the drone, and I am getting WARN [mavlink] Operation timeout on the console and the following logs in Android Studio Logcat:

2020-10-30 15:25:03.894 30927-31026/<package> E/LOG_<package>.repositories.DroneRepository: TIMEOUT: Timeout
    io.mavsdk.mission.Mission$MissionException: TIMEOUT: Timeout
        at io.mavsdk.mission.Mission$1.onNext(Mission.java:420)
        at io.mavsdk.mission.Mission$1.onNext(Mission.java:414)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:421)
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:519)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

This is the code that I use:

    public void uploadAndExecuteMission(@NonNull Mission.MissionPlan missionPlan) {
        Disposable d = mDrone.getMission()
                .uploadMission(missionPlan)
                    .doOnComplete(() -> logD("Uploading mission"))
                    .doOnError(this::logE)
                .andThen(mDrone.getAction().arm())
                    .doOnComplete(() -> logD("Armed"))
                    .doOnError(this::logE)
                .andThen(mDrone.getMission().startMission())
                    .doOnComplete(() -> logD("Starting mission"))
                    .doOnError(this::logE)
                .subscribe(() -> { }, this::logE);

        mCompositeDisposable.add(d);
    }

Everything works perfectly well when I try to arm, take off, or land the drone (both in SITL and a physical drone).

Does anyone have any ideas on what could be going wrong and how to fix it?
Thanks in advance.

Missing classes

I have some classes that are missing and that classes are Action and Mission and Telemetry Classes.

No way to shut down the channel in an Action/Misison/etc?

These warnings show up, but I don't know how to shutdown a channel properly

2019-04-12 15:20:41.247 32038-32038/io.dronecore.dronecoreclient E/gedChannelOrphanWrapper: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*
        Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
    java.lang.RuntimeException: ManagedChannel allocation site
        at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:94)
        at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:52)
        at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:43)
        at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:449)
        at io.dronecode_sdk.action.Action.createChannel(Action.java:37)
        at io.dronecode_sdk.action.Action.<init>(Action.java:29)
        at io.dronecore.dronecoreclient.MapsActivity.onResume(MapsActivity.java:75)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1412)
        at android.app.Activity.performResume(Activity.java:7300)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3814)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3854)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6718)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

How do I connect to "JAVA"? label:question

Hello, i hava a question

JAVA's running a connection test.
The error below came out.

I don't know what the error is.

FRAME_SIZE_ERROR: 854643
INTERNAL: error in frame handler

I'm using this now. "mavsdk:0.4.0."

"io.grpc.StatusRuntimeException: INTERNAL: error in frame handler at io.grpc.Status.asRuntimeException(Status.java:532) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434) at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699) at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459) at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.io.IOException: FRAME_SIZE_ERROR: 854643 at io.grpc.okhttp.internal.framed.Http2.ioException(Http2.java:590) at io.grpc.okhttp.internal.framed.Http2.access$200(Http2.java:47) at io.grpc.okhttp.internal.framed.Http2$Reader.nextFrame(Http2.java:137) at io.grpc.okhttp.OkHttpClientTransport$ClientFrameHandler.run(OkHttpClientTransport.java:1024) ... 3 common frames omitted

blockingFirst race condition

Telemetry telemetry = new Telemetry();
telemetry.armed().subscribe(armed -> logger.debug("armed: " + armed));
logger.debug("blocking armed: " + telemetry.armed().blockingFirst());

so I’ve found a strange race condition.
sometimes this will output:

16:52:26.985 [main] DEBUG io.dronecode_sdk.telemetry.Telemetry - Building channel to 127.0.0.1:50051
16:52:28.145 [grpc-default-executor-2] DEBUG io.dronecore.example.DroneCoreExample - armed: false
16:52:29.140 [grpc-default-executor-2] DEBUG io.dronecore.example.DroneCoreExample - armed: false
16:52:30.140 [grpc-default-executor-2] DEBUG io.dronecore.example.DroneCoreExample - armed: false
16:52:31.140 [grpc-default-executor-2] DEBUG io.dronecore.example.DroneCoreExample - armed: false

and then it will just repeat indefinitely

then sometimes this will output:

16:54:49.835 [main] DEBUG io.dronecode_sdk.telemetry.Telemetry - Building channel to 127.0.0.1:50051
16:54:51.246 [main] DEBUG io.dronecore.example.DroneCoreExample - blocking armed: false

Process finished with exit code 0

Requesting a new release

It has been a while since the Java bindings got a new release. The newer versions of MAVSDK have certain features that are quite helpful. @JonasVautherin can you please create a new release with the latest stable MAVSDK code?

React Native Module mavsdk-server

@Katawann
Hi, I trying to create a React Native Module with Android Java MAVSDK.

I compiled the main branch binary mavsdk-server with c++_static flag and it gave this error:
"_ZNSt6__ndk14__fs10filesystem8__statusERKNS1_4pathEPNS_10error_codeE"...

I have tried 0.9.1, adding in gradle:
implementation group: 'io.mavsdk', name: 'mavsdk-server', version: '0.9.1'

and it gave me an old error:
More than one file was found with OS independent path 'lib/x86/libc++_shared.so'. If you are using jniLibs and CMake IMPORTED targets...

Any ideas or suggestions?
Thanks.

Originally posted by @nachod30 in #65 (comment)

Backend C++ crash when Mission demo was discovered

This was the crash in the terminal running the backend.

[03:10:29|Info ] New system on: 127.0.0.1:14580 (udp_connection.cpp:225)
[03:10:29|Debug] Component Autopilot (1) added. (system_impl.cpp:385)
[03:10:29|Debug] MAVLink: info: [logger] file: ./log/2019-04-12/21_10_29.ulg (system_impl.cpp:292)
[03:10:30|Debug] Discovered 1 component(s) (UUID: 5283920058631409231) (system_impl.cpp:548)
[03:10:30|Info ] System discovered [UUID: 5283920058631409231] (connection_initiator.h:61)
backend_bin(1962,0x70000b4d4000) malloc: *** error for object 0x7ff8760015d0: pointer being freed was not allocated
backend_bin(1962,0x70000b4d4000) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

This was the crash in logcats

2019-04-12 15:11:19.419 29430-29540/? E/AndroidRuntime: FATAL EXCEPTION: grpc-default-executor-6
    Process: io.dronecore.dronecoreclient, PID: 29430
    io.reactivex.exceptions.OnErrorNotImplementedException: UNAVAILABLE: End of stream or IOException
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
        at io.reactivex.internal.subscribers.LambdaSubscriber.onError(LambdaSubscriber.java:79)
        at io.reactivex.internal.operators.flowable.FlowableDistinct$DistinctSubscriber.onError(FlowableDistinct.java:104)
        at io.reactivex.internal.util.NotificationLite.accept(NotificationLite.java:221)
        at io.reactivex.internal.operators.flowable.FlowableReplay$BoundedReplayBuffer.replay(FlowableReplay.java:860)
        at io.reactivex.internal.operators.flowable.FlowableReplay$ReplaySubscriber.onError(FlowableReplay.java:406)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.error(FlowableCreate.java:288)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain(FlowableCreate.java:531)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.tryOnError(FlowableCreate.java:481)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError(FlowableCreate.java:270)
        at io.dronecode_sdk.telemetry.Telemetry$4.onError(Telemetry.java:564)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: End of stream or IOException
        at io.grpc.Status.asRuntimeException(Status.java:532)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434) 
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) 
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) 
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) 
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699) 
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) 
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) 
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) 
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397) 
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459) 
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584) 
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

DronecodeSDK commit: 531a55b9c0ac9ea7a2dbaa5b17cd67c3f62316f8
DronecoreCore-Java commit: 249a950

Mavsdk server not running

Hi,
I have a problem because I do not know how to run mavsdk server on the macos system. Downloaded mavsdk_server_macos does not allow startup.

newbie question : controlling aux (pwm 6-16)

Dear all,

I started to learn on this sdk, mange to figure out most of question.
how can I control with Java, the pwm6-16, I mean, I want to send a signal to servo, for open/close the hook.

tried to look for it, didn't found it :(

zeev

Command denied and crash in Android

I am trying to implement the TakeoffAndLand example on Android. I am able to control the copter using my phone. It is just that when I press the takeoff or land button while the execution of the previous command hasn't completely finished, I get a command denied error and the app crashes. Is there an elegant way built into the SDK that prevents this from happening?

I have added the log messages below:

2020-09-04 11:15:54.728 25266-25301/com.example.app E/AndroidRuntime: FATAL EXCEPTION: grpc-default-executor-1
    Process: com.example.app, PID: 25266
    io.reactivex.exceptions.OnErrorNotImplementedException: COMMAND_DENIED: Command Denied
        at io.reactivex.internal.observers.EmptyCompletableObserver.onError(EmptyCompletableObserver.java:51)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.tryOnError(CompletableCreate.java:90)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:76)
        at io.mavsdk.action.Action$1.onNext(Action.java:216)
        at io.mavsdk.action.Action$1.onNext(Action.java:210)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:421)
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:519)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: io.mavsdk.action.Action$ActionException: COMMAND_DENIED: Command Denied
        at io.mavsdk.action.Action$1.onNext(Action.java:216) 
        at io.mavsdk.action.Action$1.onNext(Action.java:210) 
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:421) 
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33) 
        at io.grpc.ForwardingClientCallListener.onMessage(ForwardingClientCallListener.java:33) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:519) 
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

Thank you.

App crashes when its conneciton is lost

Steps to reproduce:
Connect to backend over wifi.
Turn off wifi.

2019-04-12 15:25:20.986 32038-32293/? E/AndroidRuntime: FATAL EXCEPTION: grpc-default-executor-10
    Process: io.dronecore.dronecoreclient, PID: 32038
    io.reactivex.exceptions.OnErrorNotImplementedException: UNAVAILABLE: End of stream or IOException
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
        at io.reactivex.internal.subscribers.LambdaSubscriber.onError(LambdaSubscriber.java:79)
        at io.reactivex.internal.operators.flowable.FlowableDistinct$DistinctSubscriber.onError(FlowableDistinct.java:104)
        at io.reactivex.internal.util.NotificationLite.accept(NotificationLite.java:221)
        at io.reactivex.internal.operators.flowable.FlowableReplay$BoundedReplayBuffer.replay(FlowableReplay.java:860)
        at io.reactivex.internal.operators.flowable.FlowableReplay$ReplaySubscriber.onError(FlowableReplay.java:406)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.error(FlowableCreate.java:288)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain(FlowableCreate.java:531)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.tryOnError(FlowableCreate.java:481)
        at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError(FlowableCreate.java:270)
        at io.dronecode_sdk.telemetry.Telemetry$4.onError(Telemetry.java:564)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: End of stream or IOException
        at io.grpc.Status.asRuntimeException(Status.java:532)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434) 
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) 
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) 
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) 
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699) 
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) 
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) 
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) 
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397) 
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459) 
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584) 
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 

sending commands in java

Dear all,

after struggling to connect mavsdk to apm drone via herelink,
i was finally able to connect :)

how do i send commands to the drone?

in mav proxy, i send the command:

COMMAND_LONG 0 0 183 0 7 1500 0 0 0 0 0

how can i achieve that with mavsdk?
once i will be able to send this commands, i can finally write a simpler higher level of sdk to implement both px4 and apm for novice users.

java.net.ConnectException: Connection refused (Connection refused) error when running "./gradlew setRtlAltitude"

Hello,

Looking for help to fix this issue, to find the bug in how the java-client has been set up on my local machine.
Going through the java-client example, mavsdk_server and headless gazebo runs, but ./gradlew setRtlAltitude comes up with an error.

MAVSDK server runs and connects to Gazebo.

MartaS:MAVSDK userX$ build/release/install/bin/mavsdk_server
[05:03:24|Info ] MAVSDK version: 0.24.0 (mavsdk_impl.cpp:25)
[05:03:24|Debug] New: System ID: 0 Comp ID: 0 (mavsdk_impl.cpp:401)
[05:03:24|Info ] Server started (grpc_server.cpp:38)
[05:03:24|Info ] Server set to listen on 0.0.0.0:51959 (grpc_server.cpp:39)
[05:03:24|Info ] Waiting to discover system on udp://:14540... (connection_initiator.h:22)
[05:03:47|Info ] New system on: 127.0.0.1:60847 (udp_connection.cpp:264)
[05:03:47|Debug] Component Autopilot (1) added. (system_impl.cpp:386)
[05:03:47|Debug] MAVLink: info: [logger] file: ./log/2020-02-23/16_03_47.ulg (system_impl.cpp:292)
[05:03:48|Debug] Discovered 1 component(s) (UUID: 5283920058631409231) (system_impl.cpp:556)
[05:03:48|Info ] System discovered [UUID: 5283920058631409231] (connection_initiator.h:61)

Running headless gazebo:
docker run --rm -it jonasvautherin/px4-gazebo-headless:v1.10.1

INFO  [simulator] Simulator connected on TCP port 4560.
[Msg] Using MAVLink protocol v2.0
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 14570 remote port 14550
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] Opened full log file: ./log/2020-02-23/16_03_47.ulg
INFO  [mavlink] MAVLink only on localhost (set param MAV_BROADCAST = 1 to enable network)
INFO  [mavlink] MAVLink only on localhost (set param MAV_BROADCAST = 1 to enable network)
  MAV_BROADCAST: curr: 0 -> new: 1
INFO  [px4] Startup script returned successfully
pxh> INFO  [ekf2] Mag sensor ID changed to 197388
INFO  [ecl/EKF] EKF aligned, (pressure height, IMU buf: 22, OBS buf: 14)
INFO  [ecl/EKF] 728000: EKF GPS checks passed (WGS-84 origin set)
INFO  [ecl/EKF] 5196000: EKF commencing GPS fusion

QGroundControl connects and I am able to Take Off and Land manually through QGroundControl.
INFO output is printed for PX4 and MAVSDK server, showing take off and landing took place.

./gradlew takeoffAndLand builds successfully, but maybe it is a silent fail, as nothing shows up in QGroundControl controller, mavsdk_server or simulator logs.

./gradlew takeoffAndLand
> Task :takeoffAndLand
17:21:50.199 [main] DEBUG io.mavsdk.example.TakeoffAndLand - Starting example: takeoff and land...

BUILD SUCCESSFUL in 1s
2 actionable tasks: 1 executed, 1 up-to-date

Output with error from running ./gradlew setRtlAltitude

MartaS:java-client userX$ ./gradlew setRtlAltitude

> Configure project :


=======
WARNING: this is not the best way to run `jshell`, as it may not be cross-platform and it won't have auto-completion enabled.
You may want to run the following instead:

    $ ./gradlew exportDeps
    $ jshell --class-path $(ls -d build/jshell_classpath_export/* | tr '\n' ':')
=======


> Task :setRtlAltitude
17:26:52.422 [main] DEBUG io.mavsdk.example.SetRtlAltitude - Starting example: set RTL altitude...
io.reactivex.exceptions.OnErrorNotImplementedException: UNAVAILABLE
        at io.reactivex.internal.observers.CallbackCompletableObserver.accept(CallbackCompletableObserver.java:48)
        at io.reactivex.internal.observers.CallbackCompletableObserver.accept(CallbackCompletableObserver.java:26)
        at io.reactivex.internal.observers.CallbackCompletableObserver.onError(CallbackCompletableObserver.java:65)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.tryOnError(CompletableCreate.java:90)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:76)
        at io.mavsdk.action.Action$15.onError(Action.java:650)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE
        at io.grpc.Status.asRuntimeException(Status.java:532)
        ... 19 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at java.net.Socket.connect(Socket.java:556)
        at java.net.Socket.<init>(Socket.java:452)
        at java.net.Socket.<init>(Socket.java:262)
        at io.grpc.okhttp.OkHttpClientTransport$4.run(OkHttpClientTransport.java:509)
        ... 4 more
Exception in thread "grpc-default-executor-1" io.reactivex.exceptions.OnErrorNotImplementedException: UNAVAILABLE
        at io.reactivex.internal.observers.CallbackCompletableObserver.accept(CallbackCompletableObserver.java:48)
        at io.reactivex.internal.observers.CallbackCompletableObserver.accept(CallbackCompletableObserver.java:26)
        at io.reactivex.internal.observers.CallbackCompletableObserver.onError(CallbackCompletableObserver.java:65)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableConcatArray$ConcatInnerObserver.onError(CompletableConcatArray.java:60)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.tryOnError(CompletableCreate.java:90)
        at io.reactivex.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:76)
        at io.mavsdk.action.Action$15.onError(Action.java:650)
        at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:434)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:699)
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:397)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:459)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:546)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:467)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:584)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE
        at io.grpc.Status.asRuntimeException(Status.java:532)
        ... 19 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at java.net.Socket.connect(Socket.java:556)
        at java.net.Socket.<init>(Socket.java:452)
        at java.net.Socket.<init>(Socket.java:262)
        at io.grpc.okhttp.OkHttpClientTransport$4.run(OkHttpClientTransport.java:509)
        ... 4 more

This is a clean build with the most recent git commits.
Mavsdk_server was built from the master branch, with the same settings as outlined for building for macOS release in GitHub workflow main.yaml file.

Java version:

java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

Proto version: proto (b34da69)

Uploading a mission will crash in Android api level <24

Steps to reproduce:
Open Mission sample app on an android device running lollipop.
Upload a mission.

If you open up Mission.java, Android Studio provides a warning on line 318:
Method reference requires API level 24 (current min is 21): missionItems.stream().map(elem -> elem.rpcMissionItem())::iterator

Logcats:

04-16 11:27:11.988 6063-6063/io.dronecore.dronecoreclient E/AndroidRuntime: FATAL EXCEPTION: main
    Process: io.dronecore.dronecoreclient, PID: 6063
    java.lang.NoSuchMethodError: No interface method stream()Ljava/util/stream/Stream; in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)
        at io.dronecode_sdk.mission.Mission.uploadMission(Mission.java:318)
        at io.dronecore.dronecoreclient.MapsViewModel.startMission(MapsViewModel.java:58)
        at io.dronecore.dronecoreclient.MapsActivity.lambda$onCreate$0(MapsActivity.java:67)
        at io.dronecore.dronecoreclient.-$$Lambda$MapsActivity$XPnl_5WvEWE9lr8HVMHD3eIKKLc.onClick(lambda)
        at android.view.View.performClick(View.java:4780)
        at android.view.View$PerformClick.run(View.java:19866)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Calibration Callbacks not Triggering

I'm running calibration routines, trying to trigger code based on the calibration succeeding or failing:

drone.getCalibration().getCalibrateGyro()
                        .doOnComplete(() -> Log.d("gyro","complete"))
                        .doOnError(throwable -> Log.d("gyro","error"))
                        .doOnTerminate(() -> Log.d("gyro","terminated")).subscribe();

The drone does start calibrating, but none of the callbacks are triggering upon completion of the calibration routine. Also, on failed calibration, the app as a whole is crashing instead of triggering the onError callback.

Appreciate any ideas. Thanks!

Can Android connect over serial?

Asked on Slack, copying here for the record:

Hello!

Just wanted to know whats the best way to create a custom android groundstation app with mavsdk? There doesn't seem to be any framework for connecting to a serial connection on android to a telemetry module. I tried modifying the qgroundcontrol app but it isn't java based so it doesn't work for my purposes. I also tried using dronekit but their code is so old, much of it is unsupported by android studio, same story with trying to fork Android Tower.

Thanks in advance!

Library source does not match bytecode

Hi,

I got the gradle/maven build by putting in
implementation 'io.mavsdk:mavsdk:0.6.0'
implementation 'io.mavsdk:mavsdk-server:0.6.0'
into build.gradle

When I get the action.java file it complains about it being different to the compiled version. Was wondering if the source and build were somehow different? It still seems to work for telemetry but I was having an issue with actions and thought maybe this was the reason ( I could arm the the drone in the sim, but the .andthen() never execute) ie I get "arming", and the sim says it's armed, but then nothing else happens.
`
try {
System drone = MavlinkService.getInstance().drone.get();
CountDownLatch latch = new CountDownLatch(1);

        drone.getAction().arm()
                .doOnComplete(() -> Log.i(TAG, "Arming..."))

                .doOnError(throwable -> Log.e(TAG,"Failed to arm: "
                        + ((Action.ActionException) throwable).getCode()))

                .andThen(drone.getAction().takeoff()
                        .doOnComplete(() -> Log.i(TAG, "Taking off..."))
                        .doOnError(throwable -> Log.e(TAG, "Failed to take off: "
                                + ((Mission.MissionException) throwable).getCode())))
                .delay(5, TimeUnit.SECONDS)

                .andThen(drone.getAction().land()
                        .doOnComplete(() -> Log.i(TAG, "Landing..."))
                        .doOnError(throwable -> Log.e(TAG, "Failed to land: "
                                + ((Mission.MissionException) throwable).getCode())))

                .subscribe(latch::countDown, throwable -> latch.countDown());

        try {
            latch.await();
        } catch (InterruptedException ignored) {
            // This is expected
        }

        ShowMessage.showMessageShort("Post Request");
    } catch (Exception e) {
        ShowMessage.showErrorMessage(TAG, "CRASH?", e);
    }
}

`

image

Detecting serial connections with android.

Hi,

I am connecting via serial (to a px4) on android and you need to put in a serial connection string :

int mavsdkServerPort = mavsdkServer.run("serial:///bus/usb/001/003:1150200");
How can I:

  • Tell what the connection string is - ie the bus/usb/001/003. I got bus/usb/001/003 from Q ground control.
  • Detect when a new serial connection is successful.

When I plug in the serial device (PX4), q ground ground immediately wants to open it - how do I do that for my own application?

I've had a quick look through https://github.com/mik3y/usb-serial-for-android. Not sure if you are already using this or I need to implement it.

Is there a serial example for android?

I've a quick look at the q ground control source, not sure if I need to do this.

I assume all I need to do is:
Get the connection strings
then should be able to drone.getAction().arm(); etc

Cheers
Michael Swan (emesent)

Camera APIs with Gazebo Simulation not working

Hello Team,

I am trying to simulate a camera with Gazebo SITL. But the camera APIs seem to not working for me.

MAVSDK Java: 0.11
MAVSDK Server: 0.48.0
Gazebo command: make px4_sitl_default gazebo_plane_cam

Snippet:

system.getCamera().getCaptureInfo() .subscribe( { println("Picture taken: " + it.getFileUrl()) }, { println(it.toString()) })

None of the success or error subscriptions are called. If I use blockingFirst(), the code just hangs executing further. Same goes for other camera apis like takePhoto() etc.

Please suggest.

Android Studio Build/Run Errors

Hi,

I am trying to build a demo Android application using the MAVSDK-Java and appear to be running into an issue when trying to build and run the demo android-client.

The android-client demo app builds fine, but throws the following exception;
E/AndroidRuntime: FATAL EXCEPTION: main Process: io.mavsdk.androidclient, PID: 32546 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.mavsdk.androidclient-jUHyjA6idTc61v6a7rECHw==/base.apk"],nativeLibraryDirectories=[/data/app/io.mavsdk.androidclient-jUHyjA6idTc61v6a7rECHw==/lib/x86, /data/app/io.mavsdk.androidclient-jUHyjA6idTc61v6a7rECHw==/base.apk!/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libnative_lib.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at io.mavsdk.mavsdkserver.MavsdkServer.<clinit>(MavsdkServer.java:6) at io.mavsdk.androidclient.MapsActivity.<init>(MapsActivity.java:56) at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newActivity(Instrumentation.java:1173) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

I get a common error when trying to build a new application following the guide, can you confirm how to get around/fix this?

Thanks

Simon.

Flying in a circle with a fixed-wing drone.

Greetings. I would like to implement fixed-wing drone's flight in a circle around a fixed point.

According to what I've found, there are three ways to do that:

  1. Offboard flight mode
    https://mavsdk.mavlink.io/develop/en/guide/offboard.html#fly-a-circle

Unfortunately, this mode is only allowed for copters and VTOLs.

  1. Orbit guided flight mode
    https://docs.px4.io/master/en/flight_modes/orbit.html

Unfortunately, this one has similar limitations.

  1. Building up a number of waypoints that fit the required circle and sending them via general waypoint mission.

It is not really a circle, but I'll go there if I'll find nothing else.

To be honest, it feels that I am trying to solve X/Y problem here, in 3rd approach especially.

How do I do such a flight the most common and general way via MavSDK? I doubt that the ability of a drone to fly around a point is too complicated or unused so that there's no code in the repository already. :)

RC_CHANNELS_OVERRIDE

Dear all,

i need to send values to channel 9-16.
i saw that there is RC_CHANNELS_OVERRIDE commands that can do just that.
how i can implement this in java

thanks in advance

Unable to build mavsdk_server for armv7 android device

Hello,

I'm having difficulty building the backend (C++) for armeabi-v7a. Following the instructions for building from source do not seem to work (get a message about the system no longer using makefiles, instructions coming later?) but I've made what seems to be progress by using the following below, strung together from a variety of web sources for each issue that comes up. It seems the biggest problem is getting gRPC, error below:

CMake Error at cmake/cares.cmake:38 (find_package):
Could not find a package configuration file provided by "c-ares" with any
of the following names:

c-aresConfig.cmake
c-ares-config.cmake

Add the installation prefix of "c-ares" to CMAKE_PREFIX_PATH or set
"c-ares_DIR" to a directory containing one of the above files. If "c-ares"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:135 (include)

command I've attempted (hopefully you can suggest something simpler??) that seems to get somewhere:
cmake -G"Unix Makefiles" -DCMAKE_SYSTEM_NAME="Android" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=${HOME}/Android/android-ndk-r18b -DCMAKE_TOOLCHAIN_FILE=${HOME}/Android/android-ndk-r18b/build/cmake/android.toolchain.cmake -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_BACKEND=ON -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DRUN_HAVE_STD_REGEX=0 -DRUN_HAVE_POSIX_REGEX=0 -DRUN_HAVE_STEADY_CLOCK=0 -Bbuild/android -H.

Please let me know if I'm doing anything wrong? I've attempted this on both OSX (10.14.6) and Ubuntu 18.04

I'm looking to build mavsdk_server to install on an armv7 android device. I attempted to use a few different NDK versions as well, 20b, 18b, 17c.

Connecting android example to SITL jmavsim

Hello, I am a beginner. I try to run the android example and connect it to the SITL jmavsim. I wrote in "BACKEND_IP_ADDRESS" IP of network and added jmavsim port (4560). App is opened, but "takeoff" button does not work. How to connect to jmavsim correctly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.