Skip to content
Snippets Groups Projects
Commit 833260e0 authored by Houssaini Ziyad's avatar Houssaini Ziyad
Browse files

Add new directory containing python parser ros

parent 99f1b35c
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ def save_rosbags_topics(file_name : str, directory : str):
content_split = content.split("/")[-1]
#Case when you specify the directory containing the rosbags files or read directory the file
b = bagreader(content)
df_topics = b.topic_table
df_topics.to_csv(os.path.join(directory,content_split[:-5]+'.csv'))
......
......@@ -9,6 +9,12 @@ import shutil
def convert_topics_to_file(files , topics , directory):
"""
This function allows to extract the data published in the topics choosen in the command line and save all the topics choosen in a new directory
which in this directory there are each new directory containing the data topics save into a csv and matlab format.
"""
if(directory not in os.listdir()):
os.mkdir(directory)
else:
......@@ -31,7 +37,7 @@ def convert_topics_to_file(files , topics , directory):
os.mkdir(os.path.join(directory , file_split))
data_frame.to_csv(os.path.join(directory , file_split , file_split+'.csv'))
print("Convert the topic {} to a csv format in the directory {}".format(topic , os.path.join(directory , file_split)))
print("Convert the topic {} to a csv format in the directory {}.csv".format(topic , os.path.join(directory , file_split)))
data_mat = data_frame.to_dict('list')
topic_name = topic.replace('/' , '_')
savemat(os.path.join(directory , file_split , file_split+'.mat') , data_mat)
......@@ -40,7 +46,7 @@ def convert_topics_to_file(files , topics , directory):
except Exception as e:
print('Unable to read the topic or other probles ... {}'.format(e))
print('Unable to read the topic or the file speciefied ...Error : {}'.format(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment