-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_livox.sh
executable file
·163 lines (144 loc) · 4.09 KB
/
run_livox.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
set -e
# Default settings
CUDA="on"
IMAGE_NAME="autoware/livox"
TAG_PREFIX="latest"
ROS_DISTRO="melodic"
BASE_ONLY="false"
PRE_RELEASE="off"
AUTOWARE_HOST_DIR=""
USER_ID="$(id -u)"
function usage() {
echo "Usage: $0 [OPTIONS]"
echo " -b,--base-only <AUTOWARE_HOST_DIR> If provided, run the base image only and mount the provided Autoware folder."
echo " Default: Use pre-compiled Autoware image"
echo " -c,--cuda <on|off> Enable Cuda support in the Docker."
echo " Default: $CUDA"
echo " -h,--help Display the usage and exit."
echo " -i,--image <name> Set docker images name."
echo " Default: $IMAGE_NAME"
echo " -p,--pre-release <on|off> Use pre-release image."
echo " Default: $PRE_RELEASE"
echo " -r,--ros-distro <name> Set ROS distribution name."
echo " Default: $ROS_DISTRO"
echo " -s,--skip-uid-fix Skip uid modification step required when host uid != 1000"
echo " -t,--tag-prefix <tag> Tag prefix use for the docker images."
echo " Default: $TAG_PREFIX"
}
# Convert a relative directory path to absolute
function abspath() {
local path=$1
if [ ! -d $path ]; then
exit 1
fi
pushd $path > /dev/null
echo $(pwd)
popd > /dev/null
}
OPTS=`getopt --options b:c:hi:p:r:st: \
--long base-only:,cuda:,help,image-name:,pre-release:,ros-distro:,skip-uid-fix,tag-prefix: \
--name "$0" -- "$@"`
eval set -- "$OPTS"
while true; do
case $1 in
-b|--base-only)
BASE_ONLY="true"
AUTOWARE_HOST_DIR=$(abspath "$2")
shift 2
;;
-c|--cuda)
param=$(echo $2 | tr '[:upper:]' '[:lower:]')
case "${param}" in
"on"|"off") CUDA="${param}" ;;
*) echo "Invalid cuda option: $2"; exit 1 ;;
esac
shift 2
;;
-h|--help)
usage
exit 0
;;
-i|--image-name)
IMAGE_NAME="$2"
shift 2
;;
-p|--pre-release)
param=$(echo $2 | tr '[:upper:]' '[:lower:]')
case "${param}" in
"on"|"off") PRE_RELEASE="${param}" ;;
*) echo "Invalid pre-release option: $2"; exit 1 ;;
esac
shift 2
;;
-r|--ros-distro)
ROS_DISTRO="$2"
shift 2
;;
-s|--skip-uid-fix)
USER_ID=1000
shift 1
;;
-t|--tag-prefix)
TAG_PREFIX="$2"
shift 2
;;
--)
if [ ! -z $2 ];
then
echo "Invalid parameter: $2"
exit 1
fi
break
;;
*)
echo "Invalid option"
exit 1
;;
esac
done
echo "Using options:"
echo -e "\tROS distro: $ROS_DISTRO"
echo -e "\tImage name: $IMAGE_NAME"
echo -e "\tTag prefix: $TAG_PREFIX"
echo -e "\tCuda support: $CUDA"
if [ "$BASE_ONLY" == "true" ]; then
echo -e "\tAutoware Home: $AUTOWARE_HOST_DIR"
fi
echo -e "\tPre-release version: $PRE_RELEASE"
echo -e "\tUID: <$USER_ID>"
SUFFIX=""
RUNTIME=""
XSOCK=/tmp/.X11-unix
XAUTH=$HOME/.Xauthority
SHARED_DOCKER_DIR=/home/autoware/shared_dir
SHARED_HOST_DIR=$HOME/shared_dir
AUTOWARE_DOCKER_DIR=/home/autoware/Autoware
VOLUMES="--volume=$XSOCK:$XSOCK:rw
--volume=$XAUTH:$XAUTH:rw
--volume=$SHARED_HOST_DIR:$SHARED_DOCKER_DIR:rw"
if [ "$BASE_ONLY" == "true" ]; then
SUFFIX=$SUFFIX"-base"
VOLUMES="$VOLUMES --volume=$AUTOWARE_HOST_DIR:$AUTOWARE_DOCKER_DIR "
fi
if [ $CUDA == "on" ]; then
SUFFIX=$SUFFIX"-cuda"
RUNTIME="--runtime=nvidia"
fi
if [ $PRE_RELEASE == "on" ]; then
SUFFIX=$SUFFIX"-rc"
fi
# Create the shared directory in advance to ensure it is owned by the host user
mkdir -p $SHARED_HOST_DIR
IMAGE=$IMAGE_NAME:$TAG_PREFIX
echo "Launching $IMAGE"
docker run \
-it --rm \
$VOLUMES \
--env="XAUTHORITY=${XAUTH}" \
--env="DISPLAY=${DISPLAY}" \
--env="USER_ID=$USER_ID" \
--privileged \
--net=host \
$RUNTIME \
$IMAGE