From a5749756c472823146cb50a5df94decc98d4dcaf Mon Sep 17 00:00:00 2001 From: Rooholla-KhorramBakht Date: Mon, 13 Jan 2025 08:28:24 +0800 Subject: [PATCH] docker updated. --- .devcontainer/Dockerfile | 71 +------------------ .devcontainer/Dockerfile.go2 | 15 ++-- .devcontainer/Dockerfile.x86 | 70 ++++++++++++++++++ .devcontainer/docker-compose.yaml | 5 +- deploy/docker/Dockerfile.mid360 | 3 +- deploy/docker/scripts/bridge_start.sh | 2 +- .../services/go2py-robot-description.service | 4 +- 7 files changed, 90 insertions(+), 80 deletions(-) mode change 100644 => 120000 .devcontainer/Dockerfile create mode 100644 .devcontainer/Dockerfile.x86 diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index ba80d1f..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,70 +0,0 @@ -FROM ros:humble -ENV DEBIAN_FRONTEND noninteractive -ARG CONDA_VER=latest -ARG OS_TYPE=x86_64 - -RUN apt-get update && apt-get install -y -qq --no-install-recommends \ - libglvnd-dev \ - libgl1-mesa-dev \ - libegl1-mesa-dev \ - libgles2-mesa-dev \ - libxext6 \ - libx11-6 \ - freeglut3-dev \ - git \ - python3-pip \ - python3-tk \ - curl \ - vim \ - libcgal-dev \ - libcgal-demo \ - ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl \ - libyaml-cpp-dev \ - ros-humble-xacro \ - libboost-all-dev\ - build-essential \ - cmake \ - git \ - wget \ - && rm -rf /var/lib/apt/lists/* - -RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash -RUN apt-get install git-lfs -# Install Miniconda -RUN wget https://github.com/conda-forge/miniforge/releases/${CONDA_VER}/download/Miniforge3-Linux-${OS_TYPE}.sh -O ~/miniconda.sh \ - && /bin/bash ~/miniconda.sh -b -p /opt/conda \ - && rm ~/miniconda.sh \ - && ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \ - && echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \ - && echo "conda activate base" >> ~/.bashrc - -ENV PATH /opt/conda/bin:$PATH -SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"] -ENV CONDA_PREFIX /opt/conda - -# Cheange the ROS2 RMW to CycloneDDS as instructed by Unitree -# RUN cd / && git clone https://github.com/unitreerobotics/unitree_ros2 && cd /unitree_ros2/cyclonedds_ws/src && \ -# git clone https://github.com/ros2/rmw_cyclonedds -b humble && git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.10.x &&\ -# cd .. && colcon build --packages-select cyclonedds && source /opt/ros/humble/setup.bash && colcon build - -# Install Python dependencies -RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 -RUN pip install matplotlib opencv-python proxsuite scipy isort black -RUN pip install warp-lang scikit-learn casadi -RUN pip install onnx onnxruntime -# RUN pip install cyclonedds pygame pynput jupyter ipykernel -RUN pip install meshcat mujoco -RUN conda install -y -c conda-forge \ - pinocchio \ - crocoddyl \ - mim-solvers - -# Set environmental variables required for using ROS -RUN echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc -RUN echo 'source /unitree_ros2/cyclonedds_ws/install/setup.bash' >> ~/.bashrc -RUN echo 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' >> ~/.bashrc -RUN echo 'export CYCLONEDDS_URI=file:///home/Go2py/Go2Py/assets/cyclonedds.xml' >> ~/.bashrc - -# Env vars for the nvidia-container-runtime. -ENV NVIDIA_VISIBLE_DEVICES all -ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 120000 index 0000000..e85a7ab --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1 @@ +Dockerfile.go2 \ No newline at end of file diff --git a/.devcontainer/Dockerfile.go2 b/.devcontainer/Dockerfile.go2 index 6afa223..a3e56e6 100644 --- a/.devcontainer/Dockerfile.go2 +++ b/.devcontainer/Dockerfile.go2 @@ -3,9 +3,10 @@ ENV DEBIAN_FRONTEND noninteractive ARG CONDA_VER=latest ARG OS_TYPE=aarch64 -RUN apt-get update && apt-get install -y -qq --no-install-recommends \ cuda \ +RUN apt-get update && apt-get install -y -qq --no-install-recommends cuda \ wget \ ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl \ + ros-humble-pcl-ros \ && rm -rf /var/lib/apt/lists/* # MID360 Lidar Drivers @@ -20,18 +21,22 @@ cd .. && colcon build --packages-select cyclonedds && source /opt/ros/humble/set RUN echo "export CYCLONEDDS_HOME=/unitree_ros2/cyclonedds_ws/install/cyclonedds/" >> ~/.bashrc +ENV CYCLONEDDS_HOME "/unitree_ros2/cyclonedds_ws/install/cyclonedds" RUN cd /root && git clone https://github.com/eclipse-cyclonedds/cyclonedds-python -b releases/0.10.x && cd cyclonedds-python && pip install . # CycloneDDS-cxx -RUN cd /root && git clone https://github.com/eclipse-cyclonedds/cyclonedds-cxx -b releases/0.10.x &&\ - cd cyclonedds-cxx && mkdir build install && cd build && cmake .. && \ - cmake --build . --target install +# RUN cd /root && git clone https://github.com/eclipse-cyclonedds/cyclonedds-cxx -b releases/0.10.x &&\ +# cd cyclonedds-cxx && mkdir build install && cd build && cmake .. && \ +# cmake --build . --target install # Install Python dependencies RUN pip install matplotlib opencv-python scipy isort black onnx onnxruntime RUN pip install https://github.com/NVIDIA/warp/releases/download/v1.5.1/warp_lang-1.5.1+cu11-py3-none-manylinux2014_aarch64.whl -RUN pip install cyclonedds pygame pynput jupyter ipykernel meshcat +RUN pip install pygame pynput jupyter ipykernel meshcat +RUN echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc + +# RUN echo "export CYCLONEDDS_URI=''" >> ~/.bashrc # RUN echo 'source /unitree_ros2/cyclonedds_ws/install/setup.bash' >> ~/.bashrc # RUN echo 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' >> ~/.bashrc # RUN echo 'export CYCLONEDDS_URI=file:///home/Go2py/Go2Py/assets/cyclonedds.xml' >> ~/.bashrc diff --git a/.devcontainer/Dockerfile.x86 b/.devcontainer/Dockerfile.x86 new file mode 100644 index 0000000..ba80d1f --- /dev/null +++ b/.devcontainer/Dockerfile.x86 @@ -0,0 +1,70 @@ +FROM ros:humble +ENV DEBIAN_FRONTEND noninteractive +ARG CONDA_VER=latest +ARG OS_TYPE=x86_64 + +RUN apt-get update && apt-get install -y -qq --no-install-recommends \ + libglvnd-dev \ + libgl1-mesa-dev \ + libegl1-mesa-dev \ + libgles2-mesa-dev \ + libxext6 \ + libx11-6 \ + freeglut3-dev \ + git \ + python3-pip \ + python3-tk \ + curl \ + vim \ + libcgal-dev \ + libcgal-demo \ + ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl \ + libyaml-cpp-dev \ + ros-humble-xacro \ + libboost-all-dev\ + build-essential \ + cmake \ + git \ + wget \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN apt-get install git-lfs +# Install Miniconda +RUN wget https://github.com/conda-forge/miniforge/releases/${CONDA_VER}/download/Miniforge3-Linux-${OS_TYPE}.sh -O ~/miniconda.sh \ + && /bin/bash ~/miniconda.sh -b -p /opt/conda \ + && rm ~/miniconda.sh \ + && ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \ + && echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \ + && echo "conda activate base" >> ~/.bashrc + +ENV PATH /opt/conda/bin:$PATH +SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"] +ENV CONDA_PREFIX /opt/conda + +# Cheange the ROS2 RMW to CycloneDDS as instructed by Unitree +# RUN cd / && git clone https://github.com/unitreerobotics/unitree_ros2 && cd /unitree_ros2/cyclonedds_ws/src && \ +# git clone https://github.com/ros2/rmw_cyclonedds -b humble && git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.10.x &&\ +# cd .. && colcon build --packages-select cyclonedds && source /opt/ros/humble/setup.bash && colcon build + +# Install Python dependencies +RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 +RUN pip install matplotlib opencv-python proxsuite scipy isort black +RUN pip install warp-lang scikit-learn casadi +RUN pip install onnx onnxruntime +# RUN pip install cyclonedds pygame pynput jupyter ipykernel +RUN pip install meshcat mujoco +RUN conda install -y -c conda-forge \ + pinocchio \ + crocoddyl \ + mim-solvers + +# Set environmental variables required for using ROS +RUN echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc +RUN echo 'source /unitree_ros2/cyclonedds_ws/install/setup.bash' >> ~/.bashrc +RUN echo 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' >> ~/.bashrc +RUN echo 'export CYCLONEDDS_URI=file:///home/Go2py/Go2Py/assets/cyclonedds.xml' >> ~/.bashrc + +# Env vars for the nvidia-container-runtime. +ENV NVIDIA_VISIBLE_DEVICES all +ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute \ No newline at end of file diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index c623dce..54b1edc 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -10,9 +10,12 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix - ../:/home/Go2py - /dev/input:/dev/input + - /dev/shm:/dev/shm + - /dev:/dev environment: - DISPLAY=${DISPLAY} - QT_X11_NO_MITSHM=1 runtime: nvidia stdin_open: true - tty: true \ No newline at end of file + tty: true + ipc: host \ No newline at end of file diff --git a/deploy/docker/Dockerfile.mid360 b/deploy/docker/Dockerfile.mid360 index a9edb0a..afca464 100644 --- a/deploy/docker/Dockerfile.mid360 +++ b/deploy/docker/Dockerfile.mid360 @@ -27,7 +27,8 @@ SHELL ["/bin/bash", "-c"] COPY docker/scripts/MID360_config.json /root/ws_livox/src/livox_ros_driver2/config/MID360_config.json COPY launch_files/msg_MID360_launch.py /root/ws_livox/src/livox_ros_driver2/launch_ROS2/msg_MID360_launch.py RUN cd /root/ws_livox/src/livox_ros_driver2 && source /opt/ros/humble/setup.sh && /bin/bash build.sh humble - +# Clone and compile FAST-LIO +RUN cd /root && mkdir -p fastlio-ws/src && cd fastlio-ws/src && git clone https://github.com/Ericsii/FAST_LIO.git --recursive && cd FAST_LIO && git checkout ros2 && cd /root/fastlio-ws && source /root/ws_livox/install/setup.bash && colcon build --symlink-install # Copy the script to start the nodes COPY docker/scripts/mid360_start.sh /root/mid360_start.sh # set the entrypoint to bash diff --git a/deploy/docker/scripts/bridge_start.sh b/deploy/docker/scripts/bridge_start.sh index 54d710c..5823081 100644 --- a/deploy/docker/scripts/bridge_start.sh +++ b/deploy/docker/scripts/bridge_start.sh @@ -2,6 +2,6 @@ source /opt/ros/humble/setup.bash source /unitree_ros2/cyclonedds_ws/install/setup.bash export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp export CYCLONEDDS_URI=' - + ' source /bridge_ws/install/setup.bash && ros2 launch /root/launch/bridge.launch.py \ No newline at end of file diff --git a/deploy/services/go2py-robot-description.service b/deploy/services/go2py-robot-description.service index 7f3554a..de1b18c 100644 --- a/deploy/services/go2py-robot-description.service +++ b/deploy/services/go2py-robot-description.service @@ -1,7 +1,7 @@ [Unit] Description=ROS2 device driver container -Requires=multi-user.target -After=multi-user.target +Requires=go2py-robot-description.service +After=go2py-robot-description.service [Service] Restart=always