Need help connecting companion computer using Ethernet on RPi

Hi guys, I am trying to connect my autopilot with my companion computer using the ethernet cable.

Details of the hardware:
Autopilot: Pixhawk 6x with firmware version 1.15.1
Companion computer: Raspberry Pi 4B running Ubuntu 24.04
Connected using an Ethernet cable

I have followed the steps from https://docs.px4.io/main/en/advanced_config/ethernet_setup.html#ros-2-setup-example and https://px4.io/get-the-pixhawk-raspberry-pi-cm4-baseboard-by-holybro-talking-with-px4/.
However, XRCE-Agent is unable to communicate with the client.

uavpi2@raspberrypi:~$ MicroXRCEAgent udp4 -p 8888
[1727457933.486357] info     | UDPv4AgentLinux.cpp | init                     | running...             | port: 8888
[1727457933.487239] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4

On the client side, I get:

uxrce_dds_client status
INFO  [uxrce_dds_client] Running, disconnected
INFO  [uxrce_dds_client] Using transport:     udp
INFO  [uxrce_dds_client] Agent IP:            10.41.10.1
INFO  [uxrce_dds_client] Agent port:          8888
INFO  [uxrce_dds_client] Custom participant:  no
INFO  [uxrce_dds_client] Localhost only:      no
INFO  [uxrce_dds_client] timesync converged: false
uxrce_dds_client: cycle: 0 events, 0us elapsed, 0.00us avg, min 0us max 0us 0.000us rms
uxrce_dds_client: cycle interval: 0 events, 0.00us avg, min 0us max 0us 0.000us rms

Also, I am able to ping from both the devices.

nsh> ping 10.41.10.1
PING 10.41.10.1 56 bytes of data
56 bytes from 10.41.10.1: icmp_seq=0 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=1 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=2 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=3 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=4 time=1.0 ms
56 bytes from 10.41.10.1: icmp_seq=5 time=1.0 ms
56 bytes from 10.41.10.1: icmp_seq=6 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=7 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=8 time=0.0 ms
56 bytes from 10.41.10.1: icmp_seq=9 time=0.0 ms
10 packets transmitted, 10 received, 0% packet loss, time 10010 ms
rtt min/avg/max/mdev = 0.000/0.200/1.000/0.400 ms
uavpi2@raspberrypi:~$ ping 10.41.10.2
PING 10.41.10.2 (10.41.10.2) 56(84) bytes of data.
64 bytes from 10.41.10.2: icmp_seq=1 ttl=64 time=0.577 ms
64 bytes from 10.41.10.2: icmp_seq=2 ttl=64 time=0.157 ms
64 bytes from 10.41.10.2: icmp_seq=3 ttl=64 time=1.34 ms
^C
--- 10.41.10.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2083ms
rtt min/avg/max/mdev = 0.157/0.692/1.344/0.491 ms

My IP settings on the client (autopilot)

nsh> netman show
DEVICE=eth0
BOOTPROTO=fallback
NETMASK=255.255.255.0
IPADDR=10.41.10.2
ROUTER=10.41.10.254
DNS=10.41.10.254

My IP settings on the agent (companion computer)

uavpi2@raspberrypi:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.41.10.1  netmask 255.255.255.0  broadcast 10.41.10.255
        inet6 fe80::a263:3d00:389b:3425  prefixlen 64  scopeid 0x20<link>
        ether e4:5f:01:ca:97:5c  txqueuelen 1000  (Ethernet)
        RX packets 5043  bytes 332097 (332.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 301  bytes 17282 (17.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Also my MAV2 settings are

Can someone please help me establish the XRCE communication?

1 Like

Hey,

Thanks for bringing this up! I need to update the docs for that.

Meanwhile, could you try to see if Jetson docs work?

There should be a trick here probably. RPi does not have internal switch so I need to reproduce this and see how you should set the network up.

Plz let me know how it goes!

Hi! Thanks for replying.
I have gone through the docs, and I believe I have implemented it as it is described, except for the place where I did not disable MAVLink on the PX4 Ethernet port.
I have corrected this. However, the issue still persists.

uavpi2@raspberrypi:~$ MicroXRCEAgent udp4 -p 8888
[1727459881.812800] info     | UDPv4AgentLinux.cpp | init                     | running...             | port: 8888
[1727459881.815358] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4

The updated parameters are:

could you share the output of dmesg on nuttx shell and output of ip route on your pi?

The next step you can try:

  • Disable UAVCAN_ENABLE by setting it to 0 and reboot Pixhawk see if the agent loads correctly.

Here is the output from Nuttx shell

nsh> dmesg
HW arch: PX4_FMU_V6X
HW type: V6X
HW FMUM ID: 0x008
HW BASE ID: 0x000
PX4 git-hash: 93eef0c78719a9ac972d46593262c76c978ed3c4
PX4 version: 1.15.1 0 (17760512)
OS: NuttX
OS version: Release 11.0.0 (184549631)
OS git-hash: 5d74bc138955e6f010a38e0f87f34e9a9019aecc
Build datetime: Oct 27 2024 15:57:00
Build uri: localhost
Build variant: default
Toolchain: GNU GCC, 13.2.1 20231009
PX4GUID: 000600000000303736303532510c00480020
MCU: STM32H7[4|5]xxx, rev. V
INFO  [param] selected parameter default file /fs/mtd_params
INFO  [param] importing from '/fs/mtd_params'
INFO  [parameters] BSON document size 3220 bytes, decoded 3220 bytes (INT32:66, FLOAT:89)
INFO  [param] selected parameter backup file /fs/microsd/parameters_backup.bson
Board architecture defaults: /etc/init.d/rc.board_arch_defaults
Board defaults: /etc/init.d/rc.board_defaults
Loading airframe: /etc/init.d/airframes/4001_quad_x
INFO  [dataman] data manager file '/fs/microsd/dataman' size is 68528 bytes
INFO  [px4io] IO FW CRC match
Board sensors: /etc/init.d/rc.board_sensors
icm45686 #0 on SPI bus 3
icm45686 #1 on SPI bus 2
icm45686 #2 on SPI bus 1 rotation 10
bmm150 #0 on I2C bus 4 (external) address 0x10
WARN  [SPI_I2C] ist8310: no instance started (no device on bus?)
icp201xx #0 on I2C bus 4 (external) address 0x64
bmp388 #0 on I2C bus 2 (external) address 0x76
WARN  [SPI_I2C] ms5611: no instance started (no device on bus?)
WARN  [vehicle_angular_velocity] no gyro selected, using sensor_gyro_fifo:0 3407898
ekf2 [558:237]
Board mavlink: /etc/init.d/rc.board_mavlink
Starting Main GPS on /dev/ttyS7
Starting MAVLink on /dev/ttyS6
INFO  [mavlink] mode: Normal, data rate: 1200 B/s on /dev/ttyS6 @ 57600B
Starting UXRCE-DDS Client on ethernet
INFO  [uxrce_dds_client] init UDP agent IP:10.41.10.1, port:8888
INFO  [cdcacm_autostart] Starting CDC/ACM autostart
INFO  [logger] logger started (mode=all)
INFO  [uavcan] Node ID 1, bitrate 1000000

NuttShell (NSH) NuttX-11.0.0
nsh> sercon: Registering CDC/ACM serial driver
sercon: Successfully registered the CDC/ACM serial driver
WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station    
INFO  [cdcacm_autostart] Starting mavlink on /dev/ttyACM0 (SYS_USB_AUTO=2)
INFO  [mavlink] mode: Onboard, data rate: 100000 B/s on /dev/ttyACM0 @ 2000000B
INFO  [mavlink] Starting mavlink shell

and here is the output from rpi

uavpi2@raspberrypi:~$ ip route
default via 10.41.10.254 dev eth0 proto static metric 100 
default via 192.168.41.176 dev wlan0 proto dhcp src 192.168.41.2 metric 600 
10.41.10.0/24 dev eth0 proto kernel scope link src 10.41.10.1 metric 100 
192.168.41.0/24 dev wlan0 proto kernel scope link src 192.168.41.2 metric 600

I have tried disabling UAVCAN and rebooting Pixhawk, but nothing has changed on the agent side.

could you enable your mavlink instance for ethernet?

I’ve tried that.

nsh> mavlink status

instance #0:
    mavlink chan: #0
    type:        GENERIC LINK OR RADIO
    flow control: ON
    rates:
      tx: 781.2 B/s
      txerr: 0.0 B/s
      tx rate mult: 0.329
      tx rate max: 1200 B/s
      rx: 0.0 B/s
      rx loss: 0.0%
    FTP enabled: YES, TX enabled: YES
    mode: Normal
    Forwarding: On
    MAVLink version: 1
    transport protocol: serial (/dev/ttyS6 @57600)

instance #1:
    mavlink chan: #1
    type:        GENERIC LINK OR RADIO
    flow control: OFF
    rates:
      tx: 0.0 B/s
      txerr: 483.5 B/s
      tx rate mult: 0.050
      tx rate max: 100000 B/s
      rx: 0.0 B/s
      rx loss: 0.0%
    FTP enabled: YES, TX enabled: YES
    mode: Onboard
    Forwarding: Off
    MAVLink version: 1
    transport protocol: UDP (14540, remote port: 14540)
    Broadcast enabled: YES

instance #2:
    GCS heartbeat valid
    mavlink chan: #2
    type:        USB CDC
    flow control: ON
    rates:
      tx: 21228.4 B/s
      txerr: 0.0 B/s
      tx rate mult: 1.000
      tx rate max: 100000 B/s
      rx: 621.2 B/s
      rx loss: 0.0%
    Received Messages:
      sysid:255, compid:190, Total: 17532 (lost: 0)
        msgid:  126, Rate:  0.1 Hz, last 0.04s ago
        msgid:    4, Rate:  1.0 Hz, last 0.66s ago
        msgid:    0, Rate:  1.0 Hz, last 0.39s ago
        msgid:   69, Rate: 25.0 Hz, last 0.06s ago
    FTP enabled: YES, TX enabled: YES
    mode: Onboard
    Forwarding: On
    MAVLink version: 2
    transport protocol: serial (/dev/ttyACM0 @2000000)
    ping statistics:
      last: 1.12 ms
      mean: 1.01 ms
      max: 21.32 ms
      min: 0.16 ms
      dropped packets: 0

I have also tried testing with the all_params file mavsdk. Even that was not working.

uavpi2@raspberrypi:~/tests$ python3 all_params.py 


sudo ip route del default via 10.41.10.254 dev eth0

This first route does not seem right. Please also try the command above and lmk. Just be sure you don have it appearing again. This will do a momentary removal of that route.

So you may want to check again your ip route after.

Hey, I’ve tried that. But didn’t work out.

I found the issue, though. It seems my firewall was blocking the udp traffic. I created a rule to allow the traffic, and it worked.

Also, there seems to be an error in the PX4 documentation.

network:
  version: 2
  renderer: NetworkManager
  ethernets:
      enp2s0:
          addresses:
              - 10.41.10.1/24
          nameservers:
              addresses: [10.41.10.1]
          routes:
              - to: 10.41.10.1
                via: 10.41.10.1

The route destination should be 0.0.0.0/0 instead of 10.41.10.1. Please confirm.

Thanks again for your inputs.

Thank you,

But you mentioned you followed Jetson Docs as well, right?

I think it is same as what you mentioned which is same as removing the route tempoarily from the command I mentioned earlier.

I will update the docs.

1 Like

Yeah, the documentation in jetson docs is fine. I was able to ping from both devices following that. In my case firewall was the issue.

1 Like