-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.bash
126 lines (104 loc) · 2.81 KB
/
run.bash
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
126
#!/bin/bash
CUSTOM_JSON=`pwd`/digital/config/ar/custom.json
HAKONIWA_WEB_SERVER_PATH=`pwd`/../hakoniwa-webserver
HAKONIWA_AR_BRIDGE_PATH=`pwd`/../si2024/hakoniwa-ar-bridge
HAKONIWA_PX4SIM_PATH=`pwd`/../hakoniwa-px4sim/hakoniwa
HAKONIWA_SHMPROXY_PATH=bridge/virtual
HAKONIWA_UNITY_APL_PATH=`pwd`/../si2024/hakoniwa-unity-drone-model/DTwinAppleSilicon
export PYTHONPATH="/usr/local/lib/hakoniwa:$PYTHONPATH"
export PYTHONPATH="/usr/local/lib/hakoniwa/py:$PYTHONPATH"
export PATH="/usr/local/bin/hakoniwa:${PATH}"
export LD_LIBRARY_PATH="/usr/local/lib/hakoniwa:${LD_LIBRARY_PATH}"
export DYLD_LIBRARY_PATH="/usr/local/lib/hakoniwa:${DYLD_LIBRARY_PATH}"
if [ -f ~/myenv/bin/activate ]
then
source ~/myenv/bin/activate
PYTHON_BIN=python3.12
else
PYTHON_BIN=python
fi
HAKO_PX4SIM_PID=
HAKO_SHMPROXY_PID=
HAKO_UNITY_PID=
HAKO_WEBSRV_PID=
function kill_process()
{
echo "trapped"
if [ ! -z "$HAKO_SHMPROXY_PID" ]
then
echo "KILLING: shmproxy $HAKO_SHMPROXY_PID"
kill -s TERM "$HAKO_SHMPROXY_PID" || echo "Failed to kill shmproxy"
fi
if [ ! -z "$HAKO_UNITY_PID" ]
then
echo "KILLING: unity $HAKO_UNITY_PID"
kill -s TERM "$HAKO_UNITY_PID" || echo "Failed to kill unity"
fi
if [ ! -z "$HAKO_WEBSRV_PID" ]
then
echo "KILLING: web server $HAKO_WEBSRV_PID"
kill -s TERM "$HAKO_WEBSRV_PID" || echo "Failed to kill web server"
fi
if [ ! -z "$HAKO_PX4SIM_PID" ]
then
echo "KILLING: px4sim $HAKO_PX4SIM_PID"
kill -s TERM "$HAKO_PX4SIM_PID" || echo "Failed to kill px4sim"
fi
exit 0
}
function signal_handler() {
echo "SIGINT"
}
trap signal_handler SIGINT
function activate_px4sim()
{
CURR_DIR=`pwd`
cd $HAKONIWA_PX4SIM_PATH
bash drone-app.bash ${HAKONIWA_UNITY_APL_PATH} config/rc &
HAKO_PX4SIM_PID=$!
cd $CURR_DIR
}
function activate_shmproxy()
{
CURR_DIR=`pwd`
cd $HAKONIWA_SHMPROXY_PATH
./cmake-build/shm-proxy/shm-proxy ShmProxy ${CUSTOM_JSON} 20 &
HAKO_SHMPROXY_PID=$!
cd $CURR_DIR
}
function activate_unity()
{
CURR_DIR=`pwd`
cd $HAKONIWA_UNITY_APL_PATH
cd ..
bash plugin/activate_app.bash DTwinAppleSilicon &
HAKO_UNITY_PID=$!
cd $CURR_DIR
}
function activate_web_server()
{
CURR_DIR=`pwd`
cd $HAKONIWA_WEB_SERVER_PATH
${PYTHON_BIN} server/main.py --asset_name WebServer --config_path config/twin-custom.json --delta_time_usec 20000 &
HAKO_WEBSRV_PID=$!
cd $CURR_DIR
}
function activate_ar_bridge()
{
CURR_DIR=`pwd`
CONFIG_PATH=`pwd`/digital/config/ar/ar_bridge_config.json
cd $HAKONIWA_AR_BRIDGE_PATH
${PYTHON_BIN} asset_lib/main.py --config ${CONFIG_PATH}
cd $CURR_DIR
}
activate_px4sim
sleep 1
activate_unity
sleep 1
activate_shmproxy
sleep 5
hako-cmd start
sleep 1
activate_web_server
activate_ar_bridge
kill_process