Skip to content

Commit a29eaca

Browse files
committed
fix merging conflicts.
Signed-off-by: Liu, Wei Zhi <[email protected]>
2 parents 74d3686 + ccca78e commit a29eaca

File tree

3 files changed

+215
-153
lines changed

3 files changed

+215
-153
lines changed
+37-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ros2 openvino toolkit env master f1b1ca4d914186a1881b87f103be9c6e910c9d80
22

3-
from osrf/ros:humble-desktop
3+
FROM osrf/ros:humble-desktop
44

55
# Set non-interactive mode for APT
66
ENV DEBIAN_FRONTEND=noninteractive
@@ -15,58 +15,55 @@ LABEL maintainer="Jayabalaji Sathiyamoorthi <[email protected]
1515

1616
SHELL ["/bin/bash", "-c"]
1717

18-
# install OpenVINO 2025.0.0 / 2023.3 LTS
19-
#https://docs.openvino.ai/2025/get-started/install-openvino.html?PACKAGE=OPENVINO_BASE&VERSION=v_2025_0_0&OP_SYSTEM=LINUX&DISTRIBUTION=APT
20-
RUN apt update \
21-
&& apt install curl wget gnupg2 lsb-release
22-
RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
23-
&& apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
24-
#RUN echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu22 main" | tee /etc/apt/sources.list.d/intel-openvino-2025.list
25-
RUN echo "deb https://apt.repos.intel.com/openvino/2024 ubuntu22 main" | tee /etc/apt/sources.list.d/intel-openvino-2024.list
26-
#RUN echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu22 main" | tee /etc/apt/sources.list.d/intel-openvino-2023.list
18+
# Define build argument for OpenVINO version (2025.0.0 , 2024.6.0, 2023.3.0)
19+
ARG OPENVINO_VERSION=2025.0.0
2720

28-
RUN apt update \
29-
&& apt-cache search openvino \
30-
# && apt-get install -y openvino-2025.0.0
31-
&& apt-get install -y openvino-2024.2.0
32-
# && apt-get install -y openvino-2023.3.0
21+
# Extract the major version from the full version string
22+
ENV OPENVINO_MAJOR_VERSION=${OPENVINO_VERSION%%.*}
3323

34-
# workaround to fetch librealsense2-dkms via ECI repo
35-
RUN bash -c 'echo "deb [trusted=yes] http://wheeljack.ch.intel.com/apt-repos/ECI/$(lsb_release -sc) isar main" > /etc/apt/sources.list.d/eci.list'
36-
RUN bash -c 'echo "deb-src [trusted=yes] http://wheeljack.ch.intel.com/apt-repos/ECI/$(lsb_release -sc) isar main" >> /etc/apt/sources.list.d/eci.list'
37-
RUN bash -c 'echo -e "Package: *\nPin: origin wheeljack.ch.intel.com\nPin-Priority: 1000" > /etc/apt/preferences.d/isar'
38-
RUN bash -c 'echo "Acquire::http::Proxy \"http://proxy-dmz.intel.com:912\"; Acquire::https::Proxy \"http://proxy-dmz.intel.com:912\"; Acquire::http::Proxy::wheeljack.ch.intel.com DIRECT;" >> /etc/apt/apt.conf.d/proxy.conf'
39-
40-
RUN apt-get update \
41-
&& apt-get install -y librealsense2-dkms
24+
# install OpenVINO and dependencies
25+
# https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_apt.html
26+
RUN apt update && \
27+
apt install -y --no-install-recommends wget curl gnupg2 lsb-release software-properties-common apt-transport-https nano && \
28+
wget -qO- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor -o /etc/apt/trusted.gpg.d/intel.gpg && \
29+
echo "deb https://apt.repos.intel.com/openvino/${OPENVINO_MAJOR_VERSION} ubuntu22 main" | tee /etc/apt/sources.list.d/intel-openvino-${OPENVINO_MAJOR_VERSION}.list && \
30+
apt update && \
31+
apt-get install -y openvino-${OPENVINO_VERSION} && \
32+
rm -rf /var/lib/apt/lists/*
4233

4334
# install librealsense2
4435
# Reference : https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
45-
RUN apt-get install -y --no-install-recommends \
46-
software-properties-common \
47-
apt-transport-https
48-
49-
RUN mkdir -p /etc/apt/keyrings
50-
RUN curl -sSf https://librealsense.intel.com/Debian/librealsense.pgp | tee /etc/apt/keyrings/librealsense.pgp > /dev/null
51-
52-
RUN echo "deb [signed-by=/etc/apt/keyrings/librealsense.pgp] https://librealsense.intel.com/Debian/apt-repo `lsb_release -cs` main" | \
53-
tee /etc/apt/sources.list.d/librealsense.list
54-
RUN apt-get update
55-
RUN apt-get install -y --no-install-recommends \
56-
# librealsense2-dkms \ # Houston, this is not available in kernel 6.8
36+
RUN mkdir -p /etc/apt/keyrings && \
37+
curl -sSf https://librealsense.intel.com/Debian/librealsense.pgp | tee /etc/apt/keyrings/librealsense.pgp > /dev/null && \
38+
echo "deb [signed-by=/etc/apt/keyrings/librealsense.pgp] https://librealsense.intel.com/Debian/apt-repo `lsb_release -cs` main" | \
39+
tee /etc/apt/sources.list.d/librealsense.list && \
40+
apt-get update && \
41+
apt-get install -y --no-install-recommends \
5742
librealsense2-utils \
5843
librealsense2-dev \
5944
librealsense2-dbg \
45+
libgflags-dev \
6046
&& rm -rf /var/lib/apt/lists/*
6147

48+
#Install sudo and setup ubuntu user and password to "ubuntu"
49+
RUN apt-get update && apt-get install -y sudo && \
50+
echo "root:ubuntu" | chpasswd && \
51+
useradd -m -s /bin/bash ubuntu && \
52+
echo "ubuntu:ubuntu" | chpasswd && \
53+
usermod -aG sudo ubuntu && \
54+
rm -rf /var/lib/apt/lists/*
55+
56+
# Set working directory and Switch to user "ubuntu"
57+
WORKDIR /home/ubuntu
58+
USER ubuntu
59+
6260
# build ros2 openvino toolkit
63-
WORKDIR /root
6461
RUN mkdir -p ros2_ws/src
65-
WORKDIR /root/ros2_ws/src
62+
WORKDIR /home/ubuntu/ros2_ws/src
6663
RUN git clone https://github.com/intel/ros2_object_msgs.git
67-
RUN git clone -b ros2 https://github.com/jb-balaji/ros2_openvino_toolkit.git
64+
#change the branch before merge
65+
RUN git clone -b openvino_2025 https://github.com/jb-balaji/ros2_openvino_toolkit.git
6866
RUN git clone -b humble https://github.com/ros-perception/vision_opencv.git
69-
WORKDIR /root/ros2_ws
67+
WORKDIR /home/ubuntu/ros2_ws
7068
RUN source /opt/ros/humble/setup.bash \
7169
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
72-
Original file line numberDiff line numberDiff line change
@@ -1 +1,120 @@
1-
To Do
1+
# ROS2 OpenVINO Toolkit Docker Image
2+
3+
This repository contains a Dockerfile for building a Docker image with ROS2 and the OpenVINO toolkit. The image is based on the `osrf/ros:humble-desktop` base image and includes additional tools and libraries for working with OpenVINO and librealsense.
4+
5+
## Features
6+
7+
- ROS2 Humble Desktop
8+
- OpenVINO Toolkit (version configurable supports 2025.0.0, 2024.x, 2023.3)
9+
- librealsense2
10+
- User setup with `sudo` privileges
11+
12+
## Prerequisites
13+
14+
- Docker installed on your system
15+
- Network connection & correct proxy settings for downloading base images and dependencies
16+
17+
## Building the Docker Image
18+
19+
To build the Docker image, use the following command. You can specify the OpenVINO version using the `--build-arg` option. The default version is `2025.0.0`.
20+
21+
```bash
22+
docker build --build-arg OPENVINO_VERSION=2025.0.0 -t ros2_openvino_image .
23+
24+
```
25+
26+
Replace `2025.0.0` with the desired OPENVINO version if needed, for example to build `OpenVINO 2024.6`, use the following command,
27+
28+
```bash
29+
docker build --build-arg OPENVINO_VERSION=2024.6.0 -t ros2_openvino_image .
30+
31+
```
32+
33+
if you are behind a proxy server use the following command,
34+
35+
```bash
36+
docker build --build-arg "HTTP_PROXY=http://<your-proxy.com>:<your-port>" --build-arg OPENVINO_VERSION=2024.6.0 -t ros2_openvino_image .
37+
38+
```
39+
## Download the Models from OpenVINO Model Zoo (OMZ)
40+
OMZ tools are provided for downloading and converting OMZ models in OpenVINO 202x versions.</br>
41+
Refer to: [OMZ-tool_guide](https://pypi.org/project/openvino-dev/)
42+
Refer to: [OMZ Models](https://github.com/openvinotoolkit/open_model_zoo/tree/2024.6.0/models)
43+
44+
```bash
45+
omz_downloader --print_all
46+
```
47+
48+
* Download the optimized Intermediate Representation (IR) of model (execute once), for example:
49+
50+
```bash
51+
omz_downloader --list <ros2-ws>/src/ros2_openvino_toolkit/data/model_list/download_model.lst -o /opt/openvino_toolkit/models/
52+
```
53+
54+
## Running the Docker Container
55+
56+
To run the Docker container, use the following command:
57+
58+
```bash
59+
docker run -it --rm --name ros2_openvino_container ros2_openvino_image
60+
61+
```
62+
63+
To run the Docker container with GUI support, use the following command:
64+
65+
```bash
66+
docker run -itd -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev --privileged=true --name ros2_openvino_container ros2_openvino_image
67+
68+
```
69+
70+
To run the Docker container with the volumes containing models and images, use the following command:
71+
72+
```bash
73+
docker run -itd -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -v /opt:/opt -v /data:/data --privileged=true --name ros2_openvino_container ros2_openvino_image
74+
```
75+
76+
#### Explanation of Options
77+
78+
* -itd: Combines three flags:
79+
80+
-i: Runs the container in interactive mode, keeping the standard input open.
81+
-t: Allocates a pseudo-TTY, which is useful for interactive applications.
82+
-d: Runs the container in detached mode, allowing it to run in the background.
83+
84+
* -e DISPLAY=$DISPLAY
85+
86+
###### Sets the DISPLAY environment variable inside the container to match the host's DISPLAY variable. This is necessary for GUI applications to display on the host's screen.
87+
88+
* -v /tmp/.X11-unix:/tmp/.X11-unix
89+
90+
###### Mounts the X11 Unix socket from the host to the container. This is required for GUI applications to communicate with the X server on the host.
91+
92+
* -v /dev:/dev
93+
94+
###### Mounts the /dev directory from the host to the container, allowing the container to access hardware devices. This is often necessary for applications that interact with hardware, such as cameras or GPUs.
95+
96+
* -v /opt:/opt
97+
98+
###### Mounts the /opt directory from the host to the container, allowing the container to access the models installed from OpenVINO Model Zoo.
99+
100+
* -v /data:/data
101+
102+
###### Mounts the /data directory from the host to the container, that contains the images and labels. Replace this with the folder of your images and labels.
103+
104+
* --privileged=true
105+
106+
###### Grants the container extended privileges, allowing it to access all devices on the host and perform operations that are typically restricted. This is necessary for certain applications that require direct hardware access.
107+
108+
* --name ros2_openvino_container
109+
110+
###### Assigns the name ros2_openvino_container to the running container, making it easier to reference in subsequent Docker commands.
111+
112+
* ros2_openvino_image
113+
114+
###### Specifies the name of the Docker image to run. Replace this with the actual name of your built image if it differs.
115+
116+
### Notes
117+
118+
* Ensure that your host's X11 server is configured to allow connections from the Docker container. You may need to run xhost +local:docker on the host to permit this.
119+
120+
* The --privileged flag provides the container with elevated permissions, which can pose security risks. Use it only when necessary and understand the implications.

0 commit comments

Comments
 (0)