Skip to content

Commit f5af5ea

Browse files
committed
Better naming of output file
1 parent 1d0ef71 commit f5af5ea

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tycho_recorder/src/recorder_node

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
import datetime
34
import subprocess
45

56
import rospy
@@ -27,14 +28,16 @@ class RosbagRecorder:
2728
return
2829
rospy.loginfo(f"{rospy.get_caller_id()}: Starting recording")
2930
self.is_recording = True
30-
self.process = subprocess.Popen(["rosbag", "record", "-a", "-O", "test.bag"])
31+
self.process = subprocess.Popen(["rosbag", "record", "-a", "-O", f"tycho-experiment-{datetime.datetime.now().strftime('%y%m%d-%H%M%S')}.bag"])
3132

3233
def stop_recording(self):
34+
if not self.is_recording:
35+
return
3336
rospy.loginfo(f"{rospy.get_caller_id()}: Stopping recording")
37+
self.is_recording = False
3438
self.process.terminate()
3539

3640
def start_listening():
37-
3841
# In ROS, nodes are uniquely named. If two nodes with the same
3942
# name are launched, the previous one is kicked off. The
4043
# anonymous=True flag means that rospy will choose a unique
@@ -44,7 +47,7 @@ def start_listening():
4447
recorder = RosbagRecorder()
4548
rospy.Subscriber("/argos3/status", String, recorder.argos3_status_callback)
4649
rospy.on_shutdown(recorder.stop_recording)
47-
50+
rospy.loginfo(f"{rospy.get_caller_id()}: Node is ready for recording.")
4851
# spin() simply keeps python from exiting until this node is stopped
4952
rospy.spin()
5053

0 commit comments

Comments
 (0)