Android App - MavsdkServer gets stucked at run()

Hello!

I’m new to Pixhawk and PX4, and I am trying to connect a simple Android app with a simulator (PX4 SITL).
I tried to run the example app from the MAVSDK-Java GitHub repository (Android-Client) but it seems it
always gets stuck at the mavsdkserver.run() even I got a positive connection in the console. (Screenshots below with yellow marker)

My current setup is a Windows 10 Notebook with Android Studio that run an Emulator and WSL - Ubuntu running the PX4 firmware with SITL.

Any ideas what I am doing wrong/missing?

Thanks!

The Code:

private void runMavsdkServer() {
    log("Before MavsdkEventQueue");
      MavsdkEventQueue.executor().execute(() -> {
        log("{Before - mavsdkServer.run}");

        String deviceIpMavsdkServer = "172.30.137.92"; // intern WSL

        String addr = "udp://" + deviceIpMavsdkServer + ":18570"; // use this Port

        log("Do i get that?");

	int mavsdkServerPort = 50051;//mavsdkServer.run(addr, 50051);
        log("And this? - " + mavsdkServer.run(addr, 50051));
        
        log("{After - mavsdkServer.run} Connected to - " + addr + " / on listing Port [" + mavsdkServerPort + "]");
        log("MAVSDK-Server run complete");

        log("{Before - new Drone}");

        drone = new io.mavsdk.System();
        log("{After - new Drone} Drone: " + drone);

      }));

      isMavsdkServerRunning = true;
      runOnUiThread(() -> buttonRunDestroyMavsdkServer.setText(R.string.destroy_mavsdk_server));
    });
    log("After MavsdkEventQueue");
  }

Android console:

PX4 console:

Can you try maybe to put the run() function in a background thread? I never remember if it blocks while the server is running or if it returns when the drone is connected :sweat_smile:

1 Like

Looks like that was it!

Now i just need to learn more about MAVSDK :stuck_out_tongue:

Thank you very much :slight_smile:

2 Likes