I am trying to run gazebo simulations of xarm robot inside the docker container, but I get black screen even if I just run gazebo itself.
Here is a dockerfile from where I created the image:
# Use Ubuntu 22.04 as the base image
FROM ubuntu:22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV ROS_DISTRO=humble
ENV ament_cmake_DIR=/opt/ros/$ROS_DISTRO/share/ament_cmake/cmake
# Update the package lists and install necessary dependencies
RUN apt-get update && apt-get install -y \
curl \
gnupg2 \
lsb-release \
locales \
sudo \
git \
wget
# Set the locale to avoid any locale-related issues
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
# Add the ROS 2 apt repository
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
RUN echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list
# Update the package lists again and install ROS 2 Humble
RUN apt-get update && apt-get install -y \
ros-$ROS_DISTRO-desktop \
ros-$ROS_DISTRO-ros-base
# Install additional dependencies for rosdep
RUN apt-get install -y python3-rosdep python3-colcon-common-extensions xorg
# Initialize rosdep and update
RUN rosdep init && rosdep update
# Create the ROS workspace
RUN mkdir -p /root/ros2_ws/src
# Clone the xarm_ros2 repository
RUN cd /root/ros2_ws/src && \
git clone --recursive -b $ROS_DISTRO https://github.com/xArm-Developer/xarm_ros2.git && \
cd /root/ros2_ws/src/xarm_ros2/ && \
git pull && \
git submodule sync && \
git submodule update --init --remote
# Clone the gazebo_ros2_control repository
RUN cd /root/ros2_ws/src && \
git clone https://github.com/ros-controls/gazebo_ros2_control.git
# Install the dependency
RUN apt-get install -y ros-$ROS_DISTRO-ament-cmake
# Update rosdep and install
RUN cd /root/ros2_ws/src && \
rosdep update && \
rosdep install --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
# Build the ROS workspace
RUN cd /root/ros2_ws && \
. /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build
# Set up the entrypoint
CMD ["bash"]
I searched internet and asked chatgpt to help, couldn't solve and stopped at this:
docker run -it --gpus all --device /dev/snd:/dev/snd --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native -v ~/.config/pulse/cookie:/root/.config/pulse/cookie -v $HOME/.Xauthority:/home/$(id -un)/.Xauthority -e XAUTHORITY=/home/$(id -un)/.Xauthority ros2-humble:latest
Seems like I am missing something or building the docker image wrong.