zenoh: Add support for ROS2 Humble and earlier (#26619)

* Add support for hash-less Zenoh topic key expressions

- Add kConfig option ZENOH_KEY_TYPE_HASH to toggle the inclusion
- Update topic and liveliness generators

* chore: Update Zenoh kConfig param description and help message

* docs(zenoh): Document Zenoh configuration for Humble

* docs: Clarify PX4 ROS2 Interface library compatibility
This commit is contained in:
Leonardo Cencetti
2026-03-04 20:00:58 +01:00
committed by GitHub
parent c5d22f5fea
commit de9698e7fa
4 changed files with 54 additions and 1 deletions
+7
View File
@@ -35,6 +35,13 @@ if MODULES_ZENOH
Uses the Zenoh matching feature to check whether a publisher has subscribers.
If so, only then publish the data. This is still experimental
config ZENOH_KEY_TYPE_HASH
bool "Include the type hash in Zenoh key expression"
default y
---help---
Uses the message type hash (RIHS01, as defined in REP-2016) in the Zenoh key
expression (supported by ROS2 Jazzy and later).
Set to false to use in ROS2 Humble and earlier.
# Choose exactly one item
choice ZENOH_PUBSUB_SELECTION
+27
View File
@@ -115,6 +115,8 @@ int ZENOH::generate_rmw_zenoh_topic_keyexpr(const char *topic, const uint8_t *ri
if (type_name) {
strncpy(type, type_name, TOPIC_INFO_SIZE);
toCamelCase(type); // Convert uORB type to camel case
#ifdef CONFIG_ZENOH_KEY_TYPE_HASH
return snprintf(keyexpr, KEYEXPR_SIZE, "%" PRId32 "%s/"
KEYEXPR_MSG_NAME "%s_/RIHS01_"
"%02x%02x%02x%02x%02x%02x%02x%02x"
@@ -131,6 +133,11 @@ int ZENOH::generate_rmw_zenoh_topic_keyexpr(const char *topic, const uint8_t *ri
rihs_hash[24], rihs_hash[25], rihs_hash[26], rihs_hash[27],
rihs_hash[28], rihs_hash[29], rihs_hash[30], rihs_hash[31]
);
#else
return snprintf(keyexpr, KEYEXPR_SIZE, "%" PRId32 "%s/"
KEYEXPR_MSG_NAME "%s_/TypeHashNotSupported",
_zenoh_domain_id.get(), topic, type);
#endif
}
return -1;
@@ -155,6 +162,7 @@ int ZENOH::generate_rmw_zenoh_topic_liveliness_keyexpr(const z_id_t *id, const c
str++;
}
#ifdef CONFIG_ZENOH_KEY_TYPE_HASH
return snprintf(keyexpr, KEYEXPR_SIZE,
"@ros2_lv/%" PRId32 "/"
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x/"
@@ -184,6 +192,25 @@ int ZENOH::generate_rmw_zenoh_topic_liveliness_keyexpr(const z_id_t *id, const c
rihs_hash[24], rihs_hash[25], rihs_hash[26], rihs_hash[27],
rihs_hash[28], rihs_hash[29], rihs_hash[30], rihs_hash[31]
);
#else
return snprintf(keyexpr, KEYEXPR_SIZE,
"@ros2_lv/%" PRId32 "/"
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x/"
"0/11/%s/%%/%%/px4_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x/%s/"
KEYEXPR_MSG_NAME "%s_/TypeHashNotSupported"
"/::,7:,:,:,,",
_zenoh_domain_id.get(),
id->id[0], id->id[1], id->id[2], id->id[3], id->id[4], id->id[5], id->id[6],
id->id[7], id->id[8], id->id[9], id->id[10], id->id[11], id->id[12], id->id[13],
id->id[14], id->id[15],
entity_str,
_px4_guid[0], _px4_guid[1], _px4_guid[2], _px4_guid[3],
_px4_guid[4], _px4_guid[5], _px4_guid[6], _px4_guid[7],
_px4_guid[8], _px4_guid[9], _px4_guid[10], _px4_guid[11],
_px4_guid[12], _px4_guid[13], _px4_guid[14], _px4_guid[15],
topic_lv, type_camel_case
);
#endif
}
int ZENOH::setupSession()