add metadata to rosbag
Hello everybody,
I am trying to add ros parameters to a bag file just after the record is done.
I am writing a python script to do that and I have followed this link : http://wiki.ros.org/rosbag/Cookbook. But I didn't manage to make it work.
Nothing is added to the bag file and I have no error message .....
There is my code :
record_args = ""
try:
for param in rospy.get_param_names():
record_args += str(param + ": " + str(rospy.get_param(param))+ " | ")
subprocess.call(["rosbag", "record", "-a", "-O", "test"])
except KeyboardInterrupt:
with rosbag.Bag('test.bag','a') as bag:
dump = String(data = record_args)
for _, _, t in bag.read_messages():
break
bag.write('/rosparam', dump, t-rospy.rostime.Duration(0, 1))
finally:
bag.close()
Thanks in advance.
Asked by F.Brosseau on 2016-08-03 04:15:08 UTC
Answers
I will answer my own question :
I use psutil instead of subprocess. There is the part of the code doing the job :
process = psutil.Popen(["rosbag", "record", "-O",bag_filename]+topic_list)
process.wait()
except KeyboardInterrupt:
process_util = psutil.Process(process.pid)
children = process_util.get_children()
for child_process in children:
child_process.send_signal(signal.SIGINT)
child_process.wait()
process_util.send_signal(signal.SIGINT)
process_util.wait()
Asked by F.Brosseau on 2016-08-05 03:14:10 UTC
Comments