Ethernet and TCP/IP in ArduPilot


ArduPilot now has good support for TCP/IP over ethernet, both in SITL and on real hardware for flight controllers that have an ethernet connector.
The above picture shows 3 flight controllers that have been tested, all connected to a botblox ethernet switch via the botblox cable adapter boards. The 3 flight controllers from left to right are:

  • a CubePilot CubeRed
  • a CUAV Pixhawk V6X
  • a Holybro Pixhwk6X

For the botblox devices see Products - Standard Series - BotBlox and search for ArduPilot.

These flight controllers all come with ethernet ports. The Holybro and CUAV boards use a 4 pin JST-GH 1.25 mm connector, the CubeRed uses a 5 pin JST-GH 1.25mm connector. The adapter boards from botblox allows you to cross-connect them, so in this photo the 3 flight controllers are all connected to the same ethernet switch, and also connected via a standard ethernet patch cable to my laptop.
What you can do
With the latest ArduPilot firmware installed (4.5.x developer branch) you can do the following:

  • confgure the board with a static IPv4 address, or enable the DHCP client for automatic addressing
  • configure a gateway for access to other subnets
  • configure up to 4 network ports which can be configured for any of the serial protocols supported by ArduPilot in the SERIALn_PROTOCOL options (currently 45 protocols available)
  • for each port, configure it as one of 6 TCP/IP transport types, UDP client, UDP server, TCP client, TCP server, UDP multicast or UDP broadcast

Setting up for networking
Once the hardware is setup you should set NET_ENABLED to 1 and then reboot. This will enable a new parameter tree with the networking parameters.


In the above setup I have the flight controllers IP set to 192.168.13.14 and I have my laptop at 192.168.13.15. I’m not using DHCP in this example. You will need to reboot after seting up your network addresses.
Next, test it with the ping command to make sure you have good connectivity.

Now you can setup some network ports. Here is the setup of the first network port to use UDP unicast to my laptop:
image
I’ve set the protocol to 2 for MAVLink2 as I want to connect a ground station on UDP and I’ve set it to send to UDP port 15001. I could just as easily connect any of the 45 serial protocols we support in ArduPilot (eg. NMEA out, R/C, gimbal devices etc).
You can similarly configure up to 4 network ports with NET_P1 to NET_P4. You can set the type to 1 for UDP client, 2 for UDP server, 3 for TCP client and 4 for TCP server.
For UDP broadcast and multicast you just set it as UDP client then set the target IP address appropriately. For UDP broadcast set it to 255.255.255.255. For UDP multicast you need to set an IP in the IPv4 multicast range.
DDS Support!
We also support TCP/IP for ROS2 DDS. @rfriedman has been working hard on DDS support and we expect to have it available for builds on the custom build server soon with full network support.
Next Steps
We will soon be adding lua scripting bindings for networking which will open up a lot of interesting possibilities, such as a web server and lua scripts making snmp calls.
Following Development*
To join in the development discussions please join the ethernet channel on ArduPilot discord server
Thanks
I’d also like to give a big thank you to @MagicRuB and @bugobliterator for all their work on ethernet support in ArduPilot. It has taken a while, but we are really pleased with the result.

I hope this helps users get started with ethernet on ArduPilot!

21 Likes

@tridge I want to join the test, can you provide me with the firmware for pixhawk v6x?

Excellent info. I just bought a Pixhawk 6X because it had ethernet capabilities. I’m a retired network engineer and it looked interesting to experiment with.

1 Like

Great!
The standard firmware from firmware.ardupilot.org will have support for all of the above features in a few hours time once the current build run is complete

3 Likes

Nice!
maybe you’d like to help find an issue with the code? It all works, but if you try to push TCP too hard the bandwidth suddenly drops by a huge amount.
You can reproduce by building with --enable-network-tests then setting NET_TESTS=4 and setting up a linux box with the discard service (port 9) enabled.
I’ve put a wireshark network capture showing the issue here:
http://uav.tridgell.net/tmp/TCP_test_discard.pcapng
Have a look at TCP port 9 and you’ll see this:


I’m trying to work out if the 1.4s stall is due to packet loss, and if so, is the flight controller losing incoming frames or outgoing frames? Or both?

1 Like


I can start captures as I move along with this build, see what I come up with from there…

Excellent! I have an upcoming project that was going to employ a CubeOrange+, but I may use a V6X in its place just to have a go at this.

Outstanding info, TU!


@tridge I have finished testing pixhawk v6x. I used the CUAV AG module as the router. Have you tested NET_DHCP=1 (default)? It doesn’t seem to work. When I set NET_DHCP to 0, the system works fine.

1 Like

yes, NET_DHCP=1 works for me. It am testing with a DHCP server on linux and it gets an IP allocated correctly by the DHCP client.
Note that NET_DHCP=1 makes ArduPilot a DHCP client not a DHCP server.

yes, you are right. I found an LBA3 base as a DHCP server. DHCP has successfully assigned an IP address to Pixhawk v6x, and I successfully connected to Missionplanner. Have you encountered the problem of unstable data packets and frequent data loss?

1 Like

1 Like

Hi guys, what is the maximum clients the FC can serve concurrently when it is in the role of a TCP server?

we do have a slowdown problem with TCP that I am investigating. For UDP it seems to be doing well with very little packet loss in my tests.
Are you seeing a problem?

unfortunately the TCP server in the NET_Px_ options is one client at a time at the moment. This comes from the way it maps onto a virtual serial port, and we assign a single MAVLink channel.
You can do multiple clients with one port in two ways:

  • use UDP broadcast by setting NET_Pn_TYPE=1 and the IP to 255.255.255.255. You can connect many GCS at once
  • use UDP multicast by setting NET_Pn_TYPE=1 and the IP to a multicast address (typically in the 239.x.x.x range)

There is a downside though. Several of the MAVLink sub-protocols assume only one client at a time. For example, if one client is doing parameter download and another starts downloading parameters on the same port then you will get a lot of loss. Likely you will get all the parameters down eventually, but it isn’t neat. I’m planning to fix this for ftp param downloads in the future.
The same issue can happen with mission upload/download.

1 Like

How feasible would it be to add an NTRIP client? That way my rover could connect via ethernet to a mobile hotspot and receive RTK GPS corrections without requiring a ground control station to forward them.

1 Like

yes, i think that would be a nice example to do with the upcoming lua scripting support for networking

4 Likes

hey folks
what would be the cheapest ardupilot flight controller available currently which can do ethernet?
(I’m afraid cubepilot and the others shown here are a “bit” beyond my budget, and wouldn’t fit so well size and weight wise anyway). I have troubles finding info. Sorry if this is an inappropiate question.

1 Like

This is really good stuff. I bought a Pixhawk 6x last year for the CM4 carrier board. Although it came with a little Ethernet jumper I’ve been using the telemetry 2/AMA0 connection between the CM and Pixhawk, and ground station telemetry over telemetry 1 to a Herelink. Works well enough but would be nice to use Ethernet for all comms.

I’ve also been thinking about how to build a Node-RED GUI for my application. Having Node.js hooks on the autopilot, while probably too much overhead, would make application development much easier.

currently the Pixhawk6X or CUAV-6X are the only ones commercially available that are STM32 based.
You can also run on Linux boards or SITL, but I know that isn’t quite the same thing