mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 07:03:33 +08:00
first push on supporting ROS2 Dashing and IDL 4.2
This commit is contained in:
@@ -170,7 +170,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, ids):
|
||||
def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, fastrtps_ver, ros2_distro, ids):
|
||||
"""
|
||||
Generates an .idl from .msg file
|
||||
"""
|
||||
@@ -178,11 +178,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, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
@@ -190,14 +190,18 @@ def generate_idl_file(filename_msg, msg_dir, alias, outputdir, templatedir, pack
|
||||
os.makedirs(outputdir)
|
||||
|
||||
template_file = os.path.join(templatedir, IDL_TEMPLATE_FILE)
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + "_.idl")))
|
||||
if ros2_distro == "ardent" or ros2_distro == "bouncy" or ros2_distro == "crystal":
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + "_.idl")))
|
||||
else:
|
||||
output_file = os.path.join(outputdir, IDL_TEMPLATE_FILE.replace(
|
||||
"msg.idl.em", str(spec_short_name + ".idl")))
|
||||
|
||||
return generate_by_template(output_file, template_file, em_globals)
|
||||
|
||||
|
||||
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, template_name):
|
||||
msg_dir, outputdir, templatedir, package, includepath, ids, fastrtps_ver, ros2_distro, template_name):
|
||||
"""
|
||||
Generates source file by msg content
|
||||
"""
|
||||
@@ -223,19 +227,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, MsgScope.SEND) for f in send_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_ver, 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, MsgScope.SEND) for f in alias_send_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.SEND) for f in alias_send_msgs])
|
||||
|
||||
if receive_msgs:
|
||||
em_globals_list.extend([get_em_globals(
|
||||
f, "", package, includepath, ids, MsgScope.RECEIVE) for f in receive_msgs])
|
||||
f, "", package, includepath, ids, fastrtps_ver, 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, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
f[0], f[1], package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.RECEIVE) for f in alias_receive_msgs])
|
||||
|
||||
merged_em_globals = merge_em_globals_list(em_globals_list)
|
||||
|
||||
@@ -250,7 +254,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, template_name):
|
||||
def generate_topic_file(filename_msg, msg_dir, alias, outputdir, templatedir, package, includepath, ids, fastrtps_ver, ros2_distro, template_name):
|
||||
"""
|
||||
Generates a sources and headers from .msg file
|
||||
"""
|
||||
@@ -258,11 +262,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, MsgScope.NONE)
|
||||
msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = alias
|
||||
else:
|
||||
em_globals = get_em_globals(
|
||||
msg, "", package, includepath, ids, MsgScope.NONE)
|
||||
msg, "", package, includepath, ids, fastrtps_ver, ros2_distro, MsgScope.NONE)
|
||||
spec_short_name = em_globals["spec"].short_name
|
||||
|
||||
# Make sure output directory exists:
|
||||
@@ -276,7 +280,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, scope):
|
||||
def get_em_globals(filename_msg, alias, package, includepath, ids, fastrtps_ver, ros2_distro, scope):
|
||||
"""
|
||||
Generates em globals dictionary
|
||||
"""
|
||||
@@ -304,7 +308,9 @@ def get_em_globals(filename_msg, alias, package, includepath, ids, scope):
|
||||
"ids": ids,
|
||||
"scope": scope,
|
||||
"package": package,
|
||||
"alias": alias
|
||||
"alias": alias,
|
||||
"fastrtps_version": fastrtps_ver,
|
||||
"ros2_distro": ros2_distro
|
||||
}
|
||||
|
||||
return em_globals
|
||||
|
||||
Reference in New Issue
Block a user