mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 07:03:34 +08:00
Generate default Zenoh config from dds_topics.yaml
For easy transition from uxrce to zenoh and a sane base config to begin with
This commit is contained in:
committed by
Beat Küng
parent
bac009c2b8
commit
0763bbe2cf
@@ -74,6 +74,19 @@ if(CONFIG_ZENOH_SERIAL)
|
|||||||
target_compile_options(zenohpico_static PRIVATE -DZ_LINK_SERIAL)
|
target_compile_options(zenohpico_static PRIVATE -DZ_LINK_SERIAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/default_topics.c
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/generate_dds_topics.py
|
||||||
|
--client-outdir ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
--dds-topics-file ${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/dds_topics.yaml
|
||||||
|
--template_file ${CMAKE_CURRENT_SOURCE_DIR}/default_topics.c.em
|
||||||
|
DEPENDS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/generate_dds_topics.py
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../uxrce_dds_client/dds_topics.yaml
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/default_topics.c.em
|
||||||
|
COMMENT "Generating Default config"
|
||||||
|
)
|
||||||
|
add_custom_target(default_topics_config DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/default_topics.c)
|
||||||
|
|
||||||
|
|
||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE modules__zenoh
|
MODULE modules__zenoh
|
||||||
@@ -83,6 +96,7 @@ px4_add_module(
|
|||||||
zenoh_config.cpp
|
zenoh_config.cpp
|
||||||
publishers/zenoh_publisher.cpp
|
publishers/zenoh_publisher.cpp
|
||||||
subscribers/zenoh_subscriber.cpp
|
subscribers/zenoh_subscriber.cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/default_topics.c
|
||||||
MODULE_CONFIG
|
MODULE_CONFIG
|
||||||
module.yaml
|
module.yaml
|
||||||
DEPENDS
|
DEPENDS
|
||||||
@@ -92,6 +106,7 @@ px4_add_module(
|
|||||||
zenohpico_static
|
zenohpico_static
|
||||||
zenoh_topics
|
zenoh_topics
|
||||||
git_zenoh-pico
|
git_zenoh-pico
|
||||||
|
default_topics_config
|
||||||
INCLUDES
|
INCLUDES
|
||||||
${PX4_BINARY_DIR}/msg
|
${PX4_BINARY_DIR}/msg
|
||||||
zenoh-pico/include
|
zenoh-pico/include
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
@###############################################
|
||||||
|
@#
|
||||||
|
@# EmPy template
|
||||||
|
@#
|
||||||
|
@###############################################
|
||||||
|
@# Generates default config fore Zenoh
|
||||||
|
@#
|
||||||
|
@# Context:
|
||||||
|
@# - msgs (List) list of all RTPS messages
|
||||||
|
@# - topics (List) list of all topic names
|
||||||
|
@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
|
||||||
|
@###############################################
|
||||||
|
@{
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
}@
|
||||||
|
|
||||||
|
const char* default_pub_config =
|
||||||
|
@[ for pub in publications]@
|
||||||
|
"@(pub['topic']);@(pub['simple_base_type'])\n"
|
||||||
|
@[ end for]@
|
||||||
|
;
|
||||||
|
|
||||||
|
const char* default_sub_config =
|
||||||
|
@[ for sub in subscriptions]@
|
||||||
|
"@(sub['topic']);@(sub['simple_base_type'])\n"
|
||||||
|
@[ end for]@
|
||||||
|
@[ for sub in subscriptions_multi]@
|
||||||
|
"@(sub['topic']);@(sub['simple_base_type'])\n"
|
||||||
|
@[ end for]@
|
||||||
|
;
|
||||||
@@ -113,7 +113,7 @@ int ZENOH::generate_rmw_zenoh_topic_keyexpr(const char *topic, const uint8_t *ri
|
|||||||
if (type_name) {
|
if (type_name) {
|
||||||
strcpy(type, type_name);
|
strcpy(type, type_name);
|
||||||
toCamelCase(type); // Convert uORB type to camel case
|
toCamelCase(type); // Convert uORB type to camel case
|
||||||
return snprintf(keyexpr, KEYEXPR_SIZE, "%" PRId32 "/%s/"
|
return snprintf(keyexpr, KEYEXPR_SIZE, "%" PRId32 "%s/"
|
||||||
KEYEXPR_MSG_NAME "%s_/RIHS01_"
|
KEYEXPR_MSG_NAME "%s_/RIHS01_"
|
||||||
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||||
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||||
@@ -156,7 +156,7 @@ int ZENOH::generate_rmw_zenoh_topic_liveliness_keyexpr(const z_id_t *id, const c
|
|||||||
return snprintf(keyexpr, KEYEXPR_SIZE,
|
return snprintf(keyexpr, KEYEXPR_SIZE,
|
||||||
"@ros2_lv/%" PRId32 "/"
|
"@ros2_lv/%" PRId32 "/"
|
||||||
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x/"
|
"%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/"
|
"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_/RIHS01_"
|
KEYEXPR_MSG_NAME "%s_/RIHS01_"
|
||||||
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||||
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
"%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||||
@@ -330,7 +330,6 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds)
|
|||||||
|
|
||||||
for (i = 0; i < _pub_count; i++) {
|
for (i = 0; i < _pub_count; i++) {
|
||||||
if (_config.getPublisherMapping(topic, type)) {
|
if (_config.getPublisherMapping(topic, type)) {
|
||||||
printf("Index %i ret %i Topic %s Type %s", i, ret, topic, type);
|
|
||||||
_zenoh_publishers[i] = genPublisher(type);
|
_zenoh_publishers[i] = genPublisher(type);
|
||||||
const uint8_t *rihs_hash = getRIHS01_Hash(type);
|
const uint8_t *rihs_hash = getRIHS01_Hash(type);
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,10 @@
|
|||||||
|
|
||||||
|
|
||||||
const char *default_net_config = Z_CONFIG_MODE_DEFAULT ";" CONFIG_ZENOH_DEFAULT_LOCATOR;
|
const char *default_net_config = Z_CONFIG_MODE_DEFAULT ";" CONFIG_ZENOH_DEFAULT_LOCATOR;
|
||||||
const char *default_pub_config = "";
|
|
||||||
const char *default_sub_config = ""; //TODO maybe use YAML
|
// Default config generated from default_topics.c.em and dds_topics.yaml
|
||||||
|
extern const char *default_pub_config;
|
||||||
|
extern const char *default_sub_config;
|
||||||
|
|
||||||
|
|
||||||
Zenoh_Config::Zenoh_Config()
|
Zenoh_Config::Zenoh_Config()
|
||||||
@@ -285,7 +287,6 @@ int Zenoh_Config::getPubSubMapping(char *topic, char *type, const char *filename
|
|||||||
|
|
||||||
if (fp_mapping) {
|
if (fp_mapping) {
|
||||||
while (fgets(buffer, MAX_LINE_SIZE, fp_mapping) != NULL) {
|
while (fgets(buffer, MAX_LINE_SIZE, fp_mapping) != NULL) {
|
||||||
printf("getPubSubMapping %s", buffer);
|
|
||||||
|
|
||||||
if (buffer[0] != '\n') {
|
if (buffer[0] != '\n') {
|
||||||
const char *config_type = get_csv_field(buffer, 2);
|
const char *config_type = get_csv_field(buffer, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user