ROS 2 over Ethernet

The following tutorial explains how to connect a flight controller to a companion computer using ethernet for DDS communication.

Ensure you have ROS 2 installed and have run SITL successfully before attempting this page.

Additionally, make sure you understand the basics of networking in ArduPilot.

Motivation

Starting in ArduPilot 4.5, ethernet is now supported as a new communication interface. Compared to connecting an autopilot over serial, ethernet has the following advantages:

  • Ethernet is more immune to noise because it uses twisted pair wiring

  • Ethernet can run multiple protocols over the same protocol (unless you use PPP)

  • Ethernet is easier to debug with tools such as tcpdump or Wireshark

  • Ethernet uses standard cabling, so it’s more difficult to mix up TX and RX

Physical Equipment

The following equipment is required to complete this tutorial:

  • A computer that can run the MicroROS Agent and the ROS 2 CLI

  • An autopilot with ethernet support

Necessary parameters for static configuration

This list of parameters is given as an example. If you had the following static IP addresses:

  • An autopilot has the IP address 192.168.1.6

  • A Computer running the MicroROS agent has the IP address 192.168.1.5

  • The MicroROS agent is running on port 2019

Then, you would configure all of the below parameters.

Parameter Name

Value

DDS_ENABLE

1

DDS_IP0

192

DDS_IP1

168

DDS_IP2

1

DDS_IP3

6

DDS_UDP_PORT

2019

NET_DHCP

0

NET_ENABLE

1

NET_IPADDR0

192

NET_IPADDR1

168

NET_IPADDR2

1

NET_IPADDR3

5

Modify the addresses to suit your needs; the rest can remain the same.

Steps

  1. Flash the autopilot with software compiled with --enable-dds

  2. Connect the autopilot via ethernet to the computer

  3. Open a MavProxy session

  4. Configure the parameters described above, starting with the ENABLE parameters first.

  5. Reboot the flight controller

  6. Start the MicroROS Agent with the same port as the parameter for DDS_UDP_PORT

    ros2 run micro_ros_agent micro_ros_agent udp4 -p 2019 -r dds_xrce_profile.xml
    
  7. Use the ROS 2 CLI to interact with the autopilot