Skip to content

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

@tmori

Description

@tmori

問題のコード

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions