mavlink / MAVSDK-Java

MAVSDK client for Java.
73 stars 42 forks source link

mavsdk java Connection refused: connect #87

Closed zeev-mindali closed 2 years ago

zeev-mindali commented 2 years ago

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?

julianoes commented 2 years ago

Can you lay out what is sending on what port and how you are trying to connect?

JonasVautherin commented 2 years ago

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

This is most likely wrong. If you look at the docs:


  /**
   * Create a System object.The plugins are initialized lazily, when the corresponding
   * get method is called.
   *
   * @param host the address of mavsdk_server
   * @param port the port of mavsdk_server
   */
  public System(@NonNull String host, int port)

You should run mavsdk_server separately:

Then you should connect your System object to mavsdk_server, e.g.:

System drone = new System("127.0.0.1", 50051); 

If you run mavsdk_server on the machine running the java code, with -p 50051, then that's the default, so you can just use:

System drone = new System();
zeev-mindali commented 2 years ago

oh, so let me check if i understand correctly i will create mavsdk_server on my machine and send the message to mavsdk, and then the mavsdk_server will send it to the drone, i get it right?

and if i will use the android platform for herelink, i will create mavsdk on android and give him the connection to udp of the drone?

JonasVautherin commented 2 years ago

Exactly. For Android, there is a package on maven for mavsdk_server. We use it in the example app here: https://github.com/mavlink/MAVSDK-Java/blob/main/examples/android-client/app/src/main/java/io/mavsdk/androidclient/MapsActivity.java#L92-L93

zeev-mindali commented 2 years ago

mavsdk_server is connected to my drone, cheers

but when running java examples i getting the error: is stauck for ever in run , i can not write any command to jshell

my goal is to send a message to the drone, in mavproxy i sent : message COMMAND_LONG 0 0 183 0 7 1500 0 0 0 0 0

i sure i missing something stupied here, but what?

also in android , i have mavserver, but where i configure there the drone ip and port?

i think i almost there

thanks for all the help, very appricated

JonasVautherin commented 2 years ago

On Android it's here: https://github.com/mavlink/MAVSDK-Java/blob/main/examples/android-client/app/src/main/java/io/mavsdk/androidclient/MapsActivity.java#L93

How do you run the java examples?

zeev-mindali commented 2 years ago

running the mavserver (found ready exe file :) ) about the java, i run from intellij ide the system shell. but it's stuck and rolling for ever