FROM ubuntu:jammy ARG USERNAME=nx ARG USER_UID=1000 ARG USER_GID=$USER_UID ENV HOME=/home/nx RUN addgroup \ --gid $USER_GID $USERNAME && adduser \ --uid $USER_UID \ --gid $USER_GID \ --disabled-password \ --gecos "$USERNAME user" $USERNAME ARG DBF=noninteractive ENV DEBIAN_FRONTEND=${DBF} ENV MAKEFLAGS=-j4 ARG PW=10 ENV ROS2_DISTRO=humble ENV ROS2_INSTALL_PATH=$HOME/ros2_ws RUN mkdir -p $ROS2_INSTALL_PATH/src ENV ROS2_INSTALL=$ROS2_INSTALL_PATH/install/setup.bash #### GENERAL LINUX/ROS DEPENDENCIES RUN apt-get update RUN apt-get install -y \ build-essential \ cmake \ curl \ git \ gnupg \ locales \ lsb-release \ wget RUN locale-gen en_US en_US.UTF-8 &&\ update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ENV LANG=en_US.UTF-8 #### INSTALL ROS2 HUMBLE FROM SRC RUN apt install software-properties-common -y RUN add-apt-repository universe -y RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg RUN 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 # Install additional packages RUN apt update && apt install -y \ python3-flake8 \ python3-flake8-blind-except \ python3-flake8-builtins \ python3-flake8-class-newline \ python3-flake8-comprehensions \ python3-flake8-deprecated \ python3-flake8-docstrings \ python3-flake8-import-order \ python3-flake8-quotes \ python3-pip \ python3-pytest \ python3-pytest-cov \ python3-pytest-repeat \ python3-pytest-rerunfailures \ python3-rosdep \ python3-setuptools \ ros-dev-tools # Install colcon from PyPI, rather than apt packages RUN python3 -m pip install -U colcon-common-extensions vcstool WORKDIR $ROS2_INSTALL_PATH # RUN vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src # RUN apt upgrade -y # RUN rosdep init RUN wget https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos RUN vcs import src < ros2.repos RUN sudo rosdep init RUN rosdep update RUN rosdep install --from-paths src --ignore-src -y --rosdistro humble --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers" RUN colcon build --symlink-install --parallel-workers $PW #### INSTALL ROS1 w/ ros-core-dev RUN rm /etc/apt/sources.list.d/ros2.list && apt-get update -y RUN apt remove -y \ python3-catkin-pkg \ python3-catkin-pkg-modules RUN apt update && apt install -y \ ros-core-dev #### INSTALL ROS2 HUMBLE DEPENDENCIES FROM SRC ARG ROSV=ros2 # primarily conflict with catkin-pkg-modules (rqd by ros-core-dev) # systematically discovered ros2 dependencies installed from src RUN apt install -y \ libboost-python-dev \ libboost-iostreams-dev \ libceres-dev \ libgraphicsmagick++1-dev \ libompl-dev \ libpcl-dev \ libxtensor-dev \ libzmq3-dev \ libgazebo-dev WORKDIR $HOME COPY ./rosbridge_general_update_ament.sh . #### COPY CUSTOM_BRIDGE WORKDIR $HOME COPY ./custom_bridge_ros1_ws $HOME/custom_bridge_ros1_ws WORKDIR $HOME/custom_bridge_ros1_ws RUN bash -c "catkin_make" #### COPY NEW BRIDGE WS COPY ./custom_bridge_ros2_ws $HOME/custom_bridge_ros2_ws WORKDIR $HOME/custom_bridge_ros2_ws RUN bash -c "source $HOME/ros2_ws/install/setup.bash && colcon build --symlink-install" RUN mkdir -p $HOME/.ros/log && \ chown -R $USERNAME:$USERNAME $HOME/.ros && \ chmod -R 755 $HOME/.ros RUN chown -R $USERNAME:$USERNAME $HOME/custom_bridge_ros1_ws && \ chmod -R 755 $HOME/custom_bridge_ros1_ws RUN chown -R $USERNAME:$USERNAME $HOME/custom_bridge_ros2_ws && \ chmod -R 755 $HOME/custom_bridge_ros2_ws #### INSTALL ROS1_BRIDGE ARG ROS1_BRIDGE_ROOT_DIR=$HOME/ros1_bridge_ws ENV ROS1_BRIDGE_ROOT_DIR=$ROS1_BRIDGE_ROOT_DIR ARG ROS1_BRIDGE_INSTALL_DIR=$ROS1_BRIDGE_ROOT_DIR/src ENV ROS1_BRIDGE_INSTALL_DIR=$ROS1_BRIDGE_INSTALL_DIR WORKDIR $ROS1_BRIDGE_INSTALL_DIR RUN git clone https://github.com/ros2/ros1_bridge # update cmakelist of ros1_bridge to cpp17 RUN sed -i 's/# Default to C++14/# Default to C++17/' ${ROS1_BRIDGE_INSTALL_DIR}/ros1_bridge/CMakeLists.txt RUN sed -i 's/set(CMAKE_CXX_STANDARD 14)/set(CMAKE_CXX_STANDARD 17)/' ${ROS1_BRIDGE_INSTALL_DIR}/ros1_bridge/CMakeLists.txt WORKDIR $ROS1_BRIDGE_ROOT_DIR #### BUILD/COMPILE ROS1_BRIDGE RUN bash -c "source $HOME/custom_bridge_ros1_ws/devel/setup.bash &&\ source $HOME/ros2_ws/install/setup.bash &&\ source $HOME/custom_bridge_ros2_ws/install/setup.bash &&\ colcon build --packages-select ros1_bridge --cmake-force-configure --parallel-workers 12"