Populate type hashes in zenoh graph cache (#356) - #1004
Open
tisomi wants to merge 1 commit into
Open
Conversation
Populates the new type_hashes field on rmw_names_and_types_t from the
zenoh graph cache. Adds two private helpers:
- _type_hashes_equal compares two rosidl_type_hash_t values
(version + byte-by-byte via std::memcmp).
- _resolve_type_hash_for_type walks the per-type QoS map; if all
successfully-parsed hashes agree it returns that hash, otherwise it
logs a WARN and returns a zero-initialized hash so the caller sees
an unambiguous "no consensus" value. Matches the rmw_dds_common
conflict-detection behavior.
fill_names_and_types now allocates the per-name type_hashes array (or
sets it to nullptr when there are no types) and fills each entry via
_resolve_type_hash_for_type so callers of the rmw graph query APIs see
type hashes alongside names and types.
Adds gtests covering pub/sub topic hashes, per-node publisher and
subscriber hashes, topic endpoint info hashes, plus the equivalent set
for services (server/client + service endpoint info).
Related: ros2/rmw#356
Signed-off-by: tisomi <titus090404@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as
|
This was referenced Jul 2, 2026
wjwwood
requested changes
Jul 25, 2026
wjwwood
left a comment
Member
There was a problem hiding this comment.
I requested changes to the rmw interface pr (intrinsic-ai/sdk-ros#138)
|
Thanks for the feedback @wjwwood ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR populates the new
type_hashesfield onrmw_names_and_types_tfrom the zenohgraph cache, so rmw_zenoh reports the type hash of each name/type pair through the graph
query APIs. It is the rmw_zenoh counterpart to the interface change in ros2/rmw#356, and
mirrors the conflict-detection behavior of the rmw_dds_common companion PR.
Key changes:
graph_cache.cpp:_type_hashes_equalcompares tworosidl_type_hash_tvalues (versionplus abyte-by-byte
std::memcmpof the value)._resolve_type_hash_for_typewalks the per-type QoS map and reconciles the hashes.The zenoh cache stores each endpoint's hash as a serialized string
(
TopicData::info_.type_hash_) and keeps oneTopicDataper QoS/endpoint, so the hashis resolved at read time: each string is parsed with
rosidl_parse_type_hash_string,unparseable entries are skipped, and if all successfully-parsed hashes agree that hash
is returned. If they disagree, a WARN is logged and a zero-initialized hash is returned
so the caller sees an unambiguous "no consensus" value. See Additional Information
for why diverging hashes can occur.
fill_names_and_typesallocates the per-nametype_hashesarray (ornullptrwhen aname has no types) and fills each entry via
_resolve_type_hash_for_type, alongside thecorresponding type name. Its existing
rcpputils::make_scope_exitcleanup (cancelled onsuccess) already finalizes the partially-built struct via
rmw_names_and_types_finionany early return.
Adds gtests covering pub/sub topic hashes, per-node publisher and subscriber hashes, and
topic endpoint info hashes, plus the equivalent set for services (server/client and service
endpoint info).
Related: ros2/rmw#356
Is this user-facing behavior change?
Yes.
rmw_get_topic_names_and_types,rmw_get_service_names_and_types,and the per-node variants) now report the type hash of each name/type pair via the new
type_hashesarray.a zero hash and a WARN is logged.
requires the ABI-breaking struct change from Extend
names_and_typesto contain type hashes rmw#356.Did you use Generative AI?
Yes. Claude (claude-sonnet-4-6) via GitHub Copilot was used to explore the codebase and
create an initial prototype.
Additional Information
type_hashesfield and hardensrmw_names_and_types_init/rmw_names_and_types_fini. The scope-exit cleanup here relieson
finicleaning up partially-populated structs without leaking.conflict handling (zero hash + WARN) is intentionally identical across the two.
On the hash-conflict case. A single topic name can appear with more than one type in
the ROS graph, which is why
rmw_names_and_types_tstores an array of types per name.Beyond that, two entries can share the same type name while the type definitions behind
them differ structurally — different versions of the same interface — and therefore produce
different hashes. This "version drift" arises when nodes on the graph are built against
different versions of the same type definition. When it happens, the graph query reports a
zero hash for that type and logs a WARN. In a version-consistent system this should not
occur, but the graph layer has to surface it rather than hand the caller one endpoint's
hash as if it were authoritative.
Testing
in a Docker container; all pass.
path through the graph query APIs.
This is a SIEMENS activity and was initialized by @gramss