ros2 / rmw_zenoh

RMW for ROS 2 using Zenoh as the middleware
Apache License 2.0
184 stars 34 forks source link

Include type hash in liveliness token and fill endpoint info #202

Closed Yadunund closed 3 months ago

Yadunund commented 3 months ago

Builds off #171 to include the type hash in the liveliness token and populate the same when filling out endpoint info. As a result the type hash is now available when introspecting topics. Previously the type hash would show INVALID.

Note: since the liveliness token is updated, please make sure to kill all ROS 2 nodes including the ros2 daemon prior to testing.

To test:

# terminal 1
ros2 run demo_nodes_cpp talker
# terminal 2
ros2 topic info -v /chatter

The type hash should be filled in the result

yadunund@ubuntu-noble-20240225:~/ros2_rolling$ ros2 topic info -v /chatter
Type: std_msgs/msg/String

Publisher count: 1

Node name: talker
Node namespace: /
Topic type: std_msgs/msg/String
Topic type hash: RIHS01_df668c740482bbd48fb39d76a70dfd4bd59db1288021743503259e948f6b1a18
Endpoint type: PUBLISHER
GID: 01.10.0e.70.a8.7f.35.22.74.35.d2.74.00.00.17.03
QoS profile:
  Reliability: RELIABLE
  History (Depth): KEEP_LAST (7)
  Durability: VOLATILE
  Lifespan: Infinite
  Deadline: Infinite
  Liveliness: AUTOMATIC
  Liveliness lease duration: Infinite

Subscription count: 0
Yadunund commented 3 months ago

Hm, I guess you are right. Converting a char to a std::string does indeed seem to do a copy of the string. That's good to know. Personally, I prefer this to be explicit, and so I would pass the char into the TopicInfo, and have TopicInfo be responsible for both copying and releasing the string. But I leave it to you.

I think we can keep things as they are right now. The constructor args make it apparent that a copy of a string should be passed. I could convert some of them to const chat * const but then we'd be making a copy in rmw_zenoh.cpp for args like topic_type which we obtain as an std::string (now I just std::move() this string to the TopicInfo constructor.)