-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_process.zsh
executable file
·72 lines (69 loc) · 2.51 KB
/
bash_process.zsh
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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/zsh
echo "Output folder: $1"
echo "Environment folder: $2"
echo "Tmp out folder: $3"
echo "Lower folder number: $4"
echo "Offset: $5"
echo "isaac folder: $6"
source ~/.zshrc
folder=$2/
availenv=($folder*)
folderlen=${#folder}
availenv=("${availenv[@]:$4:$5}")
screen -d -m -S ROSMASTER zsh -i -c "rostrue"
echo "WARNING! TMP OUT FOLDER WILL BE CLEARED FOR EACH EXPERIMENT"
echo "WARNING! we run rm ${3}/environment/* every time!!!"
echo "WARNING! we run mv ${3}/environment/ ${1}/ every time!!! Be aware!\n"
while true; do
read -q "yn?Do you still wish to run this program (y/n)?"
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
sleep 5
mkdir -p ${1}
for env in "${availenv[@]}"
do
currentenv=${env:$folderlen}
echo "Processing ${currentenv}"
rm ${3}/${currentenv}/ -rf
rm ${1}/${currentenv}/ -rf
mkdir -p ${1}/${currentenv}
mkdir -p ${3}/${currentenv}
screen -L -Logfile ${3}/${currentenv}/isaaclog.log -d -m -S ISAACSIM zsh -i -c "cd ${6} && ./python.sh standalone_examples/api/omni.isaac.ros_bridge/my_robot.py --/renderer/enabled='rtx,iray' --config='/home/ebonetto/.local/share/ov/pkg/isaac_sim-2021.2.1/standalone_examples/api/omni.isaac.ros_bridge/config.yaml' --fix_env=${currentenv} && ./kill.sh"
screen -L -Logfile ${3}/${currentenv}/rosbag.log -d -m -S ROSRECORDER zsh -i -c "rosbag record -a -O ${1}/${currentenv}/${currentenv}.bag --split --size=1024 -b 0"
screen -L -Logfile ${3}/${currentenv}/rviz.log -d -m -S RVIZ zsh -i -c "cd /home/ebonetto/catkin_ws && source devel/setup.zsh && roslaunch exploration_manager rviz.launch"
echo "Launched"
sleep 200
result=1
cnt=90000
while [ $result -eq 1 ]
do
sleep 1
screen -wipe > suppress_output
if ! screen -list | grep -q "ISAACSIM"; then
rm suppress_output
result=0
break
fi
((cnt=cnt-1))
if [[ "$cnt" -eq 0 ]]; then
for session in $(screen -ls); do screen -S "${session}" -X quit; done
echo "ERROR had to manually stop the sessions" > ${3}/${currentenv}/error.txt
sleep 3
echo "ERROR"
screen -wipe > suppress_output
fi
done
screen -d -m -S ISAACSIMkill zsh -i -c "cd ${6} && ./kill.sh"
echo "KILLED"
sleep 3
#screen -S ROSRECORDER -X stuff "^C"
screen -d -m -S ISAACRM zsh -i -c "cd ${6} && rm kit/logs -rf"
for session in $(screen -ls | grep -o '[0-9]*\.ROSRECORDER'); do screen -S "${session}" -X stuff "^C"; done
sleep 5
screen -d -m -S mover${currentenv} zsh -i -c "mv ${3}/${currentenv}/* ${1}/${currentenv}/"
echo "Finished Processing ${currentenv}"
done