【IsaacSim】【unitree go2_omniverse】Ubuntu20.04下Docker部署与ROS2集成的完整指南

张开发
2026/4/5 4:42:58 15 分钟阅读

分享文章

【IsaacSim】【unitree go2_omniverse】Ubuntu20.04下Docker部署与ROS2集成的完整指南
1. 环境准备与基础配置在Ubuntu 20.04系统上部署Isaac Sim与ROS2 Humble的集成环境首先需要确保基础环境配置正确。我实测下来系统版本和驱动兼容性是最容易出问题的环节。建议先执行以下命令检查NVIDIA驱动状态nvidia-smi如果显示No devices were found说明驱动未正确安装。这时需要先处理驱动问题否则后续Docker GPU支持会失败。我推荐使用官方驱动仓库安装sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt update sudo ubuntu-drivers autoinstall安装完成后重启系统。接下来配置Docker环境时有个容易忽略的细节必须安装nvidia-container-toolkit。很多教程会漏掉这一步导致后续无法调用GPU。完整安装命令如下sudo apt-get install docker.io sudo systemctl enable --now docker distribution$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update sudo apt-get install -y nvidia-container-toolkit sudo systemctl restart docker验证Docker GPU支持是否正常docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi2. Isaac Sim Docker镜像部署官方提供的Isaac Sim 2023.1.1镜像已经不在Omniverse Launcher中提供必须通过Docker方式获取。这里有个关键点镜像体积约19GB下载前确保有足够磁盘空间。我建议使用以下命令拉取镜像docker pull nvcr.io/nvidia/isaac-sim:2023.1.1启动容器时需要特别注意挂载点的配置。经过多次测试以下是最稳定的启动参数docker run --name isaac-sim --entrypoint bash -it --runtimenvidia --gpus all \ -e ACCEPT_EULAY --rm --networkhost \ -e PRIVACY_CONSENTY \ -v ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw \ -v ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw \ -v ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw \ -v ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw \ -v ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw \ -v ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \ -v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \ -v ~/docker/isaac-sim/documents:/root/Documents:rw \ nvcr.io/nvidia/isaac-sim:2023.1.1进入容器后需要将Isaac Sim文件复制到本地。这个步骤容易被忽略但至关重要docker cp container_id:/isaac-sim ~/isaac-sim-2023.1.1 mv ~/isaac-sim-2023.1.1 ~/.local/share/ov/pkg/3. ROS2 Humble环境搭建ROS2 Humble需要与Python 3.10配合使用而Ubuntu 20.04默认是Python 3.8。我踩过的坑是直接安装会导致版本冲突正确的做法是sudo add-apt-repository ppa:deadsnakes/ppa sudo apt install python3.10 python3.10-dev sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2 sudo update-alternatives --config python3安装ROS2 Humble时建议使用minimal安装后续再补充需要的包sudo apt install software-properties-common sudo add-apt-repository universe sudo apt update sudo apt install curl sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg 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 | sudo tee /etc/apt/sources.list.d/ros2.list /dev/null sudo apt update sudo apt install ros-humble-ros-base配置环境变量时建议直接写入.bashrcecho source /opt/ros/humble/setup.bash ~/.bashrc source ~/.bashrc4. Unitree GO2与Omniverse集成首先需要安装OrbitIsaacLab0.3.1版本这是与Unitree GO2兼容的特定版本git clone --branch v0.3.1 https://github.com/isaac-sim/IsaacLab.git cd IsaacLab export ISAACSIM_PATH${HOME}/.local/share/ov/pkg/isaac-sim-2023.1.1 export ISAACSIM_PYTHON_EXE${ISAACSIM_PATH}/python.sh ln -s ${ISAACSIM_PATH} _isaac_sim ./orbit.sh --conda conda activate orbit sudo apt install cmake build-essential ./orbit.sh --install ./orbit.sh --extra rsl_rl验证安装是否成功python source/standalone/tutorials/00_sim/create_empty.py接着配置Unitree GO2相关文件git clone https://github.com/abizovnuralem/go2_omniverse --recurse-submodules -j8 --depth1 cp go2_omniverse/Isaac_sim/Unitree/Unitree_L1.json IsaacLab-0.3.1/source/data/sensors/lidar/ mkdir -p IsaacLab-0.3.1/source/data/material_files cp -r isaac-sim-2023.1.1/data/material_files/* IsaacLab-0.3.1/source/data/material_files/5. Docker镜像定制与ROS2集成创建自定义Dockerfile时有几个关键修改点必须指定Python 3.10为默认Python版本需要添加tf2_ros等必要的ROS2包要正确配置工作空间依赖关系以下是经过验证的Dockerfile核心内容FROM ubuntu:20.04 ARG ROS_DISTROhumble ENV DEBIAN_FRONTENDnoninteractive RUN apt update apt install -y \ git cmake build-essential curl wget gnupg2 lsb-release \ python3.10 python3.10-dev python3.10-distutils RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ python3.10 get-pip.py \ rm get-pip.py RUN wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc \ apt-key add ros.asc \ sh -c echo deb [arch$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main /etc/apt/sources.list.d/ros2-latest.list RUN apt update apt install -y \ ros-${ROS_DISTRO}-ros-base \ python3-colcon-common-extensions \ libbullet-dev libasio-dev libtinyxml2-dev构建镜像时需要注意网络配置docker build -f ubuntu_20_humble_minimal.dockerfile -t isaac_sim_ros:ubuntu_20_humble .6. 工作空间编译与问题排查编译ROS2工作空间时最常见的错误是Python版本冲突。必须明确指定Python 3.10colcon build --cmake-args -DPython3_EXECUTABLE/usr/bin/python3.10 --merge-install如果遇到install directory was created with the layout isolated错误需要清理旧编译文件rm -rf build/ install/ log/验证tf2_ros是否安装成功source install/setup.bash python3 -c import tf2_ros; print(tf2_ros.__file__)7. 运行Unitree GO2仿真最后启动仿真时有几个关键环境变量需要设置conda activate orbit export LD_PRELOAD/usr/lib/x86_64-linux-gnu/libstdc.so.6 source humble_ws/install/setup.bash source isaac_sim_ros_ws/install/local_setup.bash source go2_omniverse_ws/install/local_setup.bash python main.py --robot_amount 1 --robot go2 --terrain flat如果使用远程桌面还需要设置export MESA_GL_VERSION_OVERRIDE4.6 export CUDA_VISIBLE_DEVICES0控制Unitree GO2移动时W/S键控制前进/后退A/D键控制左右移动Q/E键控制左右旋转

更多文章