Skip to content

Commit a5429b0

Browse files
committed
Adjust build
1 parent 173efca commit a5429b0

1 file changed

Lines changed: 282 additions & 3 deletions

File tree

codebotler_ws/docker/Dockerfile

Lines changed: 282 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,294 @@
33
# - Docker container must match jetpack version installed on Jetson
44
# - Image list: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base/tags
55
# - ROS2 Humble is used for Jetson Orin OpenCV and Python version compatibility
6-
# - This image builds off of the cobot_ws image
76
# =============================================================================
87
# JetPack container: includes CUDA, cuDNN, TensorRT, VPI, Jetson Multimedia, and so on
9-
FROM cobot_ws AS base
8+
ARG BASE_IMAGE=nvcr.io/nvidia/l4t-jetpack:r36.4.0
9+
# ML container: includes TensorFlow, PyTorch, JupyterLab, and other popular ML and data science frameworks such as scikit-learn, scipy, and Pandas pre-installed in a Python environment.
10+
#ARG BASE_IMAGE=nvcr.io/nvidia/l4t-ml:r36.2.0-py3
11+
FROM ${BASE_IMAGE}
1012

11-
ARG uid
13+
ARG ros_distro=humble
1214
ARG gid
15+
ARG uid
1316
ARG username
17+
18+
# Set non-interactive installation
19+
ENV DEBIAN_FRONTEND=noninteractive
20+
21+
# Setup Locale
22+
RUN apt-get update && apt-get install -y locales \
23+
&& locale-gen en_US.UTF-8
24+
ENV LANG=en_US.UTF-8
25+
ENV LANGUAGE=en_US:en
26+
ENV LC_ALL=en_US.UTF-8
27+
28+
# Install base dependencies
29+
RUN apt-get update && apt-get install -y \
30+
build-essential \
31+
cmake \
32+
git \
33+
wget \
34+
curl \
35+
gnupg2 \
36+
lsb-release \
37+
software-properties-common \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
# Setup Isaac ROS2 APT repository
41+
RUN wget -qO - https://isaac.download.nvidia.com/isaac-ros/repos.key | apt-key add - && \
42+
grep -qxF "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" /etc/apt/sources.list || \
43+
echo "deb https://isaac.download.nvidia.com/isaac-ros/release-3 $(lsb_release -cs) release-3.0" | tee -a /etc/apt/sources.list
44+
45+
# Setup Offical ROS2 APT repository
46+
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
47+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
48+
49+
# Install Core ROS 2 Humble packages
50+
RUN apt-get update && apt-get install -y \
51+
ros-humble-desktop-full \
52+
ros-dev-tools \
53+
&& rm -rf /var/lib/apt/lists/*
54+
55+
# Install Isaac ROS common dependencies and VPI
56+
# Note: VPI libraries are also part of the Jetson host system and will be mounted.
57+
# This ensures any additional dependencies are met inside the container.
58+
RUN apt-get update && apt-get install -y \
59+
ros-humble-isaac-ros-common \
60+
&& rm -rf /var/lib/apt/lists/*
61+
62+
# Initialize rosdep
63+
RUN rosdep init && \
64+
rosdep update
65+
66+
# =============================================================================
67+
# Realsense
68+
# =============================================================================
69+
#RUN apt-get update && apt-get install -y \
70+
# kmod \
71+
# && rm -rf /var/lib/apt/lists/*
72+
#COPY scripts/install_realsense_library.sh /tmp/install_realsense_library.sh
73+
#COPY external/librealsense /tmp/librealsense
74+
#RUN /tmp/install_realsense_library.sh && rm /tmp/install_realsense_library.sh
75+
76+
# =============================================================================
77+
# UT AUTOmata dependencies
78+
# =============================================================================
79+
RUN apt-get update && apt-get install -y \
80+
libgoogle-glog-dev \
81+
libgflags-dev \
82+
liblua5.1-0-dev \
83+
libqt5websockets5-dev \
84+
libqt5opengl5-dev \
85+
&& rm -rf /var/lib/apt/lists/*
86+
87+
## =============================================================================
88+
## GStreamer (for camera streaming)
89+
## =============================================================================
90+
#RUN apt-get update && apt-get install -y \
91+
# gstreamer1.0-plugins-base \
92+
# gstreamer1.0-plugins-good \
93+
# gstreamer1.0-plugins-bad \
94+
# gstreamer1.0-plugins-ugly \
95+
# gstreamer1.0-libav \
96+
# gstreamer1.0-tools \
97+
# gstreamer1.0-x \
98+
# && rm -rf /var/lib/apt/lists/*
99+
100+
# =============================================================================
101+
# EGL, OpenGL libraries (for GUI applications)
102+
# =============================================================================
103+
RUN apt-get update && apt-get install -y \
104+
libegl1 \
105+
libegl1-mesa \
106+
libgles2-mesa \
107+
libgles2 \
108+
libapr1-dev \
109+
libglvnd-dev \
110+
libgl1-mesa-glx \
111+
libgl1-mesa-dri \
112+
mesa-utils-extra \
113+
&& rm -rf /var/lib/apt/lists/*
114+
115+
# =============================================================================
116+
# Install Kinect SDK
117+
# =============================================================================
118+
RUN apt-get update && apt-get install -y \
119+
libgtk-3-dev \
120+
build-essential \
121+
git \
122+
cmake \
123+
libssl-dev \
124+
libsoundio-dev \
125+
libjpeg-dev \
126+
libturbojpeg-dev \
127+
ninja-build \
128+
&& rm -rf /var/lib/apt/lists/*
129+
130+
# Install Deps
131+
# Define variables
132+
ENV SDK_VERSION="1.4.2"
133+
ENV ARCH="arm64"
134+
ENV DEB_PACKAGE="libk4a1.4_${SDK_VERSION}_${ARCH}.deb"
135+
ENV DEB_URL="https://packages.microsoft.com/ubuntu/18.04/multiarch/prod/pool/main/libk/libk4a1.4/${DEB_PACKAGE}"
136+
137+
# Install proprietary depth engine
138+
RUN mkdir -p /tmp/k4a_deps && cd /tmp/k4a_deps && \
139+
wget ${DEB_URL} && \
140+
ar x "${DEB_PACKAGE}" && \
141+
ls -lah . && \
142+
tar -zxf data.tar.gz && \
143+
# Copy the depthengine to the Azure Kinect build directory
144+
cp /tmp/k4a_deps/usr/lib/aarch64-linux-gnu/libk4a1.4/libdepthengine.so.2.0 /usr/local/lib/ && \
145+
ldconfig && \
146+
# Clean up
147+
cd /tmp && \
148+
rm -rf /tmp/k4a_deps
149+
150+
# Build SDK from source
151+
RUN cd /tmp && \
152+
git clone --branch v1.4.2 https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git --recurse-submodules
153+
COPY patches/kinect-hmac-fix.patch /tmp/Azure-Kinect-Sensor-SDK/kinect-hmac-fix.patch
154+
COPY patches/kinect-ssl.patch /tmp/Azure-Kinect-Sensor-SDK/kinect-ssl.patch
155+
COPY patches/ebml.patch /tmp/Azure-Kinect-Sensor-SDK/patches/ebml.patch
156+
COPY patches/k4a.patch /tmp/Azure-Kinect-Sensor-SDK/patches/k4a.patch
157+
COPY patches/examples.patch /tmp/Azure-Kinect-Sensor-SDK/patches/examples.patch
158+
RUN openssl version
159+
RUN cd /tmp/Azure-Kinect-Sensor-SDK && \
160+
cp scripts/99-k4a.rules /etc/udev/rules.d/ && \
161+
patch -p1 -i kinect-hmac-fix.patch && \
162+
patch -p1 -i kinect-ssl.patch && \
163+
patch -p1 -i patches/ebml.patch && \
164+
patch -p1 -i patches/k4a.patch && \
165+
patch -p1 -i patches/examples.patch && \
166+
head -n20 tools/k4aviewer/k4adepthpixelcolorizer.h && \
167+
mkdir build && cd build && \
168+
cmake -GNinja -DCMAKE_C_FLAGS="-Wno-deprecated-declarations -Wno-error=discarded-qualifiers" .. && \
169+
ninja && \
170+
sudo ninja install && \
171+
rm -rf /tmp/Azure-Kinect-Sensor-SDK
172+
173+
COPY scripts/ros2_nav_deps.sh /tmp/ros2_nav_deps.sh
174+
RUN /tmp/ros2_nav_deps.sh && rm /tmp/ros2_nav_deps.sh
175+
176+
COPY scripts/ros2_deps.sh /tmp/ros2_deps.sh
177+
RUN /tmp/ros2_deps.sh && rm /tmp/ros2_deps.sh
178+
179+
COPY scripts/install_livox_lidar.sh /tmp/install_livox_lidar.sh
180+
RUN /tmp/install_livox_lidar.sh && rm /tmp/install_livox_lidar.sh
181+
182+
# =============================================================================
183+
# TODO: move up deep learning deps
184+
# =============================================================================
185+
RUN pip3 install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu126
186+
187+
# So we can detect if we are in a container
188+
ENV CONTAINER_NAME=cobot_ws
189+
190+
# =============================================================================
191+
# Install Kinova python API
192+
# =============================================================================
193+
RUN python3 -m pip install --no-cache-dir \
194+
protobuf==3.20.0 \
195+
deprecated==1.2.7 \
196+
paho-mqtt==1.6.1 \
197+
mypy \
198+
mypy-protobuf \
199+
types-protobuf
200+
RUN wget https://artifactory.kinovaapps.com:443/artifactory/generic-public/kortex/API/2.5.0/kortex_api-2.5.0.post6-py3-none-any.whl \
201+
&& python3 -m pip install --no-deps kortex_api-2.5.0.post6-py3-none-any.whl \
202+
&& rm kortex_api-2.5.0.post6-py3-none-any.whl
203+
RUN apt-get update && apt-get install -y --no-install-recommends \
204+
libhidapi-hidraw0 \
205+
libhidapi-libusb0 \
206+
libusb-1.0-0 \
207+
&& rm -rf /var/lib/apt/lists/*
208+
RUN python3 -m pip install --no-cache-dir hidapi
209+
210+
# =============================================================================
211+
# Spacemouse/Joystick Depdencies
212+
# =============================================================================
213+
RUN apt-get update && apt-get install -y \
214+
libhidapi-hidraw0 \
215+
joystick \
216+
&& rm -rf /var/lib/apt/lists/*
217+
218+
# ============================================================================
219+
# Kinova Vision dependencies
220+
# ============================================================================
221+
RUN apt-get update && apt-get install -y \
222+
gstreamer1.0-tools \
223+
gstreamer1.0-libav \
224+
libgstreamer1.0-dev \
225+
libgstreamer-plugins-base1.0-dev \
226+
libgstreamer-plugins-good1.0-dev \
227+
gstreamer1.0-plugins-good \
228+
gstreamer1.0-plugins-base \
229+
&& rm -rf /var/lib/apt/lists/*
230+
231+
# ============================================================================
232+
# Kinova ROS dependencies
233+
# ============================================================================
234+
RUN apt-get update && apt-get install -y \
235+
libcap-dev \
236+
libdw-dev \
237+
&& rm -rf /var/lib/apt/lists/*
238+
239+
# remove, if installed, the pointcloud_to_laserscan package
240+
RUN apt-get remove --purge -y ros-$ROS_DISTRO-pointcloud-to-laserscan || true
241+
242+
# =============================================================================
243+
# User Creation and Configuration
244+
# =============================================================================
245+
ENV UID=$uid
246+
ENV GID=$gid
247+
ENV USERNAME=$username
248+
ENV ROS_DISTRO=$ros_distro
249+
250+
# Create user and group, then configure sudo
251+
RUN set -e && \
252+
# Create group if it doesn't exist
253+
getent group ${GID} || groupadd -g ${GID} ${USERNAME} && \
254+
# Handle user creation/modification
255+
if id ${UID} >/dev/null 2>&1; then \
256+
# User with this UID exists, modify it
257+
existing_user=$(id -nu ${UID}) && \
258+
usermod -l ${USERNAME} -d /home/${USERNAME} -m $existing_user 2>/dev/null || true && \
259+
usermod -g ${GID} ${USERNAME} 2>/dev/null || true; \
260+
else \
261+
# Create new user
262+
useradd -u ${UID} -g ${GID} -m -s /bin/bash ${USERNAME}; \
263+
fi && \
264+
# Ensure home directory exists and has correct ownership
265+
mkdir -p /home/${USERNAME} && \
266+
chown -R ${UID}:${GID} /home/${USERNAME} && \
267+
# Add to sudo group and configure passwordless sudo
268+
usermod -aG sudo ${USERNAME} && \
269+
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USERNAME} && \
270+
chmod 0440 /etc/sudoers.d/${USERNAME} && \
271+
visudo -c && \
272+
# Add the user to the video group for access to video devices
273+
usermod -aG video ${USERNAME}
274+
275+
RUN echo "export PATH=/home/${USERNAME}/.local/bin/:${PATH}" >> /home/${USERNAME}/.bash_profile && \
276+
echo "export LC_ALL=C.UTF-8" >> /home/${USERNAME}/.bash_profile && \
277+
echo "export LANG=C.UTF-8" >> /home/${USERNAME}/.bash_profile && \
278+
echo "alias killros2='killall -9 ros2 _ros2_daemon rviz2 gzserver robot_state_publisher gzclient controller_server lifecycle_manager'" >> /home/${USERNAME}/.bash_profile && \
279+
echo "source \"/opt/ros/${ROS_DISTRO}/setup.bash\" --" >> /home/${USERNAME}/.bash_profile && \
280+
echo "source \"/home/${USERNAME}/cobot_ws/install/setup.bash\" --" >> /home/${USERNAME}/.bash_profile && \
281+
echo "export ROS_VERSION=2" >> /home/${USERNAME}/.bash_profile && \
282+
echo "export PS1='\\[\\e[0;32m\\][docker]:\\u@\\h:\\w\\$ \\[\\e[0m\\]'" >> /home/${USERNAME}/.bash_profile && \
283+
echo "export LD_LIBRARY_PATH=/usr/local/lib/python3.10/dist-packages/torch/lib:\$LD_LIBRARY_PATH" >> /home/${USERNAME}/.bash_profile && \
284+
echo "cd /home/${USERNAME}/cobot_ws" >> /home/${USERNAME}/.bash_profile
285+
286+
287+
# =============================================================================
288+
# Switch to User Context
289+
# =============================================================================
290+
14291
USER $username
292+
ENV HOME=/home/$username
293+
WORKDIR /home/$username
15294

16295
# Set environment variable for Miniconda installation directory
17296
ENV CONDA_DIR /home/$username/.miniconda3

0 commit comments

Comments
 (0)