我在映射 USB 输入以用于 Docker cointeiner 时遇到了问题。我想使用连接到 USB 端口的 KinectV2,我试过:xhost +docker run --rm -it --user ros -v /dev:/dev --
我在映射 USB 输入以用于 Docker cointeiner 时遇到了问题。我想使用连接到 USB 端口的 KinectV2,我尝试过:
xhost +
docker run --rm -it --user ros -v /dev:/dev --device-cgroup-rule='c *:* rmw' -v /run/udev:/run/udev --ipc=host pu:v4 bash
当我运行 lsusb 时,在 Docker 内部
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
当我运行 lsusb 时,docker 外面的 Kinect 被视为:
Bus 004 Device 002: ID 045e:02c4 Microsoft Corp. Xbox NUI Sensor
以下是我的 Dockerfile:
FROM osrf/ros:noetic-desktop
ARG ROS_DISTRO=noetic
ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config
# Set up sudo
RUN apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/*
# install ros packages
RUN apt-get update && apt-get install -y &&\
apt-get install python3-pip -y && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install build-essential cmake pkg-config -y && \
apt-get install libusb-1.0-0-dev -y && \
apt-get install libturbojpeg0-dev -y && \
apt-get install libglfw3-dev -y && \
apt-get install libopenni2-dev -y && \
apt-get install git -y && \
apt-get install ros-noetic-catkin -y
RUN apt update && apt upgrade -y \
&& apt install -y \
libusb-1.0-0-dev \
libturbojpeg \
libturbojpeg0-dev \
libjpeg-turbo8-dev \
libglfw3-dev \
libopenni2-dev \
freeglut3-dev \
uuid-dev \
libsdl2-dev \
usbutils \
python3-catkin-tools \
python3-rosdep \
alsa-utils \
ros-${ROS_DISTRO}-ros-core \
ros-${ROS_DISTRO}-vision-opencv \
ros-${ROS_DISTRO}-nodelet-core \
ros-${ROS_DISTRO}-perception-pcl \
ros-${ROS_DISTRO}-compressed-depth-image-transport \
ros-${ROS_DISTRO}-compressed-image-transport \
ros-${ROS_DISTRO}-geometry \
ros-${ROS_DISTRO}-depth-image-proc \
python3-opencv \
udev \
nano \
&& apt-get clean
WORKDIR /home
RUN git clone https://github.com/OpenKinect/libfreenect2.git
WORKDIR /home/libfreenect2
RUN mkdir build &&\
cd build && \
cmake .. \
-DCMAKE_INSTALL_PREFIX=$HOME/freenect2 \
-DENABLE_CXX11=ON && \
make && \
make install && \
mkdir -p /etc/udev/rules.d/ && \
cp /home/libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
WORKDIR /home
RUN mkdir -p kinect_ws/src
WORKDIR /home/kinect_ws/src
RUN git clone https://github.com/paul-shuvo/iai_kinect2_opencv4.git
WORKDIR /home/kinect_ws/src/iai_kinect2_opencv4
RUN rosdep install -r -y --from-paths .
WORKDIR /home/kinect_ws
我在映射 USB 输入以用于 Docker cointeiner 时遇到了问题。我想使用连接到 USB 端口的 KinectV2,我试过了
xhost +
`docker run --rm -it --user ros -v /dev:/dev --device-cgroup-rule='c : rmw' -v /run/udev:/run/udev --ipc=host pu:v4 bash