MicroXRCEAgent created px4 topics not shown in ros2 topic list

Hi, Me and my team are working on offboard control for a drone. Right now we are trying to connect our companion computer to Pixhawk6c via USB/UART RxTx - ttl - telem2. No matter did we use UART or USB, we always could get the MicroXRCE client to create topics yet they are not shown on ros2 topic list.

the serial port for UART we used is /dev/ttyS1 and that for usb-ttl is /dev/ttyUSB0




Have you fixed it? How did you install MicroXRCEAgent? I compiled from source with the following Dockerfile and also no ROS2 topics regardless of datawriters being created and uxrce_dds_client status being running and connected in mavlink console of PX4.

ARG FROM_IMAGE=ros:jazzy-ros-base
FROM $FROM_IMAGE

# Install FastDDS dependencies
RUN apt-get update && apt-get install -y \
    libfastrtps-dev \
    libfastcdr-dev \
    && rm -rf /var/lib/apt/lists/*

# Clone Micro-XRCE-DDS-Agent v2.4.3
RUN git clone --branch v2.4.3 https://github.com/eProsima/Micro-XRCE-DDS-Agent.git /tmp/Micro-XRCE-DDS-Agent

# Build with FastDDS support
WORKDIR /tmp/Micro-XRCE-DDS-Agent/build
RUN cmake .. -DUAGENT_USE_FASTDDS=ON \
    && make -j$(nproc) \
    && make install \
    && ldconfig

# Clean up build files to reduce image size
RUN rm -rf /tmp/Micro-XRCE-DDS-Agent

CMD ["bash"]

Okay so I searched for the answer for a solid day and came to the conclusion:

Wrong domain ID was set on PX4, I was developing the system previously with domain ID 1 and after changes I decided on domain ID 0 on ROS2 side but forgot to update it on the autopilot. That’s why the datawriters and other good things were created in the agent logs and communication was going (checked with -v 6 passed on agent CLI). The communication now works as expected.

Ended up using Docker image from microros aswell to simplify setup and cut down build times (the Dockerfile posted above took 17 mintues to build on Raspberry Pi 5). Here is my compose service for DDS Agent that connects to the PX4 v1.16 over serial:

dds-bridge:
    image: microros/micro-ros-agent:jazzy
    restart: unless-stopped
    ipc: host
    pid: host
    volumes:
      - /dev/shm:/dev/shm
    network_mode: host
    environment:
      - ROS_DOMAIN_ID=0
      - XRCE_DOMAIN_ID_OVERRIDE=0
      - RMW_IMPLEMENTATION=rmw_fastrtps_cpp
    devices:
      - /dev/ttyAMA0:/dev/ttyAMA0
    command: serial --dev /dev/ttyAMA0 -b 921600

In the meantime I was using eProsima FastDDS Monitor to check whether the agent was even trying to appear on DDS space and worked out the following command for running it directly from Docker container under WSL2:

docker run -it --rm \
  -e DISPLAY=$DISPLAY \
  -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
  -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
  -e PULSE_SERVER=$PULSE_SERVER \
  -e LD_LIBRARY_PATH="/usr/lib/wsl/lib" \
  -e LOCAL_USER_ID="1000" \
  -e REMOTE_USER=$USER \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v /mnt/wslg:/mnt/wslg \
  -v /usr/lib/wsl:/usr/lib/wsl \
  --device=/dev/dxg \
  --net=host \
  ubuntu-fastdds-monitor:v3.2.0

The image however must be downloaded separately from eProsima download section and loaded into Docker as for time of writing.

Recommend it as it isolates possible ROS2 misconfigurations and shows directly FastDDS participants.