mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +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:
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:
|
||||
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_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)]@
|
||||
@{
|
||||
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())
|
||||
# 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)]@
|
||||
#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]@
|
||||
{
|
||||
@ -160,6 +160,8 @@ Zenoh_Subscriber* genSubscriber(const char *name) {
|
||||
}
|
||||
|
||||
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;
|
||||
for (auto &sub : _topics) {
|
||||
pch = strstr(name, sub.orb_meta->o_name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user