abizovnuralem / go2_omniverse

Unitree Go2, Unitree G1 support for Nvidia Isaac Lab (Isaac Gym / Isaac Sim)
BSD 2-Clause "Simplified" License
395 stars 37 forks source link

[solved] No module named 'catkin_pkg' when run ./run_sim.sh at colcon build #28

Closed ShaoshuSu closed 3 months ago

ShaoshuSu commented 3 months ago

Just in case, if anyone is facing the same 'catkin_pkg' issue when run ./run_sim.sh in step colcon build, I can share some insight about how to solve it.

Starting >>> carter_navigation
Starting >>> custom_message
Starting >>> isaac_ros2_messages
Starting >>> isaac_ros_navigation_goal
Starting >>> isaac_tutorials
--- stderr: isaac_ros2_messages                                                                                                                                                                
Traceback (most recent call last):
  File "/opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:95 (message):
  execute_process(/home/shaoshu/anaconda3/bin/python3
  /opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /home/shaoshu/research/go2_omniverse/IsaacSim-ros_workspaces/humble_ws/src/isaac_ros2_messages/package.xml
  /home/shaoshu/research/go2_omniverse/IsaacSim-ros_workspaces/humble_ws/build/isaac_ros2_messages/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  /opt/ros/humble/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:32 (ament_lint_auto_find_test_dependencies)

---
Failed   <<< isaac_ros2_messages [0.16s, exited with code 1]
Aborted  <<< carter_navigation [0.16s]
Aborted  <<< custom_message [0.23s]                                                                                                         
Aborted  <<< isaac_tutorials [0.26s]
Aborted  <<< isaac_ros_navigation_goal [0.32s]                     

Summary: 0 packages finished [0.47s]
  1 package failed: isaac_ros2_messages
  4 packages aborted: carter_navigation custom_message isaac_ros_navigation_goal isaac_tutorials
  4 packages had stderr output: carter_navigation custom_message isaac_ros2_messages isaac_tutorials

As we need to use the python under /usr/bin/python3 to build the environment instead of conda environment, there are a few things you need to make sure:

  1. Disabling conda, as conda will use its own Python, will cause another No module named 'ament_package' issue. You can disable that by commenting conda related content in your ~/.bashrc
  2. similarly, if you are using vscode, remember to change your Python interpreter to /usr/bin/python3
  3. run printenv | grep PYTHONPATH to make sure your python env does not involve any conda, and it should looks like the following PYTHONPATH=/opt/ros/humble/lib/python3.10/site-packages:/opt/ros/humble/local/lib/python3.10/dist-packages
  4. Then pip install catkin_pkg to install catkin_pkg in python base env. I use pip uninstall catkin_pkg to uninstall all catkin_pkg in all other conda env as well.
  5. remember to use rm -rf build to remove the old build

Hope these help.

ShaoshuSu commented 3 months ago

I think I finally fully solved the environment problem for run ./run_sim.sh

I would suggest In first terminal does not involve any conda environment and build the workspace

source /opt/ros/humble/setup.bash
cd IsaacSim-ros_workspaces/humble_ws

rosdep install --from-paths src --ignore-src -r -y
rm -rf build
colcon build

cd ../..
cd go2_omniverse_ws
rosdep install --from-paths src --ignore-src -r -y
rm -rf build
colcon build
cd ..

In another new terminal activate your isaaclab environment and source setup.bash

conda activate isaaclab
source /opt/ros/humble/setup.bash
cd IsaacSim-ros_workspaces/humble_ws
source install/setup.bash

cd ../..
cd go2_omniverse_ws
source install/setup.bash
cd ..

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6

Then run the Python script python main.py --robot_amount 1 --robot go2

This should help to solve the whole branch of the environmental problem including

ModuleNotFoundError: No module named 'em' ModuleNotFoundError: No module named 'catkin_pkg'

ChristophKin commented 2 months ago

Just as a comment. I had the same ModuleNotFoundError: No module named 'catkin_pkg' error when I was updating the repo to the v0.2.0 release. For me, just adding the rm -rf build command before colcon build in the run_sim.sh file fixed the issue.