|
|
|
@ -53,18 +53,23 @@ __status__ = 'Development'
@@ -53,18 +53,23 @@ __status__ = 'Development'
|
|
|
|
|
input_dir = sys.argv[1] |
|
|
|
|
output_dir = sys.argv[2] |
|
|
|
|
|
|
|
|
|
if not os.path.exists(os.path.abspath(output_dir)): |
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
print("----------------------- \033[1mmicroRTPS bridge uORB to ROS messages\033[0m -----------------------") |
|
|
|
|
print("-------------------------------------------------------------------------------------------------------") |
|
|
|
|
|
|
|
|
|
if not os.path.exists(os.path.abspath(output_dir)): |
|
|
|
|
os.mkdir(os.path.abspath(output_dir)) |
|
|
|
|
else: |
|
|
|
|
else: |
|
|
|
|
ros_msg_dir = os.path.abspath(output_dir) |
|
|
|
|
msg_files = os.listdir(ros_msg_dir) |
|
|
|
|
for msg in msg_files: |
|
|
|
|
if msg.endswith(".msg"): |
|
|
|
|
os.remove(os.path.join(ros_msg_dir, msg)) |
|
|
|
|
|
|
|
|
|
msg_list = list() |
|
|
|
|
msg_list = list() |
|
|
|
|
|
|
|
|
|
for filename in os.listdir(input_dir): |
|
|
|
|
for filename in os.listdir(input_dir): |
|
|
|
|
if '.msg' in filename: |
|
|
|
|
msg_list.append(filename.rstrip('.msg')) |
|
|
|
|
input_file = input_dir + filename |
|
|
|
@ -73,7 +78,7 @@ for filename in os.listdir(input_dir):
@@ -73,7 +78,7 @@ for filename in os.listdir(input_dir):
|
|
|
|
|
filename.partition(".")[0].title().replace('_', '') + ".msg" |
|
|
|
|
copyfile(input_file, output_file) |
|
|
|
|
|
|
|
|
|
for filename in os.listdir(output_dir): |
|
|
|
|
for filename in os.listdir(output_dir): |
|
|
|
|
if '.msg' in filename: |
|
|
|
|
input_file = output_dir + filename |
|
|
|
|
|
|
|
|
@ -91,6 +96,7 @@ for filename in os.listdir(output_dir):
@@ -91,6 +96,7 @@ for filename in os.listdir(output_dir):
|
|
|
|
|
fileUpdated = True |
|
|
|
|
line = line.replace(('px4/' + msg_type), |
|
|
|
|
msg_type.partition(".")[0].title().replace('_', '')) |
|
|
|
|
|
|
|
|
|
if re.findall('^' + msg_type + '[\s\[]', line.partition('#')[0]): |
|
|
|
|
fileUpdated = True |
|
|
|
|
line = line.replace(msg_type, |
|
|
|
@ -112,3 +118,10 @@ for filename in os.listdir(output_dir):
@@ -112,3 +118,10 @@ for filename in os.listdir(output_dir):
|
|
|
|
|
with open(input_file, 'w+') as f: |
|
|
|
|
for line in newlines: |
|
|
|
|
f.write(line) |
|
|
|
|
|
|
|
|
|
print("--\t\t- Generated {} ROS message files in '{}'".format(len(os.listdir(output_dir)), os.path.abspath(output_dir))) |
|
|
|
|
print("-------------------------------------------------------------------------------------------------------") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
main() |
|
|
|
|