-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_ros.sh
executable file
·78 lines (66 loc) · 2.22 KB
/
run_ros.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
#!/usr/bin/env bash
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Check for V4L2 devices
V4L2_DEVICES=""
for i in {0..9}; do
if [ -e "/dev/video$i" ]; then
V4L2_DEVICES="$V4L2_DEVICES --device /dev/video$i "
fi
done
# Check for Arduino Uno
ARDUINO_DEVICE=""
if [ -e "/dev/ttyACM0" ]; then
ARDUINO_DEVICE="--device /dev/ttyACM0"
fi
# Check for ESP32
ESP32_DEVICE=""
if [ -e "/dev/ttyUSB0" ]; then
ESP32_DEVICE="--device /dev/ttyUSB0"
fi
# Check for display (X11 forwarding)
DISPLAY_DEVICE=""
if [ -n "$DISPLAY" ]; then
sudo xhost +si:localuser:root
XAUTH=/tmp/.docker.xauth
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
chmod 777 $XAUTH
DISPLAY_DEVICE="-e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH"
fi
# Check if sudo is needed
if id -nG "$USER" | grep -qw "docker"; then
SUDO=""
else
SUDO="sudo"
fi
# Run the container based on architecture
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
cat /proc/device-tree/model > /tmp/nv_jetson_model
set -x
$SUDO docker run --runtime nvidia -it --rm --network host \
--volume /tmp/argus_socket:/tmp/argus_socket \
--volume /etc/enctune.conf:/etc/enctune.conf \
--volume /etc/nv_tegra_release:/etc/nv_tegra_release \
--volume /tmp/nv_jetson_model:/tmp/nv_jetson_model \
--volume $ROOT/jetson-containers/data:/data \
--device /dev/snd \
--device /dev/bus/usb \
$V4L2_DEVICES $DISPLAY_DEVICE $ARDUINO_DEVICE $ESP32_DEVICE \
-v $(pwd):/workspace \
-v /ssd/rosbags:/rosbags \
--workdir /workspace \
${USER}/ros:humble-desktop-l4t-r35.2.1 "$@"
elif [ "$ARCH" = "x86_64" ]; then
set -x
$SUDO docker run --gpus all -it --rm --network=host \
--shm-size=8g \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
--env NVIDIA_DRIVER_CAPABILITIES=all \
--volume $ROOT/jetson-containers/data:/data \
$V4L2_DEVICES $DISPLAY_DEVICE $ARDUINO_DEVICE $ESP32_DEVICE \
-v $(pwd):/workspace \
-v /ssd/rosbags:/rosbags \
--workdir /workspace \
${USER}/ros:humble-desktop-l4t-r35.2.1 "$@"
fi