-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecord.py
More file actions
36 lines (28 loc) · 1.13 KB
/
record.py
File metadata and controls
36 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import subprocess
twist_file = "src/custom_package/src/twist_generator.py"
twist_arg = ["python3", twist_file, "&"]
twpid = subprocess.Popen(twist_arg)
#################################################################################################
fileName = "CustomTopics.txt"
sleepTime = 0 # time (seconds) to get ready
durationTime = "5m" # recording time (seconds) ---- can also use minutes and hours
### NAME ##
context = "" # rush, neutral, or casual
date = "" # mmddyyyy
trajectory_number = 1
# context = "neutral" # casual, neutral, rush
initial = ""
scene = ""
bagName = f"data/{date}_{initial}_{scene}_{trajectory_number}_{context}" #"data/" + name # -- change this every trial
#################################################################################################
arg = ["rosbag", "record", "-O", f'{bagName}', f'--duration={durationTime}', '/chatter']
f = open(fileName, 'r')
lines = f.readlines()
for line in lines:
arg.append(line.strip())
print(f"Get ready in {sleepTime} seconds...")
time.sleep(sleepTime)
print("Begin")
command = subprocess.run(arg)
print("The exit code was: %d" % command.returncode)