forked from unitreerobotics/unitree_mujoco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bash
More file actions
executable file
·50 lines (37 loc) · 1.33 KB
/
setup.bash
File metadata and controls
executable file
·50 lines (37 loc) · 1.33 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
BASE_IMAGE=unitree_mujoco_base
IMAGE=unitree_mujoco
CONTAINER=$IMAGE
WORKDIR=$PWD
COUNT=$(docker ps | grep "$CONTAINER" | wc -l)
if [ "$COUNT" -eq 0 ]; then
if nvidia-container-toolkit --version &>/dev/null; then
ROCKER_NVIDIA="--nvidia"
DOCKER_NVIDIA="--gpus all"
else
ROCKER_NVIDIA="--devices /dev/dri"
DOCKER_NVIDIA="--device=/dev/dri"
fi
image_exists=$(docker images -q "$IMAGE")
if [ -z "$image_exists" ]; then
rocker $ROCKER_NVIDIA --x11 --user --home --nocleanup \
--image-name $IMAGE \
--name $CONTAINER \
$BASE_IMAGE "sleep 0"
docker commit $CONTAINER $IMAGE
docker container remove $CONTAINER
fi
docker create -it -v /home/$USER:/home/$USER --name $CONTAINER \
-h $CONTAINER \
$DOCKER_NVIDIA -e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 \
-e XAUTHORITY=/tmp/.$IMAGE.xauth -v /tmp/.$IMAGE.xauth:/tmp/.$IMAGE.xauth \
-v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/localtime:/etc/localtime:ro $IMAGE \
bash
docker container start $CONTAINER
fi
docker exec -w `pwd` -it "$CONTAINER" /ros_entrypoint.sh bash --rcfile /opt/ros/$DISTRO/setup.bash
INSTANCES=$(docker exec "$CONTAINER" bash -c "ps -e | grep bash | wc -l")
if [ "$INSTANCES" -eq 2 ]; then
docker commit $CONTAINER $IMAGE
docker container stop $CONTAINER
docker container remove $CONTAINER
fi