-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bash
More file actions
executable file
·129 lines (114 loc) · 3.85 KB
/
Copy pathrun.bash
File metadata and controls
executable file
·129 lines (114 loc) · 3.85 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
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
#!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
IMAGE_REPOSITORY="${JACKAL_AUTONOMY_REPOSITORY:-kumarrobotics/jackal_autonomy}"
IMAGE="${JACKAL_AUTONOMY_IMAGE:-${IMAGE_REPOSITORY}:${JACKAL_AUTONOMY_TAG:-latest}}"
USER_WS="$PROJECT_DIR/ws"
DATA_DIR="$PROJECT_DIR/data"
ROS_DIR="$PROJECT_DIR/.ros_docker"
BASHRC_HOST="$PROJECT_DIR/bashrc"
ZED_CONFIG="$DATA_DIR/configs/zed2i.yaml"
ZED_SETTINGS="${JACKAL_AUTONOMY_ZED_SETTINGS:-$DATA_DIR/configs/usr/local/zed/settings}"
usage() {
echo "Usage: $0 [-t|--tag TAG]"
}
while [ "$#" -gt 0 ]; do
case "$1" in
-t|--tag)
if [ "$#" -lt 2 ] || [ -z "$2" ]; then
echo "ERROR: $1 requires a tag."
usage
exit 2
fi
IMAGE="${IMAGE_REPOSITORY}:$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unknown argument: $1"
usage
exit 2
;;
esac
done
if [ "$(id -u)" -ne 1000 ]; then
echo "ERROR: This script must be run by the UID-1000 host user."
echo " Current UID: $(id -u), current GID: $(id -g)"
exit 1
fi
if [ ! -d "$USER_WS/src/jackal_nav2" ] || [ ! -d "$USER_WS/src/jackal_serial" ]; then
echo "ERROR: Workspace is missing or incomplete: $USER_WS"
echo "Run ./sync_workspace.bash before starting the container."
exit 2
fi
if [ ! -d "$ZED_SETTINGS" ]; then
echo "ERROR: ZED settings directory is missing: $ZED_SETTINGS"
exit 2
fi
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
echo "ERROR: Image is not available locally: $IMAGE"
echo "Build it with ./build.bash."
exit 3
fi
XAUTH_FILE="/tmp/.jackal_autonomy.docker.xauth"
touch "$XAUTH_FILE"
if command -v xauth >/dev/null 2>&1 && [ -n "${DISPLAY:-}" ]; then
xauth_list="$(xauth nlist "${DISPLAY}" 2>/dev/null | sed -e 's/^..../ffff/' || true)"
if [ -n "$xauth_list" ]; then
echo "$xauth_list" | xauth -f "$XAUTH_FILE" nmerge -
fi
fi
chmod a+r "$XAUTH_FILE"
echo -e "\033[1;35mRUNNING DOCKER IMAGE: \033[0m$IMAGE"
echo -e "\033[1;35mUSER WORKSPACE: \033[0m$USER_WS"
echo -e "\033[1;35mDATA DIR: \033[0m$DATA_DIR"
echo -e "\033[1;35mROS DIR: \033[0m$ROS_DIR"
echo -e "\033[1;35mBASHRC HOST: \033[0m$BASHRC_HOST"
docker_args=(
run
--gpus "${JACKAL_AUTONOMY_GPUS:-all}"
-u 1000
--mount "type=bind,src=$ZED_SETTINGS,dst=/usr/local/zed/settings,readonly"
-it
--workdir /home/dcist
--privileged
-e "DISPLAY=${DISPLAY:-}"
-e QT_X11_NO_MITSHM=1
-e "XAUTHORITY=$XAUTH_FILE"
--mount "type=bind,src=$USER_WS,dst=/home/dcist/dcist_ws"
--mount "type=bind,src=$DATA_DIR,dst=/home/dcist/data"
--mount "type=bind,src=$ROS_DIR,dst=/home/dcist/.ros"
--mount "type=bind,src=$BASHRC_HOST,dst=/home/dcist/.bashrc_host,readonly"
--mount "type=bind,src=$ZED_CONFIG,dst=/home/dcist/dcist_ws/src/zed-ros2-wrapper/zed_wrapper/config/zed2i.yaml,readonly"
--mount "type=bind,src=$XAUTH_FILE,dst=$XAUTH_FILE,readonly"
--volume /tmp/.X11-unix:/tmp/.X11-unix
--volume /etc/localtime:/etc/localtime:ro
--volume /dev:/dev
--network host
--hostname dcist
--add-host dcist:127.0.0.1
--add-host "dcist:${DCIST_HOST_IP:-192.168.8.100}"
--security-opt seccomp=unconfined
--group-add dialout
--rm
)
if input_gid="$(getent group input | cut -d: -f3)" && [ -n "$input_gid" ]; then
docker_args+=(--group-add "$input_gid")
fi
if video_gid="$(getent group video | cut -d: -f3)" && [ -n "$video_gid" ]; then
docker_args+=(--group-add "$video_gid")
fi
if [ -f "${HOME}/.bash_history" ]; then
docker_args+=(--mount "type=bind,src=${HOME}/.bash_history,dst=/home/dcist/.bash_history")
fi
if [ -d "/media/${USER}" ]; then
docker_args+=(--mount "type=bind,src=/media/${USER},dst=/media/dcist")
fi
if [ -n "${CLEARPATH_DIR:-}" ] && [ -d "$CLEARPATH_DIR" ]; then
docker_args+=(--mount "type=bind,src=$CLEARPATH_DIR,dst=/etc/clearpath,readonly")
fi
docker_args+=("$IMAGE")
docker "${docker_args[@]}"