jhelovuo/ros2-client

Recent updates break the communication with ros2

Closed this issue · 6 comments

Hi,

I found the talker and listener examples failed to integrate with ros2 humble after the very recent updates (I suggest the 10th of Nov ones as these examples worked fine in my previous test on the 9th of Nov), while I cannot locate whether this issue is caused by RustDDS or ros2-client.
My test environment is set as follows:

To reproduce this issue:

  • Clone this repo and run cargo run --example=talker
  • Open another terminal and run ros2 topic list. There is no /chatter in the list.
  • Run ros2 node list, and the output is empty.

Best,
Levi

There was a regression in RustDDS development recently. Reworking Discovery to better conform to the RTPS spec in c68488 broke Discovery and most ROS2 examples no longer work.

This is supposedly fixed in c8a65e. You can try building against this version of RustDDS. Please report if it works better for you. If you use bleeding-edge versions from GitHub, there may be some breakage from time to time.

Alternatively, the latest released versions in crates.io should also work.

This is supposedly fixed in c8a65e.

Unfortunately, It doesn't seem to fix the issue from my side. The cargo build command outputs Compiling rustdds v0.8.6 (https://github.com/jhelovuo/RustDDS.git#c8a65eb2), so it is using the exact version of rustDDS as you mentioned here. However, the communication to ros2 can not be established:

I first ran cargo run --example talker, then I opened another terminal, sourced ROS2, and kept running ros2 topic echo /chatter, and in the first couple of trails, it complained

WARNING: topic [/chatter] does not appear to be published yet
Could not determine the type for the passed topic

After that, ros2 topic echo /chatter threw an error

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

If you use bleeding-edge versions from GitHub, there may be some breakage from time to time.

Yes, I understand. Thanks for open-sourcing these wonderful repos.

Alternatively, the latest released versions in crates.io should also work.

I would say mostly yes. Interestingly, it seems to lose the first few(In most test cases the first 10) messages sent by the talker example

ros2 topic echo /chatter
A message was lost!!!
        total count change:1
        total count: 1---
A message was lost!!!
        total count change:1
        total count: 2---
A message was lost!!!
        total count change:1
        total count: 3---
A message was lost!!!
        total count change:1
        total count: 4---
A message was lost!!!
        total count change:1
        total count: 5---
A message was lost!!!
        total count change:1
        total count: 6---
A message was lost!!!
        total count change:1
        total count: 7---
A message was lost!!!
        total count change:1
        total count: 8---
A message was lost!!!
        total count change:1
        total count: 9---
A message was lost!!!
        total count change:1
        total count: 10---
data: count=81 All work and no play makes ROS a dull boy. All play and no work makes RTPS a mere toy. All work and no play makes ROS a...
---

The dependencies in my Cargo.toml file look like this

[dependencies]
futures = "0.3.29"
log4rs = "1.2.0"
ros2-client = "0.5.5"
rustdds = "0.8.6"
smol = "1.3.0"
mio = "^0.6.23"
mio-extras = "2.0.6"
log = "0.4.20"

After some investigation, some preliminary findings:

  • The ros2-client talker/listener examples seem to use Topic chatter, whereas ROS 2 originals use Topic topic. This mixup obviously causes just no communication without any error messages.
  • I was able to reproduce the "bad alloc" + crash event using ROS 2 Humble and latest master of ros2-client. It appears that we manage to send so malformed message over ros_discovery_info that it causes a remote denial-of-service in Humble. You can test this by commenting out the contents of broadcast_node_infos in ContextInner. The exact error is still not clear, but this is on our list of things to fix.

It seems that we prematurely upgraded to Iron Irwini, so Humble and pre-Humble compatibility was broken. Apparently, ros_discovery_info format has changed between Humble and Iron, and they are therefore quite incompatible on the wire.

I reverted back to Humble, so the latest master works now for me against Humble.

Hi, it works! I read your commits and noticed the elegant way to handle fix-sized arrays by std::array::from_fn.

But I still got A message was lost!!! outputs when I tried to receive published messages with ros2 topic echo /topic_name. Have you encountered the same issue?

It seems that Discovery is working slowly. It can take up to 10 seconds to establish a connection, and some messages may be lost during that time. That is on our list of things to resolve.