forked from surgical-robotics-ai/SurgicAI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollect_data.sh
More file actions
executable file
·60 lines (47 loc) · 1.63 KB
/
Copy pathcollect_data.sh
File metadata and controls
executable file
·60 lines (47 loc) · 1.63 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
NUM_RUNS=25
# Disable automatic exit on error
set +e
for ((i=1; i<=NUM_RUNS; i++)); do
echo "=== Starting iteration $i ==="
# Randomize simulator colors
echo "Randomizing simulator colors..."
python randomize_simulator_colors.py
if [ $? -ne 0 ]; then
echo "Failed to randomize colors. Skipping iteration $i."
continue
fi
# Launch the simulator
echo "Launching simulator..."
setsid vglrun ~/ambf_updated_commit/ambf/bin/lin-x86_64/ambf_simulator \
--launch_file ~/ambf/surgical_robotics_challenge/launch.yaml \
-l 0,1,3,4,13,14 \
-p 200 \
-t 1 \
--override_max_comm_freq 120 & VGL_PID=$!
sleep 1
# Check if the simulator actually launched
if ! ps -p $VGL_PID > /dev/null; then
echo "Simulator failed to start. Skipping iteration $i."
continue
fi
echo "Simulator PID: $VGL_PID"
pgid=$(ps -o pgid= "$VGL_PID" | grep -o '[0-9]*')
if [ -z "$pgid" ]; then
echo "Failed to retrieve PGID. Skipping iteration $i."
kill -KILL $VGL_PID 2>/dev/null
continue
fi
echo "Process Group ID: $pgid"
echo "Running data collection..."
python RL/data_collection_hardcoded_expert.py \
--config /home/cis2-automated-suturing/Desktop/grayson/grayson_SurgicAI_fork/SurgicAI/RL/configs/domain_randomization_configs/test.yaml
echo "Data collection exit code: $?"
# Kill the entire simulation process group
echo "Terminating simulator process group..."
kill -TERM -"$pgid"
sleep 2
kill -KILL -"$pgid" 2>/dev/null
echo "=== Finished iteration $i ==="
echo
done