ROS2 topic and service not response on CubeOrange

Question

I’m currently trying to use ROS2 to control a flight controller (CubeOrange), following the instructions below:

Currently encountering some problems:

  1. When using the mode_switch command in ROS2, the flight controller will not send back a response.
  2. Topic did not return any information
  3. Everything is normal when running using the SITL

Hardware Setting

ArduCopter 4.7.0(CubeOragne) Build firmware and parameter setting

  1. ./waf configure --board CubeOrange --enable-dds
  2. ./waf copter
  3. Use Mission Planner to program fireware on CubeOrange
  4. Set Ardupilot Parameter
    • SERIAL_BAUD=115
    • SERIAL_PROTOCOL=45

Test & Problem Reappear

The following will test the response of Ardupilot 4.7.0 in SITL and flight control firmware, and compare the differences.

Ardupilot topic/service test (use SITL with DDS Firmwre)

  1. Run micro_ros_agent(with UDP)

    • ros2 run micro_ros_agent micro_ros_agent udp4 -p 2019
  2. Run SITL with DDS Firmware

  3. Check micro_ros_agent is Created

  4. Monitor Topic: /ap/clock

    • ros2 topic echo /ap/clock
      ros2 topic echo clock
  5. Call Service mode_switch and check response

    • ros2 service call /ap/mode_switch ardupilot_msgs/srv/ModeSwitch "{mode: 5}"

ros2 service call modeSwitch
audupilot after ros2 service call modeSwitch
In SITL, ros2 command will response and mode is changed.

Ardupilot topic/service test (Use CubeOrange with DDS Firmwre)

  1. Run micro_ros_agent(with RPI5 Serial)

    • ros2 run micro_ros_agent micro_ros_agent serial -b 115200 -D /dev/ttyAMA0
  2. CubeOrange Power On

  3. Check micro_ros_agent is Created

  4. Monitor Topic: /ap/clock

    • ros2 topic echo /ap/clock

ros2 topic echo clock
Topic did not echo anything.

  1. Call Service mode_switch and check response
    • ros2 service call /ap/mode_switch ardupilot_msgs/srv/ModeSwitch "{mode: 5}"

ros2 service call modeSwitch


Though ros2 did not response anything, the mode is changed.

Check the baud rate. 45 is invalid.

@Yuri_Rage thank you for reply!
I accidentally typed it wrong in this post. :sweat_smile: And it has been corrected now.
The parameters are based on the AP_DDS document
After confirmation, these parameters have been set correctly.
image

Hi @s93011,

There’s a helpful guide here on setting up ROS 2 with a companion computer:

and further discussion here: Is it possible to test XRCE DDS on real HW? - #45 by bobzwik

It seems that the using DDS with serial requires a UART with hardware flow control for reliable results.

1 Like

@rhys thank you for reply!
I am still trying DDS over UART.
I attempted to add an RTS/CTS connection between the PI5 and CubeOrange, and it seems to have some effect, but I am still encountering some issues:

  1. When using baudrate=115200, while simultaneously monitoring /ap/clock, it seems to freeze after about 10 seconds.
    add_RTSCTS_freezed
  2. With baudrates of 57600 or 38400, the same issue occurs, but it lasts for a longer time.
  3. When I call the service, there is still no response.

Wired

Currently, my wiring setup is as follows:
OrangeCube <—> PI5:
RX <—> GPIO14(TXD0)
TX <—> GPIO15(RXD0)
RTS <—> GPIO16(CTS0)
CTS <—> GPIO17(RTS0)
The actual wiring method is as follows:

It seems to be related to the baud rate?

More Questions

  1. Will the transmission speed of DDS over PPP be better than DDS over UART?
  2. It seems that the wiring for DDS over PPP and DDS over UART is the same (TX, RX, GROUND, RTS, CTS)?

This is my first time trying to use DDS communication, and I have many questions. I would greatly appreciate it if you could kindly provide your guidance. :sweat_smile:

  • In both approaches the DDS link uses a UART, but the protocol is different.
  • It’s possible to set up a 12.5 Mbps PPP link with flow control.

It is also worth checking that the serial link works well for another protocol such as MAVLink 2. The guides linked above have more details.

It seems that using DDS via UDP is more reliable than DDS via Serial (the terminology is a little confusing, as in both cases we are using a serial port (UART) to provide the hard link, but DDS may use different protocols, and they have different backends in the XRCE DDS agent).

1 Like

@rhys Thank you! I think I succeeded!
Due to the delay and disconnection issues with DDS over UART(Serial), which I could not resolve, I switched to using DDS over Ethernet. The results were satisfying, and I’m sharing the successful method!

How to transmit DDS via Ethernet in Ardupilot

Source:

  1. testing-ppp-and-dds-on-a-desktop-or-laptop
  2. ROS 2 over Ethernet
  3. ArduPilot Network Interface
  4. Ethernet Connected Vehicle Example

Pre-Setup and Environment

  1. You need to set up the MicroROS execution environment on the computer.

  2. The Ardupilot firmware with DDS must be compiled (./waf configure --board xxx --enable-dds)

    • During compilation, errors may occur, likely due to exceeding the flight controller’s RAM settings. In this case, I disabled some modules (added --disable-RANGEFINDER).
  3. A flight controller with Ethernet capabilities. I used the CUAV Pixhawk V6X.

Ardupilot DDS (ROS2) Configuration and Introduction:

  • DDS_ENABLE=1: Enable DDS functionality

  • DDS_IPx: Set the target IP, which is the computer’s IP. It must be the same as DDS_IP. For example, if the PC’s IP is 192.168.1.7,

  • DDS_UDP_PORT=2019: The port through which DDS publishes over UDP on the network.

    • This needs to match the command for starting the micro_ros_agent on the computer, for example: ros2 run micro_ros_agent micro_ros_agent udp4 --port 2019.
  • NET_DHCP=0: Disable DHCP

  • NET_ENABLE=1: Enable network functionality

  • NET_IPADDRx: This is the flight controller’s own IP. It doesn’t need to be set specifically (just ensure it doesn’t conflict). Here is my current setting:

    • NET_IPADDR0=192
    • NET_IPADDR1=168
    • NET_IPADDR2=1
    • NET_IPADDR3=6
    • Net相關參數設定

Operation Process

  1. Flash the DDS-enabled Ardupilot firmware onto the flight controller.
  2. Write the Ardupilot DDS (ROS2) parameters into the flight controller. You can first write the xxx_ENABLE parameters and then write other related parameters later.
  3. Set the computer’s IP to DDS_IPx <<< Very Important!
  4. Connect the flight controller’s Ethernet port to the computer’s Ethernet port (or use an Ethernet-enabled Telemetry Module).
  5. On the computer, run ros2 run micro_ros_agent micro_ros_agent udp4 --port 2019.
  6. Power on (or restart) the flight controller.

DDS Function Verification

Topics

/ap/clock

clock訊息速率

/ap/imu/experimental/data

imu訊息速率

Services

/ap/mode_switch

DDS service功能確認

1 Like