mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-27 21:44:08 +08:00
msg: generation and parsing scripts: add Python3 support
This commit is contained in:
parent
4329de9e3b
commit
2be7ca08ba
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#!/usr/bin/env python3
|
||||
################################################################################
|
||||
#
|
||||
# Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
||||
@ -69,69 +68,49 @@ def check_rtps_id_uniqueness(classifier):
|
||||
|
||||
repeated_ids = dict()
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
full_send_list = dict(list(msg for msg in classifier.msgs_to_send.items(
|
||||
)) + list(msg[0].items()[0] for msg in classifier.alias_msgs_to_send))
|
||||
full_receive_list = dict(list(msg for msg in classifier.msgs_to_receive.items(
|
||||
)) + list(msg[0].items()[0] for msg in classifier.alias_msgs_to_receive))
|
||||
full_ignore_list = dict(list(msg for msg in classifier.msgs_to_ignore.items(
|
||||
)) + list(msg[0].items()[0] for msg in classifier.alias_msgs_to_ignore))
|
||||
else:
|
||||
full_send_list = dict(list(msg for msg in classifier.msgs_to_send.items(
|
||||
)) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_send))
|
||||
full_receive_list = dict(list(msg for msg in classifier.msgs_to_receive.items(
|
||||
)) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_receive))
|
||||
full_ignore_list = dict(list(msg for msg in classifier.msgs_to_ignore.items(
|
||||
)) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_ignore))
|
||||
full_send_list = dict(list(msg for msg in list(classifier.msgs_to_send.items(
|
||||
))) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_send))
|
||||
full_receive_list = dict(list(msg for msg in list(classifier.msgs_to_receive.items(
|
||||
))) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_receive))
|
||||
full_ignore_list = dict(list(msg for msg in list(classifier.msgs_to_ignore.items(
|
||||
))) + list(list(msg[0].items())[0] for msg in classifier.alias_msgs_to_ignore))
|
||||
|
||||
# check if there are repeated ID's on the messages to send
|
||||
for key, value in full_send_list.items():
|
||||
if sys.version_info[0] < 3:
|
||||
if full_send_list.values().count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
else:
|
||||
if list(full_send_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
for key, value in list(full_send_list.items()):
|
||||
if list(full_send_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
|
||||
# check if there are repeated ID's on the messages to receive
|
||||
for key, value in full_receive_list.items():
|
||||
if sys.version_info[0] < 3:
|
||||
if full_receive_list.values().count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
else:
|
||||
if list(full_receive_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
for key, value in list(full_receive_list.items()):
|
||||
if list(full_receive_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
|
||||
# check if there are repeated ID's on the messages to ignore
|
||||
for key, value in full_ignore_list.items():
|
||||
if sys.version_info[0] < 3:
|
||||
if full_ignore_list.values().count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
else:
|
||||
if list(full_ignore_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
for key, value in list(full_ignore_list.items()):
|
||||
if list(full_ignore_list.values()).count(value) > 1:
|
||||
repeated_ids.update({key: value})
|
||||
|
||||
# check if there are repeated IDs between classified and unclassified msgs
|
||||
# check send and ignore lists
|
||||
send_ignore_common_ids = list(set(full_ignore_list.values(
|
||||
)).intersection(full_send_list.values()))
|
||||
for item in full_send_list.items():
|
||||
)).intersection(list(full_send_list.values())))
|
||||
for item in list(full_send_list.items()):
|
||||
for repeated in send_ignore_common_ids:
|
||||
if item[1] == repeated:
|
||||
repeated_ids.update({item[0]: item[1]})
|
||||
for item in full_ignore_list.items():
|
||||
for item in list(full_ignore_list.items()):
|
||||
for repeated in send_ignore_common_ids:
|
||||
if item[1] == repeated:
|
||||
repeated_ids.update({item[0]: item[1]})
|
||||
|
||||
# check receive and ignore lists
|
||||
receive_ignore_common_ids = list(set(full_ignore_list.values(
|
||||
)).intersection(full_receive_list.values()))
|
||||
for item in full_receive_list.items():
|
||||
)).intersection(list(full_receive_list.values())))
|
||||
for item in list(full_receive_list.items()):
|
||||
for repeated in receive_ignore_common_ids:
|
||||
if item[1] == repeated:
|
||||
repeated_ids.update({item[0]: item[1]})
|
||||
for item in full_ignore_list.items():
|
||||
for item in list(full_ignore_list.items()):
|
||||
for repeated in receive_ignore_common_ids:
|
||||
if item[1] == repeated:
|
||||
repeated_ids.update({item[0]: item[1]})
|
||||
@ -141,16 +120,13 @@ def check_rtps_id_uniqueness(classifier):
|
||||
all_msgs.update(full_receive_list)
|
||||
all_msgs.update(full_ignore_list)
|
||||
all_ids = list()
|
||||
if sys.version_info[0] < 3:
|
||||
all_ids = all_msgs.values()
|
||||
else:
|
||||
all_ids = list(all_msgs.values())
|
||||
all_ids = list(all_msgs.values())
|
||||
all_ids.sort()
|
||||
|
||||
if not repeated_ids:
|
||||
print("All good. RTPS ID's are unique")
|
||||
else:
|
||||
raise AssertionError(", ".join('%s' % msgs for msgs in repeated_ids.keys()) +
|
||||
raise AssertionError(", ".join('%s' % msgs for msgs in list(repeated_ids.keys())) +
|
||||
" have their ID's repeated. Please choose from the following pool:\n" +
|
||||
", ".join('%d' % id for id in px_generate_uorb_topic_helper.check_available_ids(all_ids)))
|
||||
|
||||
@ -298,7 +274,7 @@ if del_tree:
|
||||
if agent:
|
||||
_continue = str(input("\nFiles in " + agent_out_dir +
|
||||
" will be erased, continue?[Y/n]\n"))
|
||||
if _continue.strip() in ("N", "n"):
|
||||
if _continue == "N" or _continue == "n":
|
||||
print("Aborting execution...")
|
||||
exit(-1)
|
||||
else:
|
||||
@ -364,10 +340,7 @@ def generate_agent(out_dir):
|
||||
|
||||
if classifier.alias_msgs_to_send:
|
||||
for msg_file in classifier.alias_msgs_to_send:
|
||||
if sys.version_info[0] < 3:
|
||||
msg_alias = msg_file[0].keys()[0]
|
||||
else:
|
||||
msg_alias = list(msg_file[0].keys())[0]
|
||||
msg_alias = list(msg_file[0].keys())[0]
|
||||
msg_name = msg_file[1]
|
||||
if gen_idl:
|
||||
if out_dir != agent_out_dir:
|
||||
@ -397,10 +370,7 @@ def generate_agent(out_dir):
|
||||
|
||||
if classifier.alias_msgs_to_receive:
|
||||
for msg_file in classifier.alias_msgs_to_receive:
|
||||
if sys.version_info[0] < 3:
|
||||
msg_alias = msg_file[0].keys()[0]
|
||||
else:
|
||||
msg_alias = list(msg_file[0].keys())[0]
|
||||
msg_alias = list(msg_file[0].keys())[0]
|
||||
msg_name = msg_file[1]
|
||||
if gen_idl:
|
||||
if out_dir != agent_out_dir:
|
||||
@ -504,8 +474,8 @@ def generate_client(out_dir):
|
||||
|
||||
if agent:
|
||||
generate_agent(agent_out_dir)
|
||||
print("\nAgent created in: " + agent_out_dir)
|
||||
print(("\nAgent created in: " + agent_out_dir))
|
||||
|
||||
if client:
|
||||
generate_client(client_out_dir)
|
||||
print("\nClient created in: " + client_out_dir)
|
||||
print(("\nClient created in: " + client_out_dir))
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#############################################################################
|
||||
#
|
||||
# Copyright (C) 2013-2018 PX4 Pro Development Team. All rights reserved.
|
||||
@ -37,7 +37,7 @@ px_generate_uorb_topic_files.py
|
||||
Generates c/cpp header/source files for uorb topics from .msg (ROS syntax)
|
||||
message files
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import filecmp
|
||||
@ -208,19 +208,11 @@ def generate_uRTPS_general(filename_send_msgs, filename_alias_send_msgs, filenam
|
||||
receive_msgs = list(os.path.join(msg_dir, msg + ".msg")
|
||||
for msg in filename_receive_msgs)
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
alias_send_msgs = list([os.path.join(
|
||||
msg_dir, msg[1] + ".msg"), msg[0].keys()[0]] for msg in filename_alias_send_msgs)
|
||||
else:
|
||||
alias_send_msgs = list([os.path.join(msg_dir, msg[1] + ".msg"),
|
||||
list(msg[0].keys())[0]] for msg in filename_alias_send_msgs)
|
||||
alias_send_msgs = list([os.path.join(
|
||||
msg_dir, msg[1] + ".msg"), list(msg[0].keys())[0]] for msg in filename_alias_send_msgs)
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
alias_receive_msgs = list([os.path.join(
|
||||
msg_dir, msg[1] + ".msg"), msg[0].keys()[0]] for msg in filename_alias_receive_msgs)
|
||||
else:
|
||||
alias_receive_msgs = list([os.path.join(
|
||||
msg_dir, msg[1] + ".msg"), list(msg[0].keys())[0]] for msg in filename_alias_receive_msgs)
|
||||
alias_receive_msgs = list([os.path.join(
|
||||
msg_dir, msg[1] + ".msg"), list(msg[0].keys())[0]] for msg in filename_alias_receive_msgs)
|
||||
|
||||
em_globals_list = []
|
||||
if send_msgs:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#############################################################################
|
||||
#
|
||||
# Copyright (C) 2013-2019 PX4 Pro Development Team. All rights reserved.
|
||||
@ -254,10 +254,10 @@ def print_field(field):
|
||||
|
||||
else:
|
||||
for i in range(array_length):
|
||||
print("PX4_INFO_RAW(\"\\t" + field.type +
|
||||
" " + field.name + "[" + str(i) + "]\");")
|
||||
print(" print_message(message." +
|
||||
field.name + "[" + str(i) + "]);")
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.type +
|
||||
" " + field.name + "[" + str(i) + "]\");"))
|
||||
print((" print_message(message." +
|
||||
field.name + "[" + str(i) + "]);"))
|
||||
return
|
||||
|
||||
for i in range(array_length):
|
||||
@ -291,23 +291,23 @@ def print_field(field):
|
||||
field_name = "(" + field_name + " ? \"True\" : \"False\")"
|
||||
|
||||
else:
|
||||
print("PX4_INFO_RAW(\"\\n\\t" + field.name + "\");")
|
||||
print("\tprint_message(message." + field.name + ");")
|
||||
print(("PX4_INFO_RAW(\"\\n\\t" + field.name + "\");"))
|
||||
print(("\tprint_message(message." + field.name + ");"))
|
||||
return
|
||||
|
||||
if field.name == 'timestamp':
|
||||
print("if (message.timestamp != 0) {\n\t\tPX4_INFO_RAW(\"\\t" + field.name +
|
||||
print(("if (message.timestamp != 0) {\n\t\tPX4_INFO_RAW(\"\\t" + field.name +
|
||||
": " + c_type + " (%.6f seconds ago)\\n\", " + field_name +
|
||||
", hrt_elapsed_time(&message.timestamp) / 1e6);\n\t} else {\n\t\tPX4_INFO_RAW(\"\\n\");\n\t}")
|
||||
", hrt_elapsed_time(&message.timestamp) / 1e6);\n\t} else {\n\t\tPX4_INFO_RAW(\"\\n\");\n\t}"))
|
||||
elif field.name == 'device_id':
|
||||
print("char device_id_buffer[80];")
|
||||
print("device::Device::device_id_print_buffer(device_id_buffer, sizeof(device_id_buffer), message.device_id);")
|
||||
print("PX4_INFO_RAW(\"\\tdevice_id: %d (%s) \\n\", message.device_id, device_id_buffer);")
|
||||
elif is_array and 'char' in field.type:
|
||||
print("PX4_INFO_RAW(\"\\t" + field.name + ": \\\"%." + str(array_length) + "s\\\" \\n\", message." + field.name + ");")
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.name + ": \\\"%." + str(array_length) + "s\\\" \\n\", message." + field.name + ");"))
|
||||
else:
|
||||
print("PX4_INFO_RAW(\"\\t" + field.name + ": " +
|
||||
c_type + "\\n\", " + field_name + ");")
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.name + ": " +
|
||||
c_type + "\\n\", " + field_name + ");"))
|
||||
|
||||
|
||||
def print_field_def(field):
|
||||
@ -347,8 +347,8 @@ def print_field_def(field):
|
||||
if field.name.startswith('_padding'):
|
||||
comment = ' // required for logger'
|
||||
|
||||
print('\t%s%s%s %s%s;%s' % (type_prefix, type_px4, type_appendix, field.name,
|
||||
array_size, comment))
|
||||
print(('\t%s%s%s %s%s;%s' % (type_prefix, type_px4, type_appendix, field.name,
|
||||
array_size, comment)))
|
||||
|
||||
|
||||
def check_available_ids(used_msg_ids_list):
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#!/usr/bin/env python3
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (c) 2018-2019 PX4 Development Team. All rights reserved.
|
||||
@ -76,8 +75,8 @@ class Classifier():
|
||||
send = {}
|
||||
send_alias = []
|
||||
for dict in self.msg_id_map['rtps']:
|
||||
if 'send' in dict.keys():
|
||||
if 'alias' in dict.keys():
|
||||
if 'send' in list(dict.keys()):
|
||||
if 'alias' in list(dict.keys()):
|
||||
send_alias.append(
|
||||
({dict['msg']: dict['id']}, dict['alias']))
|
||||
else:
|
||||
@ -88,8 +87,8 @@ class Classifier():
|
||||
receive = {}
|
||||
receive_alias = []
|
||||
for dict in self.msg_id_map['rtps']:
|
||||
if 'receive' in dict.keys():
|
||||
if 'alias' in dict.keys():
|
||||
if 'receive' in list(dict.keys()):
|
||||
if 'alias' in list(dict.keys()):
|
||||
receive_alias.append(
|
||||
({dict['msg']: dict['id']}, dict['alias']))
|
||||
else:
|
||||
@ -100,8 +99,8 @@ class Classifier():
|
||||
ignore = {}
|
||||
ignore_alias = []
|
||||
for dict in self.msg_id_map['rtps']:
|
||||
if (('send' not in dict.keys()) and ('receive' not in dict.keys())):
|
||||
if 'alias' in dict.keys():
|
||||
if (('send' not in list(dict.keys())) and ('receive' not in list(dict.keys()))):
|
||||
if 'alias' in list(dict.keys()):
|
||||
ignore_alias.append(
|
||||
({dict['msg']: dict['id']}, dict['alias']))
|
||||
else:
|
||||
@ -110,15 +109,15 @@ class Classifier():
|
||||
|
||||
def set_msg_files_send(self):
|
||||
return [os.path.join(self.msg_folder, msg + ".msg")
|
||||
for msg in self.msgs_to_send.keys()]
|
||||
for msg in list(self.msgs_to_send.keys())]
|
||||
|
||||
def set_msg_files_receive(self):
|
||||
return [os.path.join(self.msg_folder, msg + ".msg")
|
||||
for msg in self.msgs_to_receive.keys()]
|
||||
for msg in list(self.msgs_to_receive.keys())]
|
||||
|
||||
def set_msg_files_ignore(self):
|
||||
return [os.path.join(self.msg_folder, msg + ".msg")
|
||||
for msg in self.msgs_to_ignore.keys()]
|
||||
for msg in list(self.msgs_to_ignore.keys())]
|
||||
|
||||
def check_if_listed(self, yaml_file):
|
||||
"""
|
||||
@ -148,11 +147,11 @@ class Classifier():
|
||||
Check if alias message has correct base type
|
||||
"""
|
||||
registered_alias_msgs = list(
|
||||
dict['alias'] for dict in self.msg_id_map['rtps'] if 'alias' in dict.keys())
|
||||
dict['alias'] for dict in self.msg_id_map['rtps'] if 'alias' in list(dict.keys()))
|
||||
|
||||
base_types = []
|
||||
for dict in self.msg_id_map['rtps']:
|
||||
if 'alias' not in dict.keys():
|
||||
if 'alias' not in list(dict.keys()):
|
||||
base_types.append(dict['msg'])
|
||||
|
||||
incorrect_base_types = list(
|
||||
@ -165,7 +164,7 @@ class Classifier():
|
||||
|
||||
if len(base_types_suggestion) > 0:
|
||||
raise AssertionError(
|
||||
('\n' + '\n'.join('\t- The multi-topic message base type \'{}\' does not exist.{}'.format(k, (' Did you mean \'' + v[0] + '\'?' if v else '')) for k, v in base_types_suggestion.items())))
|
||||
('\n' + '\n'.join('\t- The multi-topic message base type \'{}\' does not exist.{}'.format(k, (' Did you mean \'' + v[0] + '\'?' if v else '')) for k, v in list(base_types_suggestion.items()))))
|
||||
|
||||
def check_id_space(self):
|
||||
"""
|
||||
@ -174,18 +173,18 @@ class Classifier():
|
||||
incorrect_base_ids = {}
|
||||
incorrect_alias_ids = {}
|
||||
for dict in self.msg_id_map['rtps']:
|
||||
if 'alias' not in dict.keys() and dict['id'] >= self.alias_space_init_id:
|
||||
if 'alias' not in list(dict.keys()) and dict['id'] >= self.alias_space_init_id:
|
||||
incorrect_base_ids.update({dict['msg']: dict['id']})
|
||||
elif 'alias' in dict.keys() and dict['id'] < self.alias_space_init_id:
|
||||
elif 'alias' in list(dict.keys()) and dict['id'] < self.alias_space_init_id:
|
||||
incorrect_alias_ids.update({dict['msg']: dict['id']})
|
||||
|
||||
if len(incorrect_base_ids) > 0:
|
||||
raise AssertionError(
|
||||
('\n' + '\n'.join('\t- The message \'{} with ID \'{}\' is in the wrong ID space. Please use any of the available IDs from 0 to 149'.format(k, v) for k, v in incorrect_base_ids.items())))
|
||||
('\n' + '\n'.join('\t- The message \'{} with ID \'{}\' is in the wrong ID space. Please use any of the available IDs from 0 to 149'.format(k, v) for k, v in list(incorrect_base_ids.items()))))
|
||||
|
||||
if len(incorrect_alias_ids) > 0:
|
||||
raise AssertionError(
|
||||
('\n' + '\n'.join('\t- The alias message \'{}\' with ID \'{}\' is in the wrong ID space. Please use any of the available IDs from 149 to 255'.format(k, v) for k, v in incorrect_alias_ids.items())))
|
||||
('\n' + '\n'.join('\t- The alias message \'{}\' with ID \'{}\' is in the wrong ID space. Please use any of the available IDs from 149 to 255'.format(k, v) for k, v in list(incorrect_alias_ids.items()))))
|
||||
|
||||
@staticmethod
|
||||
def parse_yaml_msg_id_file(yaml_file):
|
||||
@ -235,52 +234,37 @@ if __name__ == "__main__":
|
||||
|
||||
if args.send:
|
||||
if args.path:
|
||||
print ('send files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_send) + '\n')
|
||||
print(('send files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_send) + '\n'))
|
||||
else:
|
||||
if args.alias:
|
||||
if sys.version_info[0] < 3:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_send.keys()) + (' alias ' + ', '.join(str(msg[0].keys()[0])
|
||||
for msg in classifier.alias_msgs_to_send) if len(classifier.alias_msgs_to_send) > 0 else '') + '\n')
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_send.keys()) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_send) if len(classifier.alias_msgs_to_send) > 0 else '') + '\n')
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_send.keys())) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_send) if len(classifier.alias_msgs_to_send) > 0 else '') + '\n'))
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_send.keys()))
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_send.keys()))))
|
||||
if args.receive:
|
||||
if args.path:
|
||||
print ('receive files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_receive) + '\n')
|
||||
print(('receive files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_receive) + '\n'))
|
||||
else:
|
||||
if args.alias:
|
||||
if sys.version_info[0] < 3:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_receive.keys()) + (' alias ' + ', '.join(str(msg[0].keys()[0])
|
||||
for msg in classifier.alias_msgs_to_receive) if len(classifier.alias_msgs_to_receive) > 0 else '') + '\n')
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_receive.keys()) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_receive) if len(classifier.alias_msgs_to_receive) > 0 else '') + '\n')
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_receive.keys())) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_receive) if len(classifier.alias_msgs_to_receive) > 0 else '') + '\n'))
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_receive.keys()))
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_receive.keys()))))
|
||||
if args.ignore:
|
||||
if args.path:
|
||||
print ('ignore files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_ignore) + '\n')
|
||||
print(('ignore files: ' + ', '.join(str(msg_file)
|
||||
for msg_file in classifier.msgs_files_ignore) + '\n'))
|
||||
else:
|
||||
if args.alias:
|
||||
if sys.version_info[0] < 3:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_ignore.keys()) + (' alias ' + ', '.join(str(msg[0].keys()[0])
|
||||
for msg in classifier.alias_msgs_to_ignore) if len(classifier.alias_msgs_to_ignore) > 0 else '') + '\n')
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_ignore.keys()) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_ignore) if len(classifier.alias_msgs_to_ignore) > 0 else '') + '\n')
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_ignore.keys())) + (' alias ' + ', '.join(str(list(msg[0].keys())[0])
|
||||
for msg in classifier.alias_msgs_to_ignore) if len(classifier.alias_msgs_to_ignore) > 0 else '') + '\n'))
|
||||
else:
|
||||
print (', '.join(str(msg)
|
||||
for msg in classifier.msgs_to_ignore.keys()))
|
||||
print((', '.join(str(msg)
|
||||
for msg in list(classifier.msgs_to_ignore.keys()))))
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script to parse uORB message format to ROS msg format
|
||||
Adapted from https://github.com/eProsima/px4_to_ros/blob/master/px4_to_ros2_PoC/px4_msgs/scripts/copy_and_rename.py
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script to read an yaml file containing the RTPS message IDs and update the naming convention to PascalCase
|
||||
"""
|
||||
@ -75,7 +75,7 @@ def load_yaml_file(file):
|
||||
try:
|
||||
with open(file, 'r') as f:
|
||||
if verbose:
|
||||
print("--\t[Step 1] %s yaml file loaded!" % file)
|
||||
print(("--\t[Step 1] %s yaml file loaded!" % file))
|
||||
return yaml.safe_load(f)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
@ -98,7 +98,7 @@ def update_dict(list):
|
||||
if verbose:
|
||||
num_of_msgs += 1
|
||||
if verbose:
|
||||
print("--\t[Step 2] List: %d msg names updated!" % num_of_msgs)
|
||||
print(("--\t[Step 2] List: %d msg names updated!" % num_of_msgs))
|
||||
|
||||
|
||||
def update_yaml_file(list, file):
|
||||
@ -117,9 +117,9 @@ def update_yaml_file(list, file):
|
||||
yaml.dump(list, f, Dumper=IndenterDumper, default_flow_style=False)
|
||||
if verbose:
|
||||
if in_file == out_file:
|
||||
print("--\t[Step 3] %s updated!" % in_file)
|
||||
print(("--\t[Step 3] %s updated!" % in_file))
|
||||
else:
|
||||
print("--\t[Step 3] %s created!" % out_file)
|
||||
print(("--\t[Step 3] %s created!" % out_file))
|
||||
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user