-
Notifications
You must be signed in to change notification settings - Fork 2
/
runDrcsimDocker.sh
executable file
·64 lines (53 loc) · 1.84 KB
/
runDrcsimDocker.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
#!/usr/bin/env bash
DUID=$((UID%256))
IP=${IPADDR:-172.16.$DUID.$DUID}
# if [[ "$(docker images -q drcsim:$DUID 2> /dev/null)" == "" ]]; then
docker build -t drcsim:$DUID --build-arg ip=$IP .
# fi
if [[ "$(docker network ls | grep docker_bridge_$DUID 2> /dev/null)" == "" ]]; then
echo "creating network bridge for docker image"
docker network create --subnet=172.16.$DUID.0/24 --driver=bridge docker_bridge_$DUID
fi
echo "running drcsim 0.11 docker container"
# Gazebo won't start gpurayplugin without display
XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
if [ ! -f /tmp/.docker.xauth ]
then
export XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
fi
DISPLAY="${DISPLAY:-:0}"
# Use lspci to check for the presence of an nvidia graphics card
has_nvidia=`lspci | grep -i nvidia | wc -l`
# Set docker gpu parameters
if [ ${has_nvidia} -gt 0 ]
then
# check if nvidia-modprobe is installed
if ! which nvidia-modprobe > /dev/null
then
echo nvidia-docker-plugin requires nvidia-modprobe
echo please install nvidia-modprobe
exit -1
fi
fi
printf "IP address is $IP \nROS master URI : http://$IP:11311 \nGazebo master URI : http://$IP:11345\n"
docker run --rm --name drcsim_${USER} \
-e DISPLAY=unix$DISPLAY \
--net=docker_bridge_$DUID \
--ip=$IP \
-e XAUTHORITY=/tmp/.docker.xauth \
--privileged \
-e ROS_MASTER_URI=http://$IP:11311 \
-e ROS_IP=$IP \
--device /dev/dri \
-v /etc/localtime:/etc/localtime:ro \
-v $NVIDIA_LIB:/usr/local/nvidia/lib64 \
-v $NVIDIA_BIN:/usr/local/nvidia/bin \
-v $NVIDIA_LIB32:/usr/local/nvidia/lib \
-v /dev/log:/dev/log \
-v "/tmp/.docker.xauth:/tmp/.docker.xauth" \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--ulimit rtprio=99 \
drcsim:$DUID
# --runtime=nvidia \