forked from tmigimatsu/cs225a-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·125 lines (114 loc) · 2.7 KB
/
make.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
set -e
# Update sai2-common
cd sai2-common
git pull origin master
mkdir -p build_rel
cd build_rel
cmake ..
make -j4
cd ../..
# Build cs225a
mkdir -p build
cd build
cmake ..
make -j4
cd ..
# Download resource files
mkdir -p resources
cd resources
if [ ! -d "puma_graphics" ]; then
curl -L http://cs.stanford.edu/groups/manips/teaching/cs225a/resources/puma_graphics.zip -o puma_graphics.zip
unzip puma_graphics.zip
rm puma_graphics.zip
fi
if [ ! -d "kuka_iiwa_graphics" ]; then
curl -L http://cs.stanford.edu/groups/manips/teaching/cs225a/resources/kuka_iiwa_graphics.zip -o kuka_iiwa_graphics.zip
unzip kuka_iiwa_graphics.zip
rm kuka_iiwa_graphics.zip
fi
cd ..
cd bin
if [ -f "hw1" ]; then
cd resources/hw1
if [ ! -e "puma_graphics" ]; then
ln -s ../../../resources/puma_graphics .
fi
cd ../..
fi
if [ -f "hw2" ]; then
cd resources/hw2
if [ ! -e "kuka_iiwa_graphics" ]; then
ln -s ../../../resources/kuka_iiwa_graphics .
fi
cd ../..
fi
if [ -f "hw3" ]; then
cd resources/hw3
if [ ! -e "kuka_iiwa_graphics" ]; then
ln -s ../../../resources/kuka_iiwa_graphics .
fi
cd ../..
fi
if [ -f "demo_project" ]; then
cd resources/demo_project
if [ ! -e "kuka_iiwa_graphics" ]; then
ln -s ../../../resources/kuka_iiwa_graphics .
fi
cd ../..
fi
if [ -f "kuka_iiwa_driver" ]; then
cd resources/kuka_iiwa_driver
if [ ! -e "kuka_iiwa_graphics" ]; then
ln -s ../../../resources/kuka_iiwa_graphics .
fi
cd ../..
fi
if [ -f "kuka_hold_pos" ]; then
cd resources/kuka_hold_pos
if [ ! -e "kuka_iiwa_graphics" ]; then
ln -s ../../../resources/kuka_iiwa_graphics .
fi
cd ../..
fi
cd ..
# Insert helper scripts into bin directory
cd bin
# Make script
cat <<EOF > make.sh
cd ..
mkdir -p build
cd build
cmake ..
make -j4
cd ../bin
EOF
chmod +x make.sh
# Run hw0 script
if [ -f "hw0" ]; then
cat <<EOF > run_hw0.sh
# This script calls ./visualizer and ./hw0 simultaneously.
# All arguments to this script will be passed onto ./hw0
trap 'kill %1' SIGINT
./visualizer resources/hw0/world.urdf resources/hw0/RRPbot.urdf RRPbot & ./hw0 "\$@"
EOF
chmod +x run_hw0.sh
fi
# Run generic controller script
if [ -f "hw1" ]; then
cat <<EOF > run_controller.sh
if [ "\$#" -lt 4 ]; then
cat <<EOM
This script calls ./visualizer, ./simulator, and the specified controller simultaneously.
All the arguments after the controller will be passed directly to it.
Usage: sh run.sh <controller-executable> <path-to-world.urdf> <path-to-robot.urdf> <robot-name> <extra_controller_args>
EOM
else
trap 'kill %1; kill %2' SIGINT
trap 'kill %1; kill %2' EXIT
./simulator \$2 \$3 \$4 > simulator.log & ./visualizer \$2 \$3 \$4 > visualizer.log & ./"\$@"
# ./visualizer \$2 \$3 \$4 & ./simulator \$2 \$3 \$4 & ./"\$@"
fi
EOF
chmod +x run_controller.sh
fi
cd ..