From 84738c56a834110bc094c83c69c77f78803b4546 Mon Sep 17 00:00:00 2001 From: mateo Date: Mon, 12 Jan 2026 17:41:44 -0700 Subject: [PATCH] adding ros2 humble install to dockerfile; created conda_overlay_ros2.sh script which allows ros2 humble commands (which work on python 3.10) to work in the conda 3.11 environment humanoid_sim_env --- Dockerfile | 29 +++++++++++++++++++++++++---- conda_overlay_ros2.sh | 26 ++++++++++++++++++++++++++ docker_run.sh | 2 +- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 conda_overlay_ros2.sh diff --git a/Dockerfile b/Dockerfile index 1317d6b..6012685 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://us.archive.ubuntu.com/ubu # Install build dependencies + X11 support for GUI rendering RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc-12 g++-12 cmake build-essential unzip git-lfs wget \ + gcc-12 g++-12 cmake build-essential curl unzip git-lfs wget \ libglu1-mesa-dev vulkan-tools libvulkan1 \ libx11-6 libxext6 libxrender1 libxi6 libxrandr2 libxcursor1 libxinerama1 \ libgl1-mesa-glx libglib2.0-0 libsm6 libxt6 libxkbcommon-x11-0 \ @@ -100,12 +100,29 @@ RUN git clone https://github.com/unitreerobotics/unitree_rl_lab.git /home/code/u ./source/unitree_rl_lab/unitree_rl_lab/assets/robots/unitree.py && \ ./unitree_rl_lab.sh -i + # Clone H12 Lab Docs RUN git clone https://github.com/correlllab/h12-lab-docs.git /home/code/h12-lab-docs # Clone H12 Stand RUN git clone https://github.com/correlllab/h12_stand.git /home/code/h12_stand +#Setup sources +RUN set -eux; \ + ROS_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}'); \ + curl -L -o /tmp/ros2.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_VERSION}/ros2-apt-source_${ROS_VERSION}.$(. /etc/os-release && echo $VERSION_CODENAME)_all.deb"; \ + dpkg -i /tmp/ros2.deb; \ + rm /tmp/ros2.deb + +#Install ros humble desktop and rmw cyclonedds cpp implementation +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-desktop \ + ros-humble-rmw-cyclonedds-cpp \ + && rm -rf /var/lib/apt/lists/* + +#Set environment variables +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp +ENV ROS_DISTRO=humble # ============================== # Stage 2: Runtime # ============================== @@ -134,19 +151,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY --from=builder /home/code /home/code COPY --from=builder /cyclonedds /cyclonedds COPY --from=builder /opt/conda /opt/conda +COPY --from=builder /opt/ros/humble /opt/ros/humble +COPY conda_overlay_ros2.sh /home/code/conda_overlay_ros2.sh # Initialize bashrc (removed OMNI_KIT_DISABLE_STARTUP) RUN echo 'source /opt/conda/etc/profile.d/conda.sh' >> ~/.bashrc && \ echo 'conda activate humanoid_sim_env' >> ~/.bashrc && \ + echo 'chmod +x /home/code/conda_overlay_ros2.sh && . /home/code/conda_overlay_ros2.sh' >> ~/.bashrc && \ + echo 'source /opt/ros/humble/setup.sh' >> ~/.bashrc && \ echo 'export OMNI_KIT_ALLOW_ROOT=1' >> ~/.bashrc && \ echo 'export OMNI_KIT_ACCEPT_EULA=yes' >> ~/.bashrc && \ echo 'export UNITREE_MODEL_DIR=/home/code/unitree_model' >> ~/.bashrc && \ echo 'export UNITREE_ROS_DIR=/home/code/unitree_ros' >> ~/.bashrc && \ - echo 'export CYCLONEDDS_HOME=/cyclonedds/install' >> ~/.bashrc - + echo 'export CYCLONEDDS_HOME=/cyclonedds/install' >> ~/.bashrc && \ + echo 'export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp' >> ~/.bashrc WORKDIR /home/code # Default to Conda environment bash -CMD ["conda", "run", "-n", "humanoid_sim_env", "/bin/bash"] \ No newline at end of file +CMD ["conda", "run", "-n", "humanoid_sim_env", "/bin/bash"] diff --git a/conda_overlay_ros2.sh b/conda_overlay_ros2.sh new file mode 100644 index 0000000..ba1aba7 --- /dev/null +++ b/conda_overlay_ros2.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +#source conda rq +source /opt/conda/etc/profile.d/conda.sh + +#update and install required python packages +echo 'installing: python3.10; libpython3.10-dev; libspdlog-dev; pip' +apt update && apt install python3.10 libpython3.10-dev libspdlog-dev pip -y + +#symlink target /usr/bin/python3.10 to link /usr/bin/python +ln -s /usr/bin/python3.10 /usr/bin/python + +#setting up python3.10 executable along with conda's executable +update-alternatives --install /usr/bin/python python /usr/bin/python3.10 2 + +#momentarily deactivate conda and set the python executable in /usr/bin to take precendence +conda deactivate +export PATH=/usr/bin:$PATH + +#install required pip packages +echo 'pip installing: packaging; numpy; netifaces; pyyaml' +python -m pip install packaging numpy netifaces pyyaml + +#reactivate conda env +conda activate humanoid_sim_env + diff --git a/docker_run.sh b/docker_run.sh index 2ac5400..cf0f1f7 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -28,4 +28,4 @@ docker run --gpus all -it --rm \ --publish 8211:8211 \ --publish 8899:8899 \ humanoid-sim:latest \ - /bin/bash \ No newline at end of file + /bin/bash