From 8316d8ce9b1c32069c13a9851e3cb19d1fff7844 Mon Sep 17 00:00:00 2001 From: Ettore Landini Date: Mon, 27 Jan 2025 17:57:01 +0100 Subject: [PATCH] New docker folders These new folders contain the dockerfiles and the managing scripts for jazzy images. They are needed since humble/iron and jazzy dockerfiles are slightly different. These folder and the standards ones will switch names in the jazzy branch --- docker_stuff/docker_mng_vars.sh | 1 + docker_stuff/docker_openPose/Dockerfile | 189 ------------ docker_stuff/docker_openPose/build-docker.sh | 25 -- .../docker_openPose/start-docker-openpose.sh | 24 -- docker_stuff/docker_sim_alt/Dockerfile | 270 +++++++++++++++++ docker_stuff/docker_sim_alt/README.md | 19 ++ .../common/xorg.conf | 0 .../docker_sim_alt/docker-compose.yml | 74 +++++ docker_stuff/docker_sim_alt/manage-docker.sh | 197 +++++++++++++ docker_stuff/docker_tourCore_alt/Dockerfile | 275 ++++++++++++++++++ .../README.md | 8 + .../docker_tourCore_alt/common/xorg.conf | 23 ++ .../docker_tourCore_alt/docker-compose.yml | 70 +++++ .../docker_tourCore_alt/manage-docker.sh | 194 ++++++++++++ 14 files changed, 1131 insertions(+), 238 deletions(-) delete mode 100644 docker_stuff/docker_openPose/Dockerfile delete mode 100755 docker_stuff/docker_openPose/build-docker.sh delete mode 100755 docker_stuff/docker_openPose/start-docker-openpose.sh create mode 100644 docker_stuff/docker_sim_alt/Dockerfile create mode 100644 docker_stuff/docker_sim_alt/README.md rename docker_stuff/{docker_openPose => docker_sim_alt}/common/xorg.conf (100%) create mode 100644 docker_stuff/docker_sim_alt/docker-compose.yml create mode 100644 docker_stuff/docker_sim_alt/manage-docker.sh create mode 100644 docker_stuff/docker_tourCore_alt/Dockerfile rename docker_stuff/{docker_openPose => docker_tourCore_alt}/README.md (66%) create mode 100644 docker_stuff/docker_tourCore_alt/common/xorg.conf create mode 100644 docker_stuff/docker_tourCore_alt/docker-compose.yml create mode 100644 docker_stuff/docker_tourCore_alt/manage-docker.sh diff --git a/docker_stuff/docker_mng_vars.sh b/docker_stuff/docker_mng_vars.sh index 3eb5184..0b0c984 100644 --- a/docker_stuff/docker_mng_vars.sh +++ b/docker_stuff/docker_mng_vars.sh @@ -1,6 +1,7 @@ UBUNTU_DEF="ubuntu:22.04" CUDA_DEF="nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04" ROS_DEF="iron" +GAZEBO_DEF="harmonic" YARP_DEF="master" CUDA_SUFFIX="cuda.11.7.1-cudnn8" UBUNTU_SUFFIX="ubuntu22.04" diff --git a/docker_stuff/docker_openPose/Dockerfile b/docker_stuff/docker_openPose/Dockerfile deleted file mode 100644 index 6b5c2fa..0000000 --- a/docker_stuff/docker_openPose/Dockerfile +++ /dev/null @@ -1,189 +0,0 @@ -FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 -LABEL maintainer="Ettore Landini" - -ARG ros_distro - -# Non-interactive installation mode -ENV DEBIAN_FRONTEND=noninteractive -ENV DOCKER_UPDATED_ON=28_09_2022 - -# Install essentials -RUN apt-get update && apt-get install -y apt-utils software-properties-common sudo psmisc lsb-release protobuf-compiler libatlas-base-dev \ - tmux nano geany vim wget curl build-essential git gitk cmake cmake-curses-gui autoconf xserver-xorg-video-dummy xserver-xorg-legacy \ - net-tools terminator libjpeg-dev ffmpeg apt-transport-https ca-certificates gnupg libace-dev ycm-cmake-modules locales \ - python3-setuptools python3-pip iproute2 python3-tornado swig lsof iftop iputils-ping gdb bash-completion btop mlocate && rm -rf /var/lib/apt/lists/* - -RUN pip3 install numpy bpytop scikit-learn==0.24.2 opencv-python - -RUN sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config -COPY ./common/xorg.conf /etc/X11/xorg.conf - -# Locale config -RUN locale-gen en_US en_US.UTF-8 -RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 -ENV LANG=en_US.UTF-8 - -# Install yarp dependencies -RUN apt-get update && apt-get install -y libode8 libace-dev libboost-filesystem-dev libboost-system-dev \ - libboost-thread-dev libc6 python3 libgsl0-dev libncurses5-dev libsdl1.2-dev subversion git gfortran \ - libxmu-dev libode-dev wget unzip qtbase5-dev qtdeclarative5-dev qtmultimedia5-dev libqt5svg5 \ - libqt5opengl5-dev libopencv-dev freeglut3-dev libtinyxml-dev libblas-dev coinor-libipopt-dev \ - liblapack-dev libmumps-dev qml-module-qtmultimedia qml-module-qtquick-dialogs qml-module-qtquick-controls \ - qml-module-qt-labs-settings libqcustomplot-dev qml-module-qt-labs-folderlistmodel libedit-dev \ - libeigen3-dev libjpeg-dev libsimbody-dev libxml2-dev libjs-underscore portaudio19-dev libgtkmm-2.4-dev \ - libi2c-dev libv4l-dev - -# Create user: user1 -USER root -RUN useradd -l -u 33334 -G sudo -md /home/user1 -s /bin/bash -p user1 user1 && \ - # passwordless sudo for users in the 'sudo' group - sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers - -# Set ENV -USER user1 -RUN mkdir /home/user1/robotology -ENV robotology_install_user user1 -ENV user1_home /home/$robotology_install_user -ENV robotology_install_folder $user1_home/robotology - -RUN sudo apt-get update && sudo apt-get install -y libgoogle-glog-dev libhdf5-dev - -# Build openpose -USER $robotology_install_user -WORKDIR $user1_home -RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose && \ - cd ./openpose/ && \ - git submodule update --init --recursive --remote && \ - git checkout tags/v1.7.0 -RUN cd $user1_home/openpose && \ - mkdir build && \ - cd ./build && \ - # Right now the following does not work. - # https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/2233 - # You have to download the weights manually - # cmake .. -DDOWNLOAD_HAND_MODEL=OFF -DUSE_CUDNN=OFF && \ - cmake .. -DDOWNLOAD_HAND_MODEL=OFF -DDOWNLOAD_BODY_25_MODEL=OFF -DDOWNLOAD_FACE_MODEL=OFF -DUSE_CUDNN=OFF && \ - make -j11 -ENV openpose_ROOT=$user1_home/openpose - - -# Build ycm -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN git clone https://github.com/robotology/ycm.git -b master -RUN cd ycm && mkdir build && cd build && \ - cmake .. \ - -DCMAKE_BUILD_TYPE=Release && \ - make -j11 -ENV YCM_DIR=/home/user1/robotology/ycm/build - -# Build YARP -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN git clone https://github.com/robotology/yarp.git -b yarp-3.9 -RUN cd yarp && mkdir build && cd build && \ - cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -DYARP_COMPILE_libYARP_math=ON \ - -DYARP_COMPILE_GUIS=ON \ - -DYARP_COMPILE_DEVICE_PLUGINS=ON \ - -DENABLE_yarpcar_mjpeg=ON \ - -DENABLE_yarpcar_human=ON \ - -DENABLE_yarpcar_segmentationimage=ON \ - -DENABLE_yarpcar_portmonitor=ON \ - -DENABLE_yarpmod_controlboardwrapper2=ON \ - -DENABLE_yarpmod_laserFromDepth=ON \ - -DENABLE_yarpmod_laserFromExternalPort=ON \ - -DENABLE_yarpmod_laserFromDepth=ON \ - -DENABLE_yarpmod_laserFromPointCloud=ON \ - -DENABLE_yarpmod_laserFromRosTopic=ON \ - -DENABLE_yarppm_soundfilter_resample=ON \ - -DENABLE_yarppm_bottle_compression_zlib=ON \ - -DENABLE_yarppm_depthimage_compression_zlib=ON \ - -DENABLE_yarppm_image_compression_ffmpeg=ON \ - -DENABLE_yarppm_depthimage_to_mono=ON \ - -DENABLE_yarppm_depthimage_to_rgb=ON && \ - make -j11 -ENV YARP_ROOT=$robotology_install_folder/yarp -ENV YARP_DIR=$robotology_install_folder/yarp/build - -# YARP bindings -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN cd yarp && cd bindings && mkdir build && cd build && cmake .. -DCREATE_PYTHON=ON && make -j11 - -# Install YARP completion -RUN sudo ln -s /usr/local/share/bash-completion/completions/yarp /usr/share/bash-completion/completions - -# Build icub-main -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN git clone https://github.com/robotology/icub-main.git -b devel -RUN cd icub-main && mkdir build && cd build && \ - cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_icubmod_cartesiancontrollerserver=ON \ - -DENABLE_icubmod_cartesiancontrollerclient=ON \ - -DICUBMAIN_COMPILE_SIMULATORS=OFF \ - -DENABLE_icubmod_gazecontrollerclient=ON && \ - make -j11 -ENV ICUB_ROOT=$robotology_install_folder/icub-main -ENV ICUB_DIR=$robotology_install_folder/icub-main/build - -# Build icub-contrib-common -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN git clone https://github.com/robotology/icub-contrib-common.git -RUN cd icub-contrib-common && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$robotology_install_folder/iCubContrib && sudo make -j11 install -ENV ICUBcontrib_DIR=$robotology_install_folder/iCubContrib/lib -ENV ICUBcontrib_SHARE=$robotology_install_folder/iCubContrib/share/ICUBcontrib - -# Build yarpopenpose (Maria Lombardi) -USER $robotology_install_user -WORKDIR $robotology_install_folder -RUN git clone https://github.com/robotology/human-sensing -RUN cd human-sensing/yarpOpenPose && \ - mkdir build && \ - cd ./build && \ - cmake .. && \ - make && sudo make install - -# Build mutual gaze classifier (Maria Lombardi) -USER $robotology_install_user -WORKDIR $user1_home -RUN git clone https://github.com/MariaLombardi/mutual-gaze-classifier-demo.git -RUN cd mutual-gaze-classifier-demo && \ - mkdir build && \ - cd ./build && \ - cmake .. && \ - make && sudo make install - -# Set environmental variables -USER $robotology_install_user -RUN echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '" >> /home/$robotology_install_user/.bashrc -ENV PATH=$PATH:$YARP_DIR/bin:$navigation_DIR/bin:$CER_DIR/bin:$ICUB_DIR/bin:$ICUB_DIR:$robotology_install_folder/iCubContrib/bin:/home/user1/robotology/Groot/build:/home/user1/tour-guide-robot/build/bin -ENV DISPLAY=:1 -ENV YARP_DATA_DIRS=$YARP_DIR/share/yarp:$ICUB_DIR/share/iCub:$navigation_DIR/share/navigation:$user1_home/tour-guide-robot/build/share/tour-guide-robot:$CER_DIR/share/CER:$ICUBcontrib_DIR/share/ICUBcontrib:$robotology_install_folder/yarp-devices-ros2/build/share/yarp:$robotology_install_folder/yarp-device-rplidar/build/share/yarp:$ICUBcontrib_SHARE -ENV LD_LIBRARY_PATH=$robotology_install_folder/yarp/build/lib/yarp/ -ENV YARP_COLORED_OUTPUT=1 -ENV QT_X11_NO_MITSHM=1 -ENV PYTHONPATH=$PYTHONPATH:/home/user1/robotology/yarp/bindings/build/lib/python3/ -ENV TOUR_GUIDE_ROBOT_SOURCE_DIR=/home/user1/tour-guide-robot -ENV CYCLONEDDS_URI=/home/user1/tour-guide-robot/app/navigation2/conf/cyclone_dds_settings.xml - -# Manage yarp port -EXPOSE 10000/tcp 10000/udp - -# Navigation stuff -WORKDIR ${user1_home} -RUN git clone https://github.com/elandini84/yarp-web-teleop.git -b master -RUN git clone https://github.com/hsp-iit/tour-guide-robot -b $ros_distro -RUN /bin/bash -c "cd tour-guide-robot; mkdir build; cd build; cmake .. -DCMAKE_BUILD_TYPE=Release -DBTState=OFF" - -# R1 NETWORK CONFIG -RUN yarp conf 192.168.100.10 10000 - -WORKDIR ${user1_home}/tour-guide-robot -RUN sudo updatedb -# Change the lidar devices permissions inside the docker to be able to start the devices with yarprobotinterface -CMD if [ -e /dev/ttyUSB0 ]; then sudo chown user1:user1 /dev/ttyUSB0 && sudo chown user1:user1 /dev/ttyUSB1; fi && bash diff --git a/docker_stuff/docker_openPose/build-docker.sh b/docker_stuff/docker_openPose/build-docker.sh deleted file mode 100755 index cb71729..0000000 --- a/docker_stuff/docker_openPose/build-docker.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Set default values -source ../docker_mng_vars.sh - -if [[ -n $1 ]]; then - if [[ $1 == "-d" || $1 == "--devel" ]]; then - sudo docker build --build-arg ros_distro=$ROS_DEF -t elandini84/r1images:r1OpenPose_devel . - elif [[ $1 == "-s" || $1 == "--stable" ]]; then - sudo docker build --build-arg ros_distro=$ROS_DEF -t elandini84/r1images:r1OpenPose_stable . - elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Syntax: ./build-docker.sh [option]" - echo "options:" - echo " -d, --devel Build the image with the r1OpenPose_devel tag" - echo " -s, --stable Build the image with the r1OpenPose_stable tag" - echo " -h, --help See current help" - echo "If no option is passed, the r1Core2_devel tag is used" - else - echo "Wrong option." - $0 -h - fi -else - echo "No option passed. Using the default tag" - $0 -d -fi diff --git a/docker_stuff/docker_openPose/start-docker-openpose.sh b/docker_stuff/docker_openPose/start-docker-openpose.sh deleted file mode 100755 index 80d66c0..0000000 --- a/docker_stuff/docker_openPose/start-docker-openpose.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -sudo xhost + - -if [[ -n $1 ]]; then - if [[ $1 == "-d" || $1 == "--devel" ]]; then - sudo docker run --rm -it --privileged --network host --pid host -e NVIDIA_DRIVER_CAPABILITIES=all -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/hosts:/etc/hosts -e QT_X11_NO_MITSHM=1 --gpus all elandini84/r1images:r1OpenPose_devel - elif [[ $1 == "-s" || $1 == "--stable" ]]; then - sudo docker run --rm -it --privileged --network host --pid host -e NVIDIA_DRIVER_CAPABILITIES=all -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/hosts:/etc/hosts -e QT_X11_NO_MITSHM=1 --gpus all elandini84/r1images:r1OpenPose_stable - elif [[ $1 == "-h" || $1 == "--help" ]]; then - echo "Syntax: ./start-docker-core [option]" - echo "options:" - echo " -d, --devel Starts the image with the r1OpenPose_devel tag" - echo " -s, --stable Starts the image with the r1OpenPose_stable tag" - echo " -h, --help See current help" - echo "If no option is passed, the r1OpenPose_stable tag is used" - else - echo "Wrong option." - $0 -h - fi -else - echo "No option passed. Using the default tag" - $0 -s -fi diff --git a/docker_stuff/docker_sim_alt/Dockerfile b/docker_stuff/docker_sim_alt/Dockerfile new file mode 100644 index 0000000..b54cf67 --- /dev/null +++ b/docker_stuff/docker_sim_alt/Dockerfile @@ -0,0 +1,270 @@ +ARG base_img +FROM $base_img +LABEL maintainer="Ettore Landini" + +ARG ros_distro +ARG yarp_branch="master" +ARG ros2_dev_remote="robotology" +ARG ros2_dev_branch=${yarp_branch} +ARG gazebo_pkg=ros-${ros_distro}-ros-gz +ARG gazebo_version=harmonic + +# Non-interactive installation mode +ENV DEBIAN_FRONTEND=noninteractive +ENV DOCKER_UPDATED_ON=06_06_2024 + +# Install essentials +RUN apt-get update && apt-get install -y apt software-properties-common sudo psmisc lsb-release \ + tmux nano geany vim wget curl build-essential git gitk cmake cmake-curses-gui autoconf xserver-xorg-video-dummy xserver-xorg-legacy \ + net-tools terminator libjpeg-dev ffmpeg apt-transport-https ca-certificates gnupg libace-dev ycm-cmake-modules locales \ + python3-setuptools python3-pip iproute2 python3-tornado swig lsof iftop iputils-ping gdb bash-completion btop pipx && rm -rf /var/lib/apt/lists/* + +RUN pipx install numpy bpytop + +RUN sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config +COPY ./common/xorg.conf /etc/X11/xorg.conf + +# ROS2 Installation +RUN locale-gen en_US en_US.UTF-8 +RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +ENV LANG=en_US.UTF-8 +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 $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null +RUN apt-get update && apt-get upgrade -y && apt-get install -y ros-${ros_distro}-desktop ros-${ros_distro}-navigation2 ros-${ros_distro}-nav2-bringup \ + ros-${ros_distro}-slam-toolbox ros-${ros_distro}-test-msgs ${gazebo_pkg} \ + python3-colcon-common-extensions 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-pytest python3-pytest-cov python3-pytest-repeat \ + python3-pytest-rerunfailures python3-rosdep python3-vcstool && rosdep init && rm -rf /var/lib/apt/lists/* + +# Install yarp dependencies +RUN apt-get update && apt-get install -y libode8 libace-dev libboost-filesystem-dev libboost-system-dev \ + libboost-thread-dev libc6 python3 libgsl0-dev libncurses5-dev libsdl1.2-dev subversion git gfortran \ + libxmu-dev libode-dev wget unzip qtbase5-dev qtdeclarative5-dev qtmultimedia5-dev libqt5svg5 \ + libqt5opengl5-dev libopencv-dev freeglut3-dev libtinyxml-dev libblas-dev coinor-libipopt-dev \ + liblapack-dev libmumps-dev qml-module-qtmultimedia qml-module-qtquick-dialogs qml-module-qtquick-controls \ + qml-module-qt-labs-settings libqcustomplot-dev qml-module-qt-labs-folderlistmodel libedit-dev \ + libeigen3-dev libjpeg-dev libsimbody-dev libxml2-dev libjs-underscore portaudio19-dev libgtkmm-2.4-dev \ + libi2c-dev libv4l-dev + +# Create user: user1 +USER root +RUN useradd -l -u 33334 -G sudo -md /home/user1 -s /bin/bash -p user1 user1 && \ + # passwordless sudo for users in the 'sudo' group + sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers + +# ROS2 Installation (part2) +USER user1 +RUN rosdep fix-permissions && rosdep update + +# Set ENV +USER user1 +RUN sudo mkdir /usr/local/src/robot +ENV robotology_install_user user1 +ENV user1_home /home/${robotology_install_user} +ENV robotology_install_folder /usr/local/src/robot +RUN sudo chown -R ${robotology_install_user}:${robotology_install_user} ${robotology_install_folder} + +#gazebo models +RUN mkdir -p $user1_home/.gazebo && git clone https://github.com/osrf/gazebo_models $user1_home/.gazebo/models + +# Build ycm +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/ycm.git -b master +RUN cd ycm && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release && \ + make -j11 +ENV YCM_DIR=${robotology_install_folder}/ycm/build + +# Build YARP +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/yarp.git -b ${yarp_branch} +RUN cd yarp && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DYARP_COMPILE_libYARP_math=ON \ + -DYARP_COMPILE_GUIS=ON \ + -DYARP_COMPILE_DEVICE_PLUGINS=ON \ + -DENABLE_yarpcar_mjpeg=ON \ + -DENABLE_yarpcar_segmentationimage=ON \ + -DENABLE_yarpcar_portmonitor=ON \ + -DENABLE_yarpmod_portaudio=ON \ + -DENABLE_yarpmod_portaudioPlayer=ON \ + -DENABLE_yarpmod_portaudioRecorder=ON \ + -DENABLE_yarpmod_fakeAnalogSensor=ON \ + -DENABLE_yarpmod_fakeBattery=ON \ + -DENABLE_yarpmod_fakeDepthCamera=ON \ + -DENABLE_yarpmod_fakeIMU=ON \ + -DENABLE_yarpmod_fakeLaser=ON \ + -DENABLE_yarpmod_fakeLocalizer=ON \ + -DENABLE_yarpmod_fakeMicrophone=ON \ + -DENABLE_yarpmod_fakeMotionControl=ON \ + -DENABLE_yarpmod_fakeNavigation=ON \ + -DENABLE_yarpmod_fakeSpeaker=ON \ + -DENABLE_yarpmod_fakebot=ON \ + -DENABLE_yarpmod_laserFromDepth=ON \ + -DENABLE_yarpmod_laserFromExternalPort=ON \ + -DENABLE_yarpmod_laserFromDepth=ON \ + -DENABLE_yarpmod_laserFromPointCloud=ON \ + -DENABLE_yarpmod_laserFromRosTopic=ON \ + -DENABLE_yarppm_soundfilter_resample=ON \ + -DENABLE_yarppm_bottle_compression_zlib=ON \ + -DENABLE_yarppm_depthimage_compression_zlib=ON \ + -DENABLE_yarppm_image_compression_ffmpeg=ON \ + -DENABLE_yarppm_depthimage_to_mono=ON \ + -DENABLE_yarppm_depthimage_to_rgb=ON && \ + make -j11 +ENV YARP_ROOT=${robotology_install_folder}/yarp +ENV YARP_DIR=${robotology_install_folder}/yarp/build + +# YARP bindings +# USER ${robotology_install_user} +# WORKDIR ${robotology_install_folder} +# RUN cd yarp && cd bindings && mkdir build && cd build && cmake .. -DCREATE_PYTHON=ON && make -j11 + +# Install YARP completion +RUN sudo ln -s /usr/local/share/bash-completion/completions/yarp /usr/share/bash-completion/completions + +# Build icub-main +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/icub-main.git -b devel +RUN cd icub-main && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_icubmod_cartesiancontrollerserver=ON \ + -DENABLE_icubmod_cartesiancontrollerclient=ON \ + -DICUBMAIN_COMPILE_SIMULATORS=OFF \ + -DENABLE_icubmod_gazecontrollerclient=ON && \ + make -j11 +ENV ICUB_ROOT=${robotology_install_folder}/icub-main +ENV ICUB_DIR=${robotology_install_folder}/icub-main/build + +# Build robots-configuration devel +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/randaz81/robots-configuration.git -b R1SN003_ros2 + +# Build navigation +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/navigation.git -b master +RUN cd navigation && mkdir build && cd build && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; cmake .. -DCMAKE_BUILD_TYPE=Release -DNAVIGATION_USE_NWC=ON -DNAVIGATION_USE_ROS2=ON" && make -j11 +ENV navigation_ROOT=${robotology_install_folder}/navigation +ENV navigation_DIR=${robotology_install_folder}/navigation/build + + +# Gazebo +RUN sudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null +RUN sudo apt-get update +RUN sudo apt-get install -y gz-${gazebo_version} + +# Gz-sim plugins dependencies +WORKDIR /home/${robotology_install_user} +RUN git clone https://github.com/CLIUtils/CLI11 +RUN cd CLI11/ && \ + mkdir build && \ + cd build && \ + git submodule update --init && \ + cmake .. && \ + cmake --build . && \ + sudo cmake --install . + +# CER +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/cer.git +RUN cd cer && mkdir build && cd build && cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_cermod_cerDoubleLidar=ON \ + -DENABLE_cermod_cerOdometry=ON \ + -DENABLE_cermod_tripodMotionControl=ON && make -j11 +ENV CER_ROOT=${robotology_install_folder}/cer +ENV CER_DIR=${robotology_install_folder}/cer/build + +# YARP-DEVICES-ROS2 +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/${ros2_dev_remote}/yarp-devices-ros2 -b ${ros2_dev_branch} +RUN cd yarp-devices-ros2/ros2_interfaces_ws && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; colcon build" +RUN cd yarp-devices-ros2 && mkdir build && cd build && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; source ${robotology_install_folder}/yarp-devices-ros2/ros2_interfaces_ws/install/setup.bash; cmake .. -DYARP_ROS2_USE_SYSTEM_map2d_nws_ros2_msgs=ON -DYARP_ROS2_USE_SYSTEM_yarp_control_msgs=ON; make -j11" + +# CER-Sim stuff +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/cer-sim -b ros2 +RUN cd cer-sim/colcon_ws && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; colcon build; source ${robotology_install_folder}/cer-sim/colcon_ws/install/local_setup.bash" + +# Build icub-contrib-common +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/icub-contrib-common.git +RUN cd icub-contrib-common && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${robotology_install_folder}/iCubContrib && make -j11 install +ENV ICUBcontrib_DIR=${robotology_install_folder}/iCubContrib/build + +# Gz-sim Plugins +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN cd yarp/build && sudo make install +RUN git clone https://github.com/robotology/gz-sim-yarp-plugins +RUN cd gz-sim-yarp-plugins && mkdir build && cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=${robotology_install_folder}/gz-sim-yarp-plugins/install \ + -DCMAKE_PREFIX_PATH=${robotology_install_folder}/gz-sim-yarp-plugins/install && \ + make -j11 && make install + +# Set environmental variables +RUN echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '" >> /home/${robotology_install_user}/.bashrc +ENV TOUR_GUIDE_ROBOT_SOURCE_DIR=${robotology_install_folder}/tour-guide-robot +ENV ROBOT_CODE=${robotology_install_folder} +ENV CER_SIM_ROOT_DIR=${ROBOT_CODE}/cer-sim +ENV PATH=$PATH:$YARP_DIR/bin:$navigation_DIR/bin:$CER_DIR/bin:$ICUB_DIR/bin:$ICUB_DIR:${robotology_install_folder}/iCubContrib/bin:${robotology_install_folder}/Groot/build:${robotology_install_folder}/tour-guide-robot/build/bin:${TOUR_GUIDE_ROBOT_SOURCE_DIR}/app/navigation2/scripts:${TOUR_GUIDE_ROBOT_SOURCE_DIR}/app/headSynchronizer/scripts +ENV DISPLAY=:1 +ENV LD_LIBRARY_PATH=${robotology_install_folder}/yarp/build/lib/yarp/ +ENV GAZEBO_PLUGIN_PATH=$GazeboYARPPlugins_DIR/lib +ENV GAZEBO_MODEL_PATH=${robotology_install_folder}/cer-sim/gazebo/ +ENV YARP_COLORED_OUTPUT=1 +ENV QT_X11_NO_MITSHM=1 +ENV PYTHONPATH=$PYTHONPATH:${robotology_install_folder}/yarp/bindings/build/lib/python3/ +ENV YARP_CLOCK=/clock +#ENV CYCLONEDDS_URI=${robotology_install_folder}/tour-guide-robot/app/navigation2/conf/cyclone_dds_settings.xml + +# Manage yarp port +EXPOSE 10000/tcp 10000/udp + +# Launch bash from ${robotology_install_folder} +USER ${robotology_install_user} +RUN sudo chown -R ${robotology_install_user}:${robotology_install_user} /opt/ros && sudo chown -R ${robotology_install_user}:${robotology_install_user} /home/${robotology_install_user}/.ros + +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/elandini84/yarp-web-teleop.git && cd yarp-web-teleop && mkdir build && cd build && cmake .. +RUN git clone https://github.com/elandini84/libfvad && cd libfvad && autoreconf -i && ./configure && sudo make install +RUN git clone https://github.com/hsp-iit/tour-guide-robot -b ${ros_distro} +RUN cd tour-guide-robot && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release && make -j11 + +ENV WEB_TELEOP_DIR=${robotology_install_folder}/yarp-web-teleop/build +ENV YARP_DATA_DIRS=$YARP_DIR/share/yarp:$ICUB_DIR/share/iCub:$navigation_DIR/share/navigation:${TOUR_GUIDE_ROBOT_SOURCE_DIR}/build/share/tour-guide-robot:$CER_DIR/share/CER:$ICUBcontrib_DIR/share/ICUBcontrib:${robotology_install_folder}/yarp-devices-ros2/build/share/yarp:${robotology_install_folder}/yarp-devices-ros2/build/share/yarp-devices-ros2:${WEB_TELEOP_DIR}/share/yarp-web-teleop + +# R1 NETWORK CONFIG +RUN yarp conf 172.17.0.1 10000 + +# Possibly temporary ROS2 network middleware change +RUN sudo apt-get update && sudo apt-get install -y cyclonedds-dev cyclonedds-tools \ +ros-${ros_distro}-cyclonedds-dbgsym ros-${ros_distro}-cyclonedds ros-${ros_distro}-rmw-cyclonedds-cpp \ +ros-${ros_distro}-rmw-cyclonedds-cpp-dbgsym libcycloneddsidl0 && \ +sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +# Set ROS2 environment +RUN echo "#!/bin/bash" >> /home/user1/.entrypoint.sh +RUN echo "source /opt/ros/${ros_distro}/setup.bash" >> /home/user1/.entrypoint.sh +RUN echo "source ${robotology_install_folder}/yarp-devices-ros2/ros2_interfaces_ws/install/local_setup.bash" >> /home/user1/.entrypoint.sh +RUN echo 'exec "$@"' >> /home/user1/.entrypoint.sh +RUN chmod +x /home/user1/.entrypoint.sh + +WORKDIR ${user1_home} +#RUN sudo updatedb +ENTRYPOINT [ "/home/user1/.entrypoint.sh" ] +CMD ["bash"] diff --git a/docker_stuff/docker_sim_alt/README.md b/docker_stuff/docker_sim_alt/README.md new file mode 100644 index 0000000..32e0aae --- /dev/null +++ b/docker_stuff/docker_sim_alt/README.md @@ -0,0 +1,19 @@ +# Instructions + +## To download from DockerHub: + +- Start the image with: `./start-docker-sim.sh` + +## To build from Dockerfile: + +- Run: `./build-docker.sh` + +- Once finished, start the image with: `./start-docker-sim.sh` + +## to run with docker-compose: + +- run `docker-compose build` + +- run `sudo xhost +` + +- run `docker-compose up` diff --git a/docker_stuff/docker_openPose/common/xorg.conf b/docker_stuff/docker_sim_alt/common/xorg.conf similarity index 100% rename from docker_stuff/docker_openPose/common/xorg.conf rename to docker_stuff/docker_sim_alt/common/xorg.conf diff --git a/docker_stuff/docker_sim_alt/docker-compose.yml b/docker_stuff/docker_sim_alt/docker-compose.yml new file mode 100644 index 0000000..a01823a --- /dev/null +++ b/docker_stuff/docker_sim_alt/docker-compose.yml @@ -0,0 +1,74 @@ +version: "3.7" + +x-base: &base + environment: + - DISPLAY=${DISPLAY} + - XAUTHORITY=/home/user1/.Xauthority + - QT_X11_NO_MITSHM=1 +# - DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user1/1000/bus + - LIBGL_ALWAYS_INDIRECT=0 + - YARP_COLORED_OUTPUT=1 + # - YARP_CLOCK=/clock + - YARP_NAMESPACE=/root + - ROS_VERSION=2 + - ROS_PYTHON_VERSION=3 + - ROS_DISTRO=humble + - ROS_DOMAIN_ID=0 + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix:rw" + - "/etc/hosts:/etc/hosts" + - ".bashrc_local:/home/user1/.bashrc_local" + + network_mode: host + ipc: host + pid: host + privileged: true + security_opt: + - apparmor:unconfined + + +services: + +# Images + ros2-r1-sim: + image: elandini84/r1images:r1Sim2 + build: + dockerfile: Dockerfile + context: . + +# containers + terminator: + image: elandini84/r1images:r1Sim2 + <<: *base + container_name: terminator + command: bash -c "yarp conf 172.17.0.1 10000; terminator --no-dbus" + + yarpserver: + image: elandini84/r1images:r1Sim2 + <<: *base + container_name: yarpserver + command: bash -c "yarp conf 172.17.0.1 10000; yarpserver" + + gazebo: + image: elandini84/r1images:r1Sim2 + <<: *base + container_name: gazebo + command: bash -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; source /opt/ros/humble/setup.bash; ros2 launch gazebo_ros gazebo.launch.py world:=/home/user1/tour-guide-robot/app/maps/SIM_GAM/GAM.world" + depends_on: + - yarpserver + + yarpmanager: + image: elandini84/r1images:r1Sim2 + <<: *base + container_name: yarpmanager + command: bash -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; yarpmanager" + depends_on: + - yarpserver + + yarplogger: + image: elandini84/r1images:r1Sim2 + <<: *base + container_name: yarplogger + command: bash -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; yarplogger --start" + depends_on: + - yarpserver diff --git a/docker_stuff/docker_sim_alt/manage-docker.sh b/docker_stuff/docker_sim_alt/manage-docker.sh new file mode 100644 index 0000000..d5a9992 --- /dev/null +++ b/docker_stuff/docker_sim_alt/manage-docker.sh @@ -0,0 +1,197 @@ +#!/bin/bash + +############################################################ +# Help # +############################################################ +usage() +{ + # Display Help + echo "Syntax: ./build-docker.sh [options]" + echo "options:" + echo " -b, --build Use the passed options to build a new image. If not passed, the options passed will be used to identify the image to run" + echo " -c, --cuda Build/run the image from the nvidia cuda official image ($CUDA_DEF) and with the '$CUDA_SUFFIX' tag" + echo " -u, --ubuntu Build/run the image from the default ubuntu image ($UBUNTU_DEF) and with the '$UBUNTU_SUFFIX' tag" + echo " -s, --stable Build/run the image with the '$STABLE_SUFFIX' tag" + echo " -d, --devel Build/run the image with the '$DEVEL_SUFFIX' tag" + echo " -e, --repo + \"repo_name\" Build/run the image with the passed repository reference" + echo " -r, --ros_distro + \"distro_name\" Build/run the image with the passed distro (the passed value will be also used to compose the image tag)" + echo " -g, --gz_version + \"gz_version\" Build/run the image with the passed gazebo version (the passed value will be also used to compose the image tag)" + echo " -y, --yarp_branch + \"yarp branch\" Build/run the image with the passed yarp branch (the passed value, if different from \"master\", will be also used to compose the image tag)." + echo " If not passed, the branch used will be \"master\"" + echo " -h, --help See current help" + echo "If the parent image is not specified (neither -u nor -c), the '$UBUNTU_DEF' one will be used" + echo "If the build type is not specified (neither -d nor -s), the '$DEVEL_SUFFIX' tag will be used" + echo "If the ROS2 distro is not specified, 'humble' will be used." + echo "If the repository is not specified, $REPO_DEF will be used." + echo "WARNING: If a wrong ROS2 distro name is passed, the image build will fail" + + exit +} + +version() +{ + echo "Current version: $VERSION" + + exit +} + +get_opts() +{ + while [[ $# -gt 0 ]] + do + key="$1" + case $key in + -u|--ubuntu) + if [[ $IMAGE_SET == "true" ]]; then + echo "Image type already set" + usage + fi + shift + IMAGE=$UBUNTU_DEF + PARENT_SUFFIX=$UBUNTU_SUFFIX + IMAGE_SET=true + ;; + -c|--cuda) + if [[ $IMAGE_SET == "true" ]]; then + echo "Image type already set" + usage + fi + shift + IMAGE=$CUDA_DEF + PARENT_SUFFIX=$CUDA_SUFFIX + IMAGE_SET=true + ;; + -s|--stable) + if [[ $BUILD_SET == "true" ]]; then + echo "Build type already set" + usage + fi + shift + BUILD_SUFFIX=$STABLE_SUFFIX + BUILD_SET=true + ;; + -d|--devel) + if [[ $BUILD_SET == "true" ]]; then + echo "Build type already set" + usage + fi + shift + BUILD_SUFFIX=$DEVEL_SUFFIX + BUILD_SET=true + ;; + -r|--ros_distro) + if [[ $ROS_SET == "true" ]]; then + echo "ROS2 distro already set" + usage + fi + shift + ROS_DISTRO=$1 + ROS_SET=true + shift + ;; + -g|--gz_version) + if [[ $GZ_SET == "true" ]]; then + echo "Gazebo version already set" + usage + fi + shift + GZ_VERS=$1 + GZ_SET=true + shift + ;; + -y|--yarp_vers) + if [[ $YARP_SET == "true" ]]; then + echo "YARP branch already set already set" + usage + fi + shift + YARP_BRANCH=$1 + YARP_SET=true + shift + ;; + -e|--repository) + if [[ $REPO_SET == "true" ]]; then + echo "Remote repository already set" + usage + fi + shift + REPO=$1 + REPO_SET=true + shift + ;; + -b|--build) + shift + GONNA_BUILD=true + ;; + --nogpu) + shift + RUN_WITH_GPU=false + ;; + -h|--help) + usage + ;; + -v|--version) + version + ;; + *) + echo "Unsupported arg" + usage + ;; + esac + done +} + +############################################################ +############################################################ +# Main program # +############################################################ +############################################################ + +# Set default values +source ../docker_mng_vars.sh +BASE_TAG_DEF="tourSim2" + +#Set Variables +BUILD_SUFFIX=$DEVEL_SUFFIX +VERSION="1.0.0" +ROS_DISTRO=$ROS_DEF +GZ_VERS=$GAZEBO_DEF +YARP_BRANCH=$YARP_DEF +PARENT_SUFFIX=$UBUNTU_SUFFIX +IMAGE_SET=false +BUILD_SET=false +GONNA_BUILD=false +RUN_WITH_GPU=true +ROS_SET=false +GZ_SET=false +YARP_SET=false +IMAGE=$UBUNTU_DEF +REPO=$REPO_DEF +REPO_SET=false +BASE_TAG=$BASE_TAG_DEF + +############################################################ +# Process the input options. Add options as needed. # +############################################################ +# Get the options +get_opts $@ + +if [[ $YARP_BRANCH != "master" ]]; then + YARP_TAG=$YARP_BRANCH$JUNCTION +fi +COMPLETE_IMAGE_NAME=$REPO$REPO_SEP$BASE_TAG$JUNCTION$PARENT_SUFFIX$JUNCTION$ROS_DISTRO$JUNCTION$GZ_VERS$JUNCTION$YARP_TAG$BUILD_SUFFIX + +echo $COMPLETE_IMAGE_NAME + +if [[ $GONNA_BUILD == "true" ]]; then + sudo docker build --build-arg base_img=$IMAGE --build-arg ros_distro=$ROS_DISTRO --build-arg yarp_branch=$YARP_BRANCH --build-arg ros2_dev_branch=$ROS2_DEV_BRANCH --build-arg ros2_dev_remote=$ROS2_DEV_REMOTE -t $COMPLETE_IMAGE_NAME . +else + sudo xhost + + if [[ $RUN_WITH_GPU == "true" ]]; then + sudo docker run --rm -it --privileged --network host --pid host -e NVIDIA_DRIVER_CAPABILITIES=all -e DISPLAY -e ROS_DOMAIN_ID=${ROS_DOMAIN_ID} -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --gpus all $COMPLETE_IMAGE_NAME + elif [[ $RUN_WITH_GPU == "false" ]]; then + sudo docker run --rm -it --privileged --network host --pid host -e DISPLAY -e ROS_DOMAIN_ID=${ROS_DOMAIN_ID} -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 $COMPLETE_IMAGE_NAME bash + else + echo "ERROR: You cannot run a nVidia based image without gpu support" + fi +fi diff --git a/docker_stuff/docker_tourCore_alt/Dockerfile b/docker_stuff/docker_tourCore_alt/Dockerfile new file mode 100644 index 0000000..98f0f2f --- /dev/null +++ b/docker_stuff/docker_tourCore_alt/Dockerfile @@ -0,0 +1,275 @@ +ARG base_img +FROM $base_img +LABEL maintainer="Ettore Landini" + +ARG ros_distro +ARG yarp_branch="master" +ARG ros2_dev_remote="robotology" +ARG ros2_dev_branch=${yarp_branch} +ARG gazebo_pkg=ros-${ros_distro}-ros-gz + +# Non-interactive installation mode +ENV DEBIAN_FRONTEND=noninteractive +ENV DOCKER_UPDATED_ON=06_06_2024 + +# Install essentials +RUN apt-get update && apt-get install -y apt-utils software-properties-common sudo psmisc lsb-release protobuf-compiler libatlas-base-dev \ + tmux nano geany vim wget curl build-essential git gitk cmake cmake-curses-gui autoconf xserver-xorg-video-dummy xserver-xorg-legacy \ + net-tools terminator libjpeg-dev ffmpeg apt-transport-https ca-certificates gnupg libace-dev ycm-cmake-modules locales \ + python3-setuptools python3-pip iproute2 python3-tornado swig lsof iftop iputils-ping gdb bash-completion btop pipx && rm -rf /var/lib/apt/lists/* + +RUN pipx install numpy bpytop + +RUN sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config +COPY ./common/xorg.conf /etc/X11/xorg.conf + +# ROS2 Installation +RUN locale-gen en_US en_US.UTF-8 +RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +ENV LANG=en_US.UTF-8 +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 $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null +RUN apt-get update && apt-get upgrade -y && apt-get install -y ros-${ros_distro}-desktop ros-${ros_distro}-navigation2 ros-${ros_distro}-nav2-bringup \ + ros-${ros_distro}-slam-toolbox ros-${ros_distro}-test-msgs ${gazebo_pkg} \ + python3-colcon-common-extensions 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-pytest python3-pytest-cov python3-pytest-repeat \ + python3-pytest-rerunfailures python3-rosdep python3-vcstool && rosdep init && rm -rf /var/lib/apt/lists/* + +# Install yarp dependencies +RUN apt-get update && apt-get install -y libode8 libace-dev libboost-filesystem-dev libboost-system-dev \ + libboost-thread-dev libc6 python3 libgsl0-dev libncurses5-dev libsdl1.2-dev subversion git gfortran \ + libxmu-dev libode-dev wget unzip qtbase5-dev qtdeclarative5-dev qtmultimedia5-dev libqt5svg5 \ + libqt5opengl5-dev libopencv-dev freeglut3-dev libtinyxml-dev libblas-dev coinor-libipopt-dev \ + liblapack-dev libmumps-dev qml-module-qtmultimedia qml-module-qtquick-dialogs qml-module-qtquick-controls \ + qml-module-qt-labs-settings libqcustomplot-dev qml-module-qt-labs-folderlistmodel libedit-dev \ + libeigen3-dev libjpeg-dev libsimbody-dev libxml2-dev libjs-underscore portaudio19-dev libgtkmm-2.4-dev \ + libi2c-dev libv4l-dev + +# Create user: user1 +USER root +RUN useradd -l -u 33334 -G sudo -md /home/user1 -s /bin/bash -p user1 user1 && \ + # passwordless sudo for users in the 'sudo' group + sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers + +# ROS2 Installation (part2) +USER user1 +RUN sudo rosdep fix-permissions && rosdep update + +# Set ENV +USER user1 +RUN sudo mkdir /usr/local/src/robot +ENV robotology_install_user user1 +ENV user1_home /home/${robotology_install_user} +ENV robotology_install_folder /usr/local/src/robot +RUN sudo chown -R ${robotology_install_user}:${robotology_install_user} ${robotology_install_folder} + + +# Build ycm +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/ycm.git -b master +RUN cd ycm && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release && \ + make -j11 +ENV YCM_DIR=${robotology_install_folder}/ycm/build + +# Build YARP +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/yarp.git -b ${yarp_branch} +RUN cd yarp && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DYARP_COMPILE_libYARP_math=ON \ + -DYARP_COMPILE_GUIS=ON \ + -DYARP_COMPILE_DEVICE_PLUGINS=ON \ + -DENABLE_yarpcar_mjpeg=ON \ + -DENABLE_yarpcar_human=ON \ + -DENABLE_yarpcar_segmentationimage=ON \ + -DENABLE_yarpcar_portmonitor=ON \ + -DENABLE_yarpmod_portaudio=ON \ + -DENABLE_yarpmod_portaudioPlayer=ON \ + -DENABLE_yarpmod_portaudioRecorder=ON \ + -DENABLE_yarpmod_fakeBattery=ON \ + -DENABLE_yarpmod_controlboardwrapper2=ON \ + -DENABLE_yarpmod_laserFromDepth=ON \ + -DENABLE_yarpmod_laserFromExternalPort=ON \ + -DENABLE_yarpmod_laserFromDepth=ON \ + -DENABLE_yarpmod_laserFromPointCloud=ON \ + -DENABLE_yarpmod_laserFromRosTopic=ON \ + -DENABLE_yarppm_soundfilter_resample=ON \ + -DENABLE_yarppm_bottle_compression_zlib=ON \ + -DENABLE_yarppm_depthimage_compression_zlib=ON \ + -DENABLE_yarppm_image_compression_ffmpeg=ON \ + -DENABLE_yarppm_depthimage_to_mono=ON \ + -DENABLE_yarppm_depthimage_to_rgb=ON && \ + make -j11 +ENV YARP_ROOT=${robotology_install_folder}/yarp +ENV YARP_DIR=${robotology_install_folder}/yarp/build + +# YARP bindings +# USER ${robotology_install_user} +# WORKDIR ${robotology_install_folder} +# RUN cd yarp && cd bindings && mkdir build && cd build && cmake .. -DCREATE_PYTHON=ON && make -j11 + +# Install YARP completion +RUN sudo ln -s /usr/local/share/bash-completion/completions/yarp /usr/share/bash-completion/completions + +# Build icub-firmware-shared +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/icub-firmware-shared -b devel +RUN cd icub-firmware-shared && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release && make -j11 +ENV icub_firmware_shared_ROOT=${robotology_install_folder}/icub-firmware-shared +ENV icub_firmware_shared_DIR=${robotology_install_folder}/icub-firmware-shared/build + +# Build icub-main +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/icub-main.git -b devel +RUN cd icub-main && mkdir build && cd build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_icubmod_cartesiancontrollerserver=ON \ + -DENABLE_icubmod_cartesiancontrollerclient=ON \ + -DENABLE_icubmod_bcbBattery=ON \ + -DENABLE_icubmod_bmsBattery=ON \ + -DENABLE_icubmod_embObjBattery=ON \ + -DENABLE_icubmod_embObjAnalogSensor=ON \ + -DENABLE_icubmod_embObjFTsensor=ON \ + -DENABLE_icubmod_embObjIMU=ON \ + -DENABLE_icubmod_embObjInertials=ON \ + -DENABLE_icubmod_embObjMais=ON \ + -DENABLE_icubmod_embObjMotionControl=ON \ + -DENABLE_icubmod_embObjMultiEnc=ON \ + -DENABLE_icubmod_embObjPSC=ON \ + -DENABLE_icubmod_embObjSkin=ON \ + -DENABLE_icubmod_embObjStrain=ON \ + -DENABLE_icubmod_parametricCalibrator=ON \ + -DENABLE_icubmod_parametricCalibratorEth=ON \ + -DICUBMAIN_COMPILE_SIMULATORS=OFF \ + -DENABLE_icubmod_gazecontrollerclient=ON && \ + make -j11 +ENV ICUB_ROOT=${robotology_install_folder}/icub-main +ENV ICUB_DIR=${robotology_install_folder}/icub-main/build + +# Build robots-configuration devel +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/robots-configuration.git -b devel + +# Build navigation +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/navigation.git -b master +RUN cd navigation && mkdir build && cd build && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; cmake .. -DCMAKE_BUILD_TYPE=Release -DNAVIGATION_USE_NWC=ON -DNAVIGATION_USE_ROS2=ON" && make -j11 +ENV navigation_ROOT=${robotology_install_folder}/navigation +ENV navigation_DIR=${robotology_install_folder}/navigation/build + +# CER +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/cer.git +RUN cd cer && mkdir build && cd build && cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_cermod_cerDoubleLidar=ON \ + -DENABLE_cermod_cerOdometry=ON \ + -DENABLE_cermod_tripodMotionControl=ON && make -j11 +ENV CER_ROOT=${robotology_install_folder}/cer +ENV CER_DIR=${robotology_install_folder}/cer/build + +# CER-SIM +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/cer-sim -b ros2 +RUN cd cer-sim/colcon_ws && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; colcon build; source ${robotology_install_folder}/cer-sim/colcon_ws/install/local_setup.bash" + +# YARP-DEVICES-ROS2 +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/${ros2_dev_remote}/yarp-devices-ros2 -b ${ros2_dev_branch} +RUN cd yarp-devices-ros2/ros2_interfaces_ws && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; colcon build" +RUN cd yarp-devices-ros2 && mkdir build && cd build && /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; source ${robotology_install_folder}/yarp-devices-ros2/ros2_interfaces_ws/install/setup.bash; cmake .. -DYARP_ROS2_USE_SYSTEM_map2d_nws_ros2_msgs=ON -DYARP_ROS2_USE_SYSTEM_yarp_control_msgs=ON; make -j11" + +# YARP RPLidar Devices +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/yarp-device-rplidar -b master +RUN cd yarp-device-rplidar && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_rpLidar4=OFF && make -j11 +ENV yarp-device-rpLidar_ROOT=${robotology_install_folder}/yarp-device-rplidar +ENV yarp-device-rpLidar_DIR=${robotology_install_folder}/yarp-device-rplidar/build + +# Build icub-contrib-common +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/robotology/icub-contrib-common.git +RUN cd icub-contrib-common && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${robotology_install_folder}/iCubContrib && make -j11 install +ENV ICUBcontrib_DIR=${robotology_install_folder}/iCubContrib/lib +ENV ICUBcontrib_SHARE=${robotology_install_folder}/iCubContrib/share/ICUBcontrib + +# Set environmental variables +USER ${robotology_install_user} +RUN echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \$ '" >> /home/${robotology_install_user}/.bashrc +ENV TOUR_GUIDE_ROBOT_SOURCE_DIR=${robotology_install_folder}/tour-guide-robot +ENV PATH=$PATH:${YARP_DIR}/bin:${navigation_DIR}/bin:${CER_DIR}/bin:${ICUB_DIR}/bin:${ICUB_DIR}:${robotology_install_folder}/iCubContrib/bin:${robotology_install_folder}/Groot/build:${robotology_install_folder}/tour-guide-robot/build/bin:${robotology_install_folder}/icub-main/build:${TOUR_GUIDE_ROBOT_SOURCE_DIR}/app/navigation2/scripts:${TOUR_GUIDE_ROBOT_SOURCE_DIR}/app/headSynchronizer/scripts +ENV ROBOT_CODE=${robotology_install_folder} +ENV CER_SIM_ROOT_DIR=${ROBOT_CODE}/cer-sim +ENV DISPLAY=:1 +ENV LD_LIBRARY_PATH=${robotology_install_folder}/yarp/build/lib/yarp/ +ENV YARP_COLORED_OUTPUT=1 +ENV QT_X11_NO_MITSHM=1 +ENV PYTHONPATH=$PYTHONPATH:${robotology_install_folder}/yarp/bindings/build/lib/python3/ +ENV CYCLONEDDS_URI=${robotology_install_folder}/tour-guide-robot/app/navigation2/conf/cyclone_dds_settings.xml + +# Manage yarp port +EXPOSE 10000/tcp 10000/udp + +# Launch bash from ${robotology_install_folder} +USER ${robotology_install_user} +RUN sudo chown -R ${robotology_install_user}:${robotology_install_user} /opt/ros && sudo chown -R ${robotology_install_user}:${robotology_install_user} /home/${robotology_install_user}/.ros + +# Groot and BT dependencies +RUN sudo apt-get update && sudo apt-get install -y libgtest-dev libzmq3-dev libboost-dev qtbase5-dev libqt5svg5-dev libdw-dev && \ +cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo rm -rf /var/lib/apt/lists/* +USER ${robotology_install_user} +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/BehaviorTree/Groot.git +#RUN cd Groot && git submodule update --init --recursive && mkdir build && cd build && cmake .. && sudo make -j11 +RUN git clone https://github.com/elandini84/libfvad && cd libfvad && autoreconf -i && ./configure && sudo make install + +# Navigation stuff +WORKDIR ${robotology_install_folder} +RUN git clone https://github.com/elandini84/yarp-web-teleop.git && cd yarp-web-teleop && mkdir build && cd build && cmake .. +RUN git clone https://github.com/hsp-iit/tour-guide-robot -b ${ros_distro} +RUN /bin/bash -c "source /opt/ros/${ros_distro}/setup.bash; cd tour-guide-robot; mkdir build; cd build; cmake .. -DCMAKE_BUILD_TYPE=Release -DBTState=OFF -DENABLE_faceExpressionImage=ON; make -j11" + +ENV WEB_TELEOP_DIR=${robotology_install_folder}/yarp-web-teleop/build +ENV YARP_DATA_DIRS=${YARP_DIR}/share/yarp:${ICUB_DIR}/share/iCub:${navigation_DIR}/share/navigation:${robotology_install_folder}/tour-guide-robot/build/share/tour-guide-robot:${CER_DIR}/share/CER:${ICUBcontrib_DIR}/share/ICUBcontrib:${robotology_install_folder}/yarp-devices-ros2/build/share/yarp:${robotology_install_folder}/yarp-devices-ros2/build/share/yarp-devices-ros2:${robotology_install_folder}/yarp-device-rplidar/build/share/yarp:${ICUBcontrib_SHARE}:${WEB_TELEOP_DIR}/share/yarp-web-teleop + +# R1 NETWORK CONFIG +RUN yarp conf 192.168.100.10 10000 + +# Set up ONNX Runtime +WORKDIR ${robotology_install_folder} +RUN wget https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-1.20.1.tgz +RUN tar -xvzf onnxruntime-linux-x64-1.20.1.tgz +ENV ONNX_PATH=${robotology_install_folder}/onnxruntime-linux-x64-1.20.1 + +# Possibly temporary ROS2 network middleware change +RUN sudo apt-get update && sudo apt-get install -y cyclonedds-dev cyclonedds-tools \ +ros-${ros_distro}-cyclonedds-dbgsym ros-${ros_distro}-cyclonedds ros-${ros_distro}-rmw-cyclonedds-cpp \ +ros-${ros_distro}-rmw-cyclonedds-cpp-dbgsym libcycloneddsidl0 && \ +sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +RUN echo "#!/bin/bash" >> /home/user1/.entrypoint.sh +RUN echo ". /opt/ros/${ros_distro}/setup.bash" >> /home/user1/.entrypoint.sh +RUN echo ". ${robotology_install_folder}/yarp-devices-ros2/ros2_interfaces_ws/install/setup.bash" >> /home/user1/.entrypoint.sh +RUN echo ". ${robotology_install_folder}/tour-guide-robot/app/navigation2/scripts/evaluate_ip.sh" >> /home/user1/.entrypoint.sh +RUN echo 'exec "$@"' >> /home/user1/.entrypoint.sh +RUN chmod +x /home/user1/.entrypoint.sh +WORKDIR ${user1_home} +#RUN sudo updatedb +# Change the lidar devices permissions inside the docker to be able to start the devices with yarprobotinterface +ENTRYPOINT [ "/home/user1/.entrypoint.sh" ] +CMD if [ -e /dev/ttyUSB0 ]; then sudo chown user1:user1 /dev/ttyUSB0 && sudo chown user1:user1 /dev/ttyUSB1; fi && bash diff --git a/docker_stuff/docker_openPose/README.md b/docker_stuff/docker_tourCore_alt/README.md similarity index 66% rename from docker_stuff/docker_openPose/README.md rename to docker_stuff/docker_tourCore_alt/README.md index 7f89229..c748a35 100644 --- a/docker_stuff/docker_openPose/README.md +++ b/docker_stuff/docker_tourCore_alt/README.md @@ -9,3 +9,11 @@ - Run: `./build-docker.sh` - Once finished, start the image with: `./start-docker-core.sh` + +## to run with docker-compose: + +- run `docker-compose build` + +- run `sudo xhost +` + +- run `docker-compose up` diff --git a/docker_stuff/docker_tourCore_alt/common/xorg.conf b/docker_stuff/docker_tourCore_alt/common/xorg.conf new file mode 100644 index 0000000..5996be2 --- /dev/null +++ b/docker_stuff/docker_tourCore_alt/common/xorg.conf @@ -0,0 +1,23 @@ +Section "Monitor" + Identifier "Monitor0" + HorizSync 28.0-80.0 + VertRefresh 48.0-75.0 + # https://arachnoid.com/modelines/ + # 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz + Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync +EndSection +Section "Device" + Identifier "Card0" + Driver "dummy" + VideoRam 256000 +EndSection +Section "Screen" + DefaultDepth 24 + Identifier "Screen0" + Device "Card0" + Monitor "Monitor0" + SubSection "Display" + Depth 24 + Modes "1920x1080_60.00" + EndSubSection +EndSection diff --git a/docker_stuff/docker_tourCore_alt/docker-compose.yml b/docker_stuff/docker_tourCore_alt/docker-compose.yml new file mode 100644 index 0000000..c167f7c --- /dev/null +++ b/docker_stuff/docker_tourCore_alt/docker-compose.yml @@ -0,0 +1,70 @@ +version: "3.7" + +x-base: &base + environment: + - DISPLAY=${DISPLAY} + - XAUTHORITY=/home/user1/.Xauthority + - QT_X11_NO_MITSHM=1 +# - DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user1/1000/bus + - LIBGL_ALWAYS_INDIRECT=0 + - YARP_COLORED_OUTPUT=1 + # - YARP_CLOCK=/clock + - YARP_NAMESPACE=/root + volumes: + - "/tmp/.X11-unix:/tmp/.X11-unix:rw" + - "/etc/hosts:/etc/hosts" + - ".bashrc_local:/home/user1/.bashrc_local" + + network_mode: host + ipc: host + pid: host + privileged: true + security_opt: + - apparmor:unconfined + + +services: + +# Images + ros2-r1-sim: + image: elandini84/r1images:tourCore2_devel + build: + dockerfile: Dockerfile + context: . + +# containers + terminator: + image: elandini84/r1images:tourCore2_devel + <<: *base + container_name: terminator + command: sh -c "yarp conf 172.17.0.1 10000; terminator --no-dbus" + + yarpserver: + image: elandini84/r1images:tourCore2_devel + <<: *base + container_name: yarpserver + command: sh -c "yarp conf 172.17.0.1 10000; yarpserver" + + gazebo: + image: elandini84/r1images:tourCore2_devel + <<: *base + container_name: gazebo + command: bash -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; source /opt/ros/humble/setup.bash; ros2 launch gazebo_ros gazebo.launch.py world:=/home/user1/tour-guide-robot/app/maps/SIM_GAM/GAM.world" + depends_on: + - yarpserver + + yarpmanager: + image: elandini84/r1images:tourCore2_devel + <<: *base + container_name: yarpmanager + command: sh -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; yarpmanager" + depends_on: + - yarpserver + + yarplogger: + image: elandini84/r1images:tourCore2_devel + <<: *base + container_name: yarplogger + command: sh -c "yarp conf 172.17.0.1 10000; yarp wait $${YARP_NAMESPACE}; yarplogger --start" + depends_on: + - yarpserver diff --git a/docker_stuff/docker_tourCore_alt/manage-docker.sh b/docker_stuff/docker_tourCore_alt/manage-docker.sh new file mode 100644 index 0000000..8154bdc --- /dev/null +++ b/docker_stuff/docker_tourCore_alt/manage-docker.sh @@ -0,0 +1,194 @@ +#!/bin/bash + +############################################################ +# Help # +############################################################ +usage() +{ + # Display Help + echo "Syntax: ./build-docker.sh [options]" + echo "options:" + echo " -b, --build Use the passed options to build a new image. If not passed, the options passed will be used to identify the image to run" + echo " -c, --cuda Build/run the image from the nvidia cuda official image ($CUDA_DEF) and with the '$CUDA_SUFFIX' tag" + echo " -u, --ubuntu Build/run the image from the default ubuntu image ($UBUNTU_DEF) and with the '$UBUNTU_SUFFIX' tag" + echo " -s, --stable Build/run the image with the '$STABLE_SUFFIX' tag" + echo " -d, --devel Build/run the image with the '$DEVEL_SUFFIX' tag" + echo " -e, --repo + \"repo_name\" Build/run the image with the passed repository reference" + echo " -r, --ros_distro + \"distro_name\" Build/run the image with the passed distro (the passed value will be also used to compose the image tag)" + echo " -y, --yarp_branch + \"yarp branch\" Build/run the image with the passed yarp branch (the passed value, if different from \"master\", will be also used to compose the image tag)." + echo " If not passed, the branch used will be \"master\"" + echo " -p, --print Just print the image name that would be built/run with the passed options" + echo " -h, --help See current help" + echo "If the parent image is not specified (neither -u nor -c), the '$UBUNTU_DEF' one will be used" + echo "If the build type is not specified (neither -d nor -s), the '$DEVEL_SUFFIX' tag will be used" + echo "If the ROS2 distro is not specified, 'humble' will be used." + echo "If the repository is not specified, $REPO_DEF will be used." + echo "WARNING: If a wrong ROS2 distro name is passed, the image build will fail" + + exit +} + +version() +{ + echo "Current version: $VERSION" + + exit +} + +get_opts() +{ + while [[ $# -gt 0 ]] + do + key="$1" + case $key in + -u|--ubuntu) + if [[ $IMAGE_SET == "true" ]]; then + echo "Image type already set" + usage + fi + shift + IMAGE=$UBUNTU_DEF + PARENT_SUFFIX=$UBUNTU_SUFFIX + IMAGE_SET=true + ;; + -c|--cuda) + if [[ $IMAGE_SET == "true" ]]; then + echo "Image type already set" + usage + fi + shift + IMAGE=$CUDA_DEF + PARENT_SUFFIX=$CUDA_SUFFIX + IMAGE_SET=true + ;; + -s|--stable) + if [[ $BUILD_SET == "true" ]]; then + echo "Build type already set" + usage + fi + shift + BUILD_SUFFIX=$STABLE_SUFFIX + BUILD_SET=true + ;; + -d|--devel) + if [[ $BUILD_SET == "true" ]]; then + echo "Build type already set" + usage + fi + shift + BUILD_SUFFIX=$DEVEL_SUFFIX + BUILD_SET=true + ;; + -r|--ros_distro) + if [[ $ROS_SET == "true" ]]; then + echo "ROS2 distro already set" + usage + fi + shift + ROS_DISTRO=$1 + ROS_SET=true + shift + ;; + -y|--yarp_vers) + if [[ $YARP_SET == "true" ]]; then + echo "YARP branch already set already set" + usage + fi + shift + YARP_BRANCH=$1 + YARP_SET=true + shift + ;; + -e|--repository) + if [[ $REPO_SET == "true" ]]; then + echo "Remote repository already set" + usage + fi + shift + REPO=$1 + REPO_SET=true + shift + ;; + -b|--build) + shift + GONNA_BUILD=true + ;; + --nogpu) + shift + RUN_WITH_GPU=false + ;; + -h|--help) + usage + ;; + -p|--print) + shift + JUST_PRINT=true + ;; + -v|--version) + version + ;; + *) + echo "Unsupported arg" + usage + ;; + esac + done +} + +############################################################ +############################################################ +# Main program # +############################################################ +############################################################ + +# Set default values +source ../docker_mng_vars.sh +BASE_TAG_DEF="tourCore2" + +#Set Variables +JUST_PRINT=false +BUILD_SUFFIX=$DEVEL_SUFFIX +VERSION="1.0.0" +ROS_DISTRO=$ROS_DEF +YARP_BRANCH=$YARP_DEF +YARP_TAG="" +PARENT_SUFFIX=$UBUNTU_SUFFIX +IMAGE_SET=false +BUILD_SET=false +GONNA_BUILD=false +RUN_WITH_GPU=true +ROS_SET=false +YARP_SET=false +IMAGE=$UBUNTU_DEF +REPO=$REPO_DEF +REPO_SET=false +BASE_TAG=$BASE_TAG_DEF + +############################################################ +# Process the input options. Add options as needed. # +############################################################ +# Get the options +get_opts $@ + +if [[ $YARP_BRANCH != "master" ]]; then + YARP_TAG=$YARP_BRANCH$JUNCTION +fi +COMPLETE_IMAGE_NAME=$REPO$REPO_SEP$BASE_TAG$JUNCTION$PARENT_SUFFIX$JUNCTION$ROS_DISTRO$JUNCTION$YARP_TAG$BUILD_SUFFIX + +if [[ $JUST_PRINT == "true" ]]; then + echo $COMPLETE_IMAGE_NAME + exit +fi + +if [[ $GONNA_BUILD == "true" ]]; then + sudo docker build --build-arg base_img=$IMAGE --build-arg ros_distro=$ROS_DISTRO --build-arg yarp_branch=$YARP_BRANCH --build-arg ros2_dev_branch=$ROS2_DEV_BRANCH --build-arg ros2_dev_remote=$ROS2_DEV_REMOTE -t $COMPLETE_IMAGE_NAME . +else + sudo xhost + + if [[ $RUN_WITH_GPU == "true" ]]; then + sudo docker run --rm -it --privileged --network host --pid host -e NVIDIA_DRIVER_CAPABILITIES=all -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 --gpus all $COMPLETE_IMAGE_NAME + elif [[ $RUN_WITH_GPU == "false" && $IMAGE == $UBUNTU_DEF ]]; then + sudo docker run --rm -it --privileged --network host --pid host -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e QT_X11_NO_MITSHM=1 $COMPLETE_IMAGE_NAME + else + echo "ERROR: You cannot run a nVidia based image without gpu support" + fi +fi