mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-29 19:57:12 +08:00
Zenoh: fix topic_name and datatype mapping
Using substring was buggy instad we make dictionary based on datatypes and the get_topics function
This commit is contained in:
committed by
Beat Küng
parent
e37f20e94d
commit
575923b534
@@ -155,7 +155,12 @@ def generate_topics_list_file_from_files(files, outputdir, template_filename, te
|
|||||||
for msg_filename in files:
|
for msg_filename in files:
|
||||||
topics.extend(get_topics(msg_filename))
|
topics.extend(get_topics(msg_filename))
|
||||||
|
|
||||||
tl_globals = {"msgs": filenames, "topics": topics, "datatypes": datatypes, "full_base_names": full_base_names, "rihs01_hashes": rihs01_hashes}
|
datatypes_with_topics = dict()
|
||||||
|
for msg_filename in files:
|
||||||
|
datatype = re.sub(r'(?<!^)(?=[A-Z])', '_', os.path.basename(msg_filename)).lower().replace(".msg","")
|
||||||
|
datatypes_with_topics[datatype] = get_topics(msg_filename)
|
||||||
|
|
||||||
|
tl_globals = {"msgs": filenames, "topics": topics, "datatypes": datatypes, "full_base_names": full_base_names, "rihs01_hashes": rihs01_hashes, "datatypes_with_topics": datatypes_with_topics}
|
||||||
tl_template_file = os.path.join(templatedir, template_filename)
|
tl_template_file = os.path.join(templatedir, template_filename)
|
||||||
tl_out_file = os.path.join(outputdir, template_filename.replace(".em", ""))
|
tl_out_file = os.path.join(outputdir, template_filename.replace(".em", ""))
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ full_base_names.sort()
|
|||||||
|
|
||||||
@[for idx, topic_name in enumerate(datatypes)]@
|
@[for idx, topic_name in enumerate(datatypes)]@
|
||||||
@{
|
@{
|
||||||
type_topic_count = len([e for e in topic_names_all if e.startswith(topic_name)])
|
type_topic_count = len(datatypes_with_topics[topic_name])
|
||||||
}@
|
}@
|
||||||
#ifdef CONFIG_ZENOH_PUBSUB_@(topic_name.upper())
|
#ifdef CONFIG_ZENOH_PUBSUB_@(topic_name.upper())
|
||||||
# define CONFIG_ZENOH_PUBSUB_@(topic_name.upper())_COUNT @(type_topic_count)
|
# define CONFIG_ZENOH_PUBSUB_@(topic_name.upper())_COUNT @(type_topic_count)
|
||||||
@@ -105,7 +105,7 @@ uorb_id_idx = 0
|
|||||||
@[for idx, topic_name in enumerate(datatypes)]@
|
@[for idx, topic_name in enumerate(datatypes)]@
|
||||||
#ifdef CONFIG_ZENOH_PUBSUB_@(topic_name.upper())
|
#ifdef CONFIG_ZENOH_PUBSUB_@(topic_name.upper())
|
||||||
@{
|
@{
|
||||||
topic_names = [e for e in topic_names_all if e.startswith(topic_name)]
|
topic_names = datatypes_with_topics[topic_name]
|
||||||
}@
|
}@
|
||||||
@[for topic_name_inst in topic_names]@
|
@[for topic_name_inst in topic_names]@
|
||||||
{
|
{
|
||||||
@@ -160,6 +160,8 @@ Zenoh_Subscriber* genSubscriber(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* genTypeName(const char *name, const uint8_t* hash) {
|
const char* genTypeName(const char *name, const uint8_t* hash) {
|
||||||
|
//FIXME this isn't fully clean because we've got topics that never matches datatype name
|
||||||
|
// i.e. ESTIMATOR_AID_SOURCE2D however storing all strings in flash isn't ideal either
|
||||||
const char *pch;
|
const char *pch;
|
||||||
for (auto &sub : _topics) {
|
for (auto &sub : _topics) {
|
||||||
pch = strstr(name, sub.orb_meta->o_name);
|
pch = strstr(name, sub.orb_meta->o_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user