Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Error When Multiple Topics Share the Same Data Type #56

Open
tmori opened this issue Apr 8, 2024 · 0 comments
Open

Compilation Error When Multiple Topics Share the Same Data Type #56

tmori opened this issue Apr 8, 2024 · 0 comments

Comments

@tmori
Copy link

tmori commented Apr 8, 2024

問題のコード

datatext = template.render({ "includeFiles":includeFiles, "pubMsgTypes":pubMsgTypes, "subMsgTypes":subMsgTypes })

該当の変数は、pubMsgTypesとsubMsgTypesで、生成コードが同じ型のものが複数出て来ると思います。

修正方法

重複するものを削ればOK

--- a/mros2_header_generator/templates_generator.py
+++ b/mros2_header_generator/templates_generator.py
@@ -55,9 +55,11 @@ def main():
                 includeFile = '#include "' + includeFile + '.hpp"'
                 includeFiles.append(includeFile)
                 
+    unique_pubMsgTypes = list(set(pubMsgTypes))
+    unique_subMsgTypes = list(set(subMsgTypes))
     env = Environment(loader=FileSystemLoader(path.dirname(__file__)))
     template = env.get_template('templates.tpl')
-    datatext = template.render({ "includeFiles":includeFiles, "pubMsgTypes":pubMsgTypes, "subMsgTypes":subMsgTypes  })
+    datatext = template.render({ "includeFiles":includeFiles, "pubMsgTypes":unique_pubMsgTypes, "subMsgTypes":unique_subMsgTypes  })
 
     outfile_path = os.path.join(outdir, "templates.hpp")
     outtemp_path = os.path.join(outdir, "templates.hpp.tmp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant