now can choose which topics to bag in the control pannel

This commit is contained in:
Glen Turner
2015-06-29 16:56:20 -07:00
parent d146020719
commit 09f78ce4d8
14 changed files with 205 additions and 96 deletions

View File

@@ -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()