mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 00:31:35 +08:00
microRTPS: use FastRTPS version instead of FastRTPSGen version to generate conditional code
This commit is contained in:
@@ -167,7 +167,7 @@ def generate_output_from_file(format_idx, filename, outputdir, package, template
|
||||
return generate_by_template(output_file, template_file, em_globals)
|
||||
|
||||
|
||||
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtpsgen_version, ros2_distro, ids):
|
||||
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtps_version, ros2_distro, ids):
|
||||
"""
|
||||
Generates an .idl from .msg file
|
||||
"""
|
||||
@@ -175,11 +175,11 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
|
||||
|
||||
if (alias != ""):
|
||||
em_globals = get_em_globals(
|
||||
msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
@@ -187,7 +187,7 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
|
||||
os.makedirs(outputdir)
|
||||
|
||||
template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE)
|
||||
if 1.5 <= fastrtpsgen_version <= 1.7:
|
||||
if 1.5 <= fastrtps_version <= 1.7:
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + "_.idl")))
|
||||
else:
|
||||
@@ -198,7 +198,7 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
|
||||
|
||||
|
||||
def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filename_receive_msgs, filename_alias_receive_msgs,
|
||||
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtpsgen_version, ros2_distro, template_name):
|
||||
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtps_version, ros2_distro, template_name):
|
||||
"""
|
||||
Generates source file by msg content
|
||||
"""
|
||||
@@ -216,19 +216,19 @@ def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filenam
|
||||
em_globals_list = []
|
||||
if send_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.SEND) for f in send_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.SEND) for f in send_msgs])
|
||||
|
||||
if alias_send_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f[0], f[1], package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
|
||||
|
||||
if receive_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.RECEIVE) for f in receive_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.RECEIVE) for f in receive_msgs])
|
||||
|
||||
if alias_receive_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f[0], f[1], package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
|
||||
merged_em_globals = merge_em_globals_list(em_globals_list)
|
||||
|
||||
@@ -243,7 +243,7 @@ def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filenam
|
||||
return generate_by_template(output_file, template_file, merged_em_globals)
|
||||
|
||||
|
||||
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtpsgen_version, ros2_distro, template_name):
|
||||
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtps_version, ros2_distro, template_name):
|
||||
"""
|
||||
Generates a sources and headers from .msg file
|
||||
"""
|
||||
@@ -251,11 +251,11 @@ def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, pa
|
||||
|
||||
if (alias):
|
||||
em_globals = get_em_globals(
|
||||
msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, fastrtpsgen_version, ros2_distro, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_version, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
@@ -269,7 +269,7 @@ def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, pa
|
||||
return generate_by_template(output_file, template_file, em_globals)
|
||||
|
||||
|
||||
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtpsgen_version, ros2_distro, scope):
|
||||
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtps_version, ros2_distro, scope):
|
||||
"""
|
||||
Generates em globals dictionary
|
||||
"""
|
||||
@@ -298,7 +298,7 @@ def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtpsgen_v
|
||||
"scope": scope,
|
||||
"package": package,
|
||||
"alias": alias,
|
||||
"fastrtpsgen_version": fastrtpsgen_version,
|
||||
"fastrtps_version": fastrtps_version,
|
||||
"ros2_distro": ros2_distro
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user