now can choose which topics to bag in the control pannel
This commit is contained in:
@@ -21,11 +21,28 @@ class Bagger(object):
|
||||
os.killpg(self.proc.pid, signal.SIGINT)
|
||||
self.pub.publish("STOPPED")
|
||||
else:
|
||||
bag_file = os.path.join(self.data_path, msg.data)
|
||||
self.proc = subprocess.Popen(["rosbag", "record",
|
||||
"--all", "-o", bag_file], preexec_fn=os.setsid)
|
||||
self.pub.publish("STARTED")
|
||||
|
||||
msg_data = msg.data.split()
|
||||
self.pub.publish(str(len(msg_data)))
|
||||
self.pub.publish(str(msg_data))
|
||||
if len(msg_data) == 0: # We only got the name of the bag file and not any topics
|
||||
bag_file_name = os.path.join(self.data_path, "bag_file")
|
||||
self.proc = subprocess.Popen(["rosbag", "record",
|
||||
"--all", "-o", bag_file_name], preexec_fn=os.setsid)
|
||||
self.pub.publish("STARTED")
|
||||
elif len(msg_data) == 1: # We only got the name of the bag file and not any topics
|
||||
bag_file_name = os.path.join(self.data_path, msg_data)
|
||||
self.proc = subprocess.Popen(["rosbag", "record",
|
||||
"--all", "-o", bag_file_name], preexec_fn=os.setsid)
|
||||
self.pub.publish("STARTED")
|
||||
else: #we posibly have a bag file name and a list of topics
|
||||
if msg_data[0].startswith("/"): #then we know there is no bag file name
|
||||
msg_data = ["bagfile"] + msg_data
|
||||
msg_data[0] = os.path.join(self.data_path, msg_data[0])
|
||||
processList = ["rosbag", "record", "-o"] + msg_data
|
||||
self.pub.publish(" ".join(processList))
|
||||
self.proc = subprocess.Popen( processList, preexec_fn=os.setsid)
|
||||
self.pub.publish("STARTED")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Bagger()
|
||||
|
||||
Reference in New Issue
Block a user