踩坑一周半,终于搞定,写一篇文章方便有相同需求的人参考
准备工作
1.根据go2_omniverse的官方仓库安装isaac sim 2023.1.1
位于https://github.com/abizovnuralem/go2_omniverse官方仓库README的Troubleshooting处,docker的安装和镜像源的配置我就不说了,网上教程很多。
这里也把那部分的教程复制过来,已经安装过isaac sim 2023.1.1的话可以忽略
Troubleshooting:
The version of Isaac Simulator 2023.1.1 is no longer available on Omniverse Launcher, what should I do?
Go to Container Installation
and follow all the steps in the Container Deployment section up to step 5).Modify the command in step 6) with:
bash docker pull nvcr.io/nvidia/isaac-sim:2023.1.1
Now run this command:
docker run --name isaac-sim --entrypoint bash -it --runtime=nvidia --gpus all -e “ACCEPT_EULA=Y” --rm --network=host \-e “PRIVACY_CONSENT=Y” \
-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
Open another terminal and run the command
bash docker ps
to find the container’s ID.From the terminal inside the container, run this command to copy the entire Isaac 2023.1.1 folder to a folder on your computer (I suggest naming it isaac-sim-2023.1.1 so that the setup commands above work):
bash docker cp <id_container>:isaac-sim/. <your_local_machine_folder> # absolute path
On your PC, you will have a folder named isaac-sim-2023.1.1. Move it to the following path:
bash .local/share/ov/pkg/
2.根据go2_omniverse的官方仓库的引导,安装orbit(也就是isaaclab,我安装的是0.3.1,不是最新的)
After installation of Nvidia Isaac Sim 2023.1.1 and Ros2 Humble:
- Clone this specific IsaacLab repo version: https://github.com/isaac-sim/IsaacLab/releases/tag/v0.3.1
- Execute in ubuntu terminal:
export ISAACSIM_PATH=“${HOME}/.local/share/ov/pkg/isaac-sim-2023.1.1”
export ISAACSIM_PYTHON_EXE=“${ISAACSIM_PATH}/python.sh”
and also put it inside .bashrc file- Inside the root folder of Orbit repo (https://github.com/isaac-sim/IsaacLab/releases/tag/v0.3.1) execute ln -s ${ISAACSIM_PATH} _isaac_sim
- Execute ./orbit.sh --conda
- Execute conda activate orbit
- Execute sudo apt install cmake build-essential
- Execute ./orbit.sh --install
- Execute ./orbit.sh --extra rsl_rl
- Verify the installation using “python source/standalone/tutorials/00_sim/create_empty.py” You should be inside conda env.
- You need to check that you have “Isaac Sim Python 2023.1.1 - New Stage*” on the top of the window.
- Clone this repo with git clone https://github.com/abizovnuralem/go2_omniverse/ --recurse-submodules -j8 --depth=1
- Copy the config file Unitree_L1.json (located in go2_omniverse/Isaac_sim/Unitree/Unitree_L1.json) for the Unitree L1 LiDAR to the folder IsaacLab-0.3.1/source/data/sensors/lidar/Unitree_L1.json (if the path doesnt exists, create it)
- Copy all material files in the isaac-sim-2023.1.1/data/material_files folder to IsaacLab_v0.3.1/source/data/material_files (if the path doesnt exists, create it)
Execute ./run_sim.sh (without activated conda orbit env)
这个时候就不要执行第14步
了,因为你没安装ros2humble,即使你安装了ros,这时候运行的话也会提示你找不到rclpy
与官方教程不同的地方
1.更改dockerfile
把go2_omniverse的仓库clone下来之后,有一个文件夹名字为IsaacSim-ros_workspaces
先cd到IsaacSim-ros_workspaces里面,执行:
cd xxx/go2_omniverse/IsaacSim-ros_workspaces #xxx替换为自己的路径
cp -r ../go2_omniverse_ws ./
把上级目录的go2_omniverse_ws
copy到这个文件夹里面(后面docker file的内容会用到),然后更改ubuntu_20_humble_minimal.dockerfile
文件内容如下:(主要是设置代理、go2_omniverse包的编译,以及在vcs import获取需要安装的包的时候新增一个tf2_ros包)
nano ubuntu_20_humble_minimal.dockerfile
ARG BASE_IMAGE=ubuntu:20.04
FROM ${BASE_IMAGE}
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV ROS_DISTRO=humble
ENV ROS_ROOT=humble_ws
ENV ROS_PYTHON_VERSION=3
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /workspace
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
cmake \
build-essential \
curl \
wget \
gnupg2 \
lsb-release
# Upgrade installed packages
RUN apt update && apt upgrade -y && apt clean
# Install Python3.10
RUN apt update && \
apt install --no-install-recommends -y build-essential software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt install --no-install-recommends -y python3.10 python3.10-dev python3.10-distutils
# Setting up locale stuff
RUN apt update && apt install locales
RUN locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8
# Set default Python3 to Python3.10
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
# Pip install stuff
RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python3.10 get-pip.py --force-reinstall && \
rm get-pip.py
RUN wget --no-check-certificate https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc && apt-key add ros.asc
RUN 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 pip3 install setuptools==70.0.0
RUN apt update && apt install -y \
python3-pip \
python3-pytest-cov \
python3-rosinstall-generator \
ros-dev-tools \
libbullet-dev \
libasio-dev \
libtinyxml2-dev \
libcunit1-dev \
libacl1-dev
RUN python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest \
lark
RUN python3.10 -m pip uninstall numpy -y
RUN python3.10 -m pip install --upgrade pip
RUN python3.10 -m pip install numpy
RUN mkdir -p ${ROS_ROOT}/src && \
cd ${ROS_ROOT} && \
rosinstall_generator --deps --rosdistro ${ROS_DISTRO} rosidl_runtime_c rcutils rcl rmw tf2 tf2_msgs tf2_ros geometry_msgs nav_msgs std_msgs rosgraph_msgs sensor_msgs vision_msgs rclpy ros2topic ros2pkg ros2doctor ros2run ros2node ros_environment ackermann_msgs example_interfaces > ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall && \
cat ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall && \
vcs import src < ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall
RUN rosdep init && rosdep update
# Build ROS workspace set python3 flag for some reason still default remains python3.8 when colcon building
RUN cd ${ROS_ROOT} && colcon build --cmake-args ' -DPython3_EXECUTABLE=/usr/bin/python3.10' --merge-install
# Need these to maintain compatibility on non 20.04 systems
RUN cp /usr/lib/x86_64-linux-gnu/libtinyxml2.so* /workspace/humble_ws/install/lib/
RUN cp /usr/lib/x86_64-linux-gnu/libssl.so* /workspace/humble_ws/install/lib/
RUN cp /usr/lib/x86_64-linux-gnu/libcrypto.so* /workspace/humble_ws/install/lib/
# Next, build the additional workspace
RUN cd ${WORKDIR} && mkdir build_ws
COPY humble_ws build_ws
RUN /bin/bash -c "source ${ROS_ROOT}/install/setup.sh && cd build_ws && colcon build --cmake-args ' -DPython3_EXECUTABLE=/usr/bin/python3.10' --packages-select custom_message --merge-install"
# jaye:Add go2_ominiverse
RUN cd ${WORKDIR} && mkdir go2_ws
COPY go2_omniverse_ws go2_ws
RUN /bin/bash -c "source ${ROS_ROOT}/install/setup.sh && cd build_ws && colcon build --cmake-args ' -DPython3_EXECUTABLE=/usr/bin/python3.10' --merge-install"
2.运行dockerfile,生成docker image
请不要直接运行我的命令,你需要把端口号替换成你已经配置好的代理的端口号,如果权限不足请 sudo docker build...
【自行配置梯子,没有梯子无法安装】
docker build . --build-arg HTTP_PROXY=http://127.0.0.1:33439 \
--build-arg HTTPS_PROXY=http://127.0.0.1:33439 \
--network=host -f ubuntu_20_humble_minimal.dockerfile -t \
isaac_sim_ros:ubuntu_20_humble
编译过程应该不会出现错误的情况
这里提一嘴我遇到过的:ERROR:colcon:colcon build: The install directory 'install' was created with the layout 'isolated'.Please remove the install directory, pick a different one or remove the ‘–>merge-install’ option.
这是因为你的某个workspace(即你电脑上IsaacSim-ros_workspaces文件夹底下的humble_ws
和go2_omniverse_ws
里面,可能存在着以前编译过的数据,此时需要cd到里面,把build、devel、log、install文件夹都删掉,即:
cd xxx_ws #某一个曾经编译过的workspace
rm -rf build/ devel/ install/ log/
3.通过上面生成的镜像,创建一个容器
从这里开始,我的docker相关命令都不会带sudo,如果你有需求请自己加上sudo
首先你可以用docker images
确定镜像是否创建成功,我的输出是这样的,可以看到isaac_sim_ros:ubuntu_20_humble
创建成功了:
REPOSITORY TAG IMAGE ID CREATED SIZE
isaac_sim_ros ubuntu_20_humble cbdd132419a0 6 hours ago 1.74GB
ubuntu latest b1d9df8ab815 4 weeks ago 78.1MB
nvcr.io/nvidia/isaac-sim 4.2.0 f02b85d71f1a 2 months ago 17.6GB
nvcr.io/nvidia/isaac-sim 2023.1.1 c5b38d11a98d 12 months ago 19.2GB
hello-world latest d2c94e258dcb 19 months ago 13.3kB
此时创建这个镜像的容器:(为了让容器内也可以用梯子,我加了--network='host'
)
docker run --network='host' --name new-humble -it isaac_sim_ros:ubuntu_20_humble
我把它命名为new-humble,你也可以取其他名字,后续教程中的内容自行替换即可
4.此时你已经进入new-humble容器内,开始编译新的包
如果你exit之后想再次进入,可以:
docker start new-humble
docker exec -it new-humble /bin/bash
在容器内,你已经处于/workspace目录下:/workspace#
你可以检查tf2_ros包是否安装成功:
source /workspace/humble_ws/install/setup.bash
source /workspace/build_ws/install/setup.bash
source /workspace/go2_ws/install/setup.bash
python3
然后在python里面 import tf2_ros
如果没有,没关系,接下来再安装一下:
cd到build_ws/src下,把需要安装的包给git clone下来:
cd build_ws/src
git clone -b humble https://github.com/ros2/geometry2.git #tf2_ros源码
git clone -b humble https://github.com/ros2/common_interfaces.git #sensor_msgs_py源码
cd common_interfaces
cp -r ./sensor_msgs_py .. #把sensor_msgs_py拷贝到上层目录,即src里面
cd .. #返回src
rm -rf common_interfaces #只需要sensor_msgs_py,而不需要common_interfaces里面的其它包
cd .. #返回build_ws
source /workspace/humble_ws/install/setup.bash
colcon build --merge-install --packages-ignore tf2_eigen_kdl tf2_sensor_msgs tf2_eigen examples_tf2_py tf2_geometry_msgs tf2_kdl test_tf2 #不安装这些,因为会报错...
编译应该可以顺利完成(忽略warning,只要没有abort就ok)
5.新建一个终端,创建并运行build_new_humble.sh文件
还是在IsaacSim-ros_workspaces目录下:
touch build_new_humble.sh
nano build_new_humble.sh
将以下内容粘贴进去:(如果你前面创建容器名称和我不一样,注意修改容器的名称)
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -rf build_ws/humble
mkdir -p build_ws/humble
pushd build_ws/humble
docker cp new-humble:/workspace/humble_ws humble_ws
docker cp new-humble:/workspace/build_ws isaac_sim_ros_ws
docker cp new-humble:/workspace/go2_ws go2_omniverse_ws
popd
这里解释一下我相对于build_humble.sh
更改的地方:
1.删去了docker build,因为前面已经单独运行了
2.从已经创建的镜像里面copy文件出来,而不是每次copy创建新文件
3.go2_omniverse的工作空间也copy出来
此时运行build_new_humble.sh
./build_new_humble.sh
6.运行go2
新建一个终端,然后
conda deactivate
cd xxx/go2_omniverse/IsaacSim-ros_workspaces #填上你对应的路径
source build_ws/humble/humble_ws/install/setup.bash
#因为isaac_sim_ros_ws是在docker内build的,所以setup.sh会引入docker内路径,所以在主机端,要source local_setup.bash
source build_ws/humble/isaac_sim_ros_ws/install/local_setup.bash
source build_ws/humble/go2_omniverse_ws/install/local_setup.bash
eval "$(conda shell.bash hook)"
conda activate orbit
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
cd .. #返回go2_omniverse文件夹
python main.py --robot_amount 1 --robot go2 --terrain flat
如果你是vnc远程桌面跑isaacsim,你还需要加一句:
export MESA_GL_VERSION_OVERRIDE=4.6
否则你启动不起来
如果是vnc,想要提高渲染帧率,有两个方法:
1.用tigervnc,然后调低画质(turbovnc帧率更低)
2.如果你有多个显卡,设置:
export CUDA_VISIBLE_DEVICES=0
(isaac sim默认第0个显卡,且很难改变…)
这个地图是平路,如果你想像go2仓库的例子那样有楼梯,可以:
python main.py --robot_amount 1 --robot go2 --terrain rough
运行成功后,你可以在isaacsim内通过键盘操纵go2:WASD前后左右,QE是旋转
7.其它问题:
因为ros2 humble是最小安装,所以还缺少很多包,我试过full安装,编译过不去的,所以rviz等应该会受到影响或者不能使用,我目前还没用rviz,所以这篇文章就到此结束