Azure_Kinect_ROS_Driver
Azure_Kinect_ROS_Driver copied to clipboard
MJPEG decode failed: -1 in Docker
I have been trying to get the driver running in Docker but it fails when I launch with additional params, e.g.:
roslaunch azure_kinect_ros_driver driver.launch fps:=30 depth_mode:=NFOV_UNBINNED rgb_point_cloud:=false
results in the following errors:
[error] [t=119] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/color/uvc_camerareader.cpp (1300): DecodeMJPEGtoBGRA32(). MJPEG decode failed: -1
[error] [t=120] /__w/1/s/extern/Azure-Kinect-Sensor-SDK/src/sdk/k4a.c (269): capturesync_get_capture(device->capturesync, capture_handle, timeout_in_ms) returned failure in k4a_device_get_capture()
I have tried different combinations of environment variables (DISPLAY etc.) and I have previously managed to get it to run on Foxy with a different Dockerfile, but there the node randomly fails after some time (similar to https://github.com/microsoft/Azure_Kinect_ROS_Driver/issues/249) and the official answer was that 20.04 is not yet supported, so I would appreciate help to get it running properly under Melodic.
I am running this on a Linux machine (Ubuntu 20.04) with an NVIDIA GPU that I am passing in via the NVIDIA Container Toolkit.
Here is my Compose file:
version: "3.9"
services:
kinect:
build:
context: .
dockerfile: azure_kinect.Dockerfile
devices:
- /dev/bus/usb:/dev/bus/usb
- /dev/dri:/dev/dri
- /dev/nvidia0:/dev/nvidia0
- /dev/nvidiactl:/dev/nvidiactl
- /dev/nvidia-uvm:/dev/nvidia-uvm
privileged: true
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- /usr/lib/nvidia-520:/usr/lib/nvidia-520
environment:
- DISPLAY=$DISPLAY
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
and Dockerfile:
FROM ros:melodic
WORKDIR /app
COPY azure_kinect/sources.list /app
ARG DEBIAN_FRONTEND=noninteractive
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
file \
dpkg-dev \
qemu \
binfmt-support \
qemu-user-static \
pkg-config \
python3 \
gcc \
g++ \
git \
git-lfs \
nasm \
cmake \
apt-transport-https \
apt-utils \
build-essential \
software-properties-common \
zip \
unzip \
python3-catkin-pkg \
python3-catkin-tools \
python3-rospkg \
python3-rosinstall \
python3-rosinstall-generator \
python3-rosdep \
python3-wstool \
python3-vcstool \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-desktop \
ros-${ROS_DISTRO}-joint-state-publisher \
ros-${ROS_DISTRO}-catkin \
ros-${ROS_DISTRO}-image-geometry \
ros-${ROS_DISTRO}-tf2-geometry-msgs \
ros-${ROS_DISTRO}-camera-info-manager \
ros-${ROS_DISTRO}-rgbd-launch \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
RUN apt-add-repository https://packages.microsoft.com/ubuntu/18.04/prod
RUN apt-get update && apt-get install -y \
ninja-build \
doxygen \
clang \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
&& rm -rf /var/lib/apt/lists/*
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
# Required for non-glvnd setups.
ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
RUN apt-get update && apt-get install -y \
libgl1-mesa-dev \
libsoundio-dev \
libjpeg-dev \
libvulkan-dev \
libx11-dev \
libxcursor-dev \
libxinerama-dev \
libxrandr-dev \
libusb-1.0-0-dev \
libssl-dev \
libudev-dev \
mesa-common-dev \
uuid-dev \
libopencv-dev \
&& rm -rf /var/lib/apt/lists/*
# Azure Kinect ROS depends on Version 1.3.0, we also need the dev version additionally to build
RUN curl -sSL https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/libk/libk4a1.3/libk4a1.3_1.3.0_amd64.deb > /tmp/libk4a1.3_1.3.0_amd64.deb
RUN curl -sSL https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/libk/libk4a1.3-dev/libk4a1.3-dev_1.3.0_amd64.deb > /tmp/libk4a1.3-dev_1.3.0_amd64.deb
RUN curl -sSL https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/k/k4a-tools/k4a-tools_1.3.0_amd64.deb > /tmp/k4a-tools_1.3.0_amd64.deb
RUN echo 'libk4a1.3 libk4a1.3/accepted-eula-hash string 0f5d5c5de396e4fee4c0753a21fee0c1ed726cf0316204edda484f08cb266d76' | debconf-set-selections
RUN echo 'libk4a1.3 libk4a1.3/accept-eula select true' | sudo debconf-set-selections
RUN dpkg -i /tmp/libk4a1.3_1.3.0_amd64.deb
RUN dpkg -i /tmp/libk4a1.3-dev_1.3.0_amd64.deb
RUN dpkg -i /tmp/k4a-tools_1.3.0_amd64.deb
# # Alternative installation method
# RUN echo 'libk4a1.3 libk4a1.3/accepted-eula-hash string 0f5d5c5de396e4fee4c0753a21fee0c1ed726cf0316204edda484f08cb266d76' | debconf-set-selections
# RUN echo 'libk4a1.3 libk4a1.3/accept-eula select true' | sudo debconf-set-selections
# RUN apt-get update && apt-get install -y \
# libk4a1.3 \
# libk4a1.3-dev \
# k4a-tools=1.3.0 \
# && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/udev/rules.d/
COPY azure_kinect/99-k4a.rules /etc/udev/rules.d/99-k4a.rules
RUN chmod a+rwx /etc/udev/rules.d
COPY azure_kinect/run_ros_azure_kinect.sh /app
RUN ["chmod", "+x", "run_ros_azure_kinect.sh"]
ENTRYPOINT ["./run_ros_azure_kinect.sh"]
as well as the script to start the driver node:
#!/bin/bash
DIR=ros_ws
source /opt/ros/melodic/setup.bash
if [ -d $DIR ]; then
echo "Starting Kinect..."
cd ros_ws
source ./devel/setup.bash
else
mkdir -p ./ros_ws/src
cd ./ros_ws/src
catkin_init_workspace
git clone https://github.com/microsoft/Azure_Kinect_ROS_Driver -b melodic
cd ..
catkin_make --force-cmake
source ./devel/setup.bash
fi
# This throws errors and terminates after throwing an instance of 'k4a::error'
roslaunch azure_kinect_ros_driver driver.launch fps:=30 depth_mode:=NFOV_UNBINNED rgb_point_cloud:=false
Additionally, it would be great if body tracking could also be included. I am currently unsure if I still need additional dependencies or if setting body_tracking_enabled:=true is enough.
Thank you
I'm having the same issue using ROS2 Humble on Ubuntu 22.04 in Docker. The node crashes after 4-5 hours of running (doing long-run tests) and I get an error saying MJPEG decode failed: -1 when using depth_mode of NFOV_UNBINNED and color_resolution of 2160p at a target framerate of 2160p. Any help from the Kinect team would be appreciated, thanks.
Here's a screenshot of the similar error I'm getting
