Mavsdk: Connection URL for DroneCore applications

Created on 5 Feb 2018  路  9Comments  路  Source: mavlink/MAVSDK

As DroneCore supports multiple connection interfaces TCP, UDP & Serial, we need to allow user to select either of them while launching the application.
Examples of connection URL could be:

  • UDP: udp://[bind_host][:port]
  • TCP client: tcp://[server_host][:port]
  • Serial: /path/to/serial/device[:baudrate]

For.eg below conn URL _binds to UDP port 14500_

$ ./takeoff_land udp://:14500

binds to default UDP port 14540

$ ./takeoff_land

Connects to TCP Server (192.168.8.2:5760) hosted by MAVLink Router on Intel Aero

$ ./takeoff_land tcp://192.168.8.2:5760

etc.

enhancement

Most helpful comment

I vote any.

All 9 comments

I agree that this would be handy, however, what you add here are cli args to the examples and not to the core library, so this means you'd have to add it one by one to each example.

We'll have to think about this again after the gRPC refactor, I think.

@julianoes Agree.
In case of gRPC it can be handled at single place dronecore_server. We can have one config file to load and connect to any number of vehicles which are listed in config file.
client (applications) just need to query for active vehicles.

How about this ?

  • DroneCore Applications are launched via connection URL argument (with default URL udp://:14540)
  • Applications need not parse it, but pass the same to DroneCore which will do the parsing and handle corresponding connection required.
int main(int argc, char **argv)
{
   DroneCore dc;
   DroneCore::ConnectionResult connection_result;
   if (argc == 1)
     connection_result = dc.add_connection(); // default UDP connection at port 14540
   else if (argc == 2)
     connection_result = dc.add_connection(argv[1]);  // connection URL  of user's preference

...

This removes all overhead from apps whether to call add_udp_connection() or add_tcp_connection(), etc.

That's a good idea.
What about calling it dc.add_any_connection(argv[1])?

Yeah. I think to keep simple and effective:

conn_res = dc.connect(argv[1]);

and

DroneCore::connect(const std::string &connection_url);

Where connection_url could be any of the below:

  • UDP: udp://[bind_host][:port]
  • TCP client: tcp://[server_host][:port]
  • Serial: /path/to/serial/device[:baudrate]

But it's not connect, it's adding a connection. Because you can add several connections and then it will connect once a vehicle appears.

Right. But its connect in case of TCP, because, we get connected to TCP server.
To be consistent, we can keep either of dc.add_any_connection(argv[1]) or dc.add_connection(argv[1]).

I vote any.

Addressed in #264 .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bresch picture bresch  路  5Comments

yusufozben picture yusufozben  路  4Comments

Katawann picture Katawann  路  4Comments

petergerten picture petergerten  路  6Comments

shakthi-prashanth-m picture shakthi-prashanth-m  路  7Comments