ORB-SLAM2,ORB-SLAM3,ROS编译的Syntax check of ORB_SLAM2/manifest.xml failed解决

  • OpenCV version: 3.x
  • Eigen version: 3.x
  • Ubuntu version: 20.04
  • ros version: noetic
  • python -V: 2.7.18
  • python3 -V: 3.8.10

build.sh正常编译,但build_ros.sh编译不通过,报错如下:

[rosbuild] Building package ORB_SLAM2
[rosbuild] Error from syntax check of ORB_SLAM2/manifest.xml
Traceback (most recent call last):
  File "", line 1, in <module>
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/__init__.py", line 53, in <module>
    import roslib.stacks  # noqa: F401, I100
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/stacks.py", line 45, in <module>
    import roslib.packages
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/packages.py", line 48, in <module>
    from catkin.find_in_workspaces import find_in_workspaces as catkin_find
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin/find_in_workspaces.py", line 39, in <module>
    from catkin_pkg.packages import find_packages
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/packages.py", line 38, in <module>
    from .package import _get_package_xml
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/package.py", line 44, in <module>
    from catkin_pkg.condition import evaluate_condition
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/condition.py", line 17, in <module>
    import pyparsing as pp
  File "/opt/ros/noetic/lib/python3/dist-packages/pyparsing/__init__.py", line 101
    major: int
         ^
SyntaxError: invalid syntax
CMake Error at /opt/ros/noetic/share/ros/core/rosbuild/private.cmake:77 (message):
  [rosbuild] Syntax check of ORB_SLAM2/manifest.xml failed; aborting
Call Stack (most recent call first):
  /opt/ros/noetic/share/ros/core/rosbuild/public.cmake:174 (_rosbuild_check_manifest)
  CMakeLists.txt:4 (rosbuild_init)


-- Configuring incomplete, errors occurred!

CMake Error at /opt/ros/noetic/share/ros/core/rosbuild/private.cmake:77 (message):
[rosbuild] Syntax check of ORB_SLAM2/manifest.xml failed; aborting
Call Stack (most recent call first):
/opt/ros/noetic/share/ros/core/rosbuild/public.cmake:174 (_rosbuild_check_manifest)
CMakeLists.txt:4 (rosbuild_init)

下面是 /opt/ros/noetic/share/ros/core/rosbuild/private.cmake的部分内容:

# Check validity of manifest.xml, to avoid esoteric build errors
macro(_rosbuild_check_manifest)
  execute_process(
    COMMAND ${PYTHON_EXECUTABLE} -c "import roslib.manifest; roslib.manifest.parse_file('manifest.xml')"
    OUTPUT_VARIABLE _manifest_error
    ERROR_VARIABLE _manifest_error
    RESULT_VARIABLE _manifest_failed
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  if(_manifest_failed)
    message("[rosbuild] Error from syntax check of ${PROJECT_NAME}/manifest.xml")
    message("${_manifest_error}")
    message(FATAL_ERROR "[rosbuild] Syntax check of ${PROJECT_NAME}/manifest.xml failed; aborting")
  endif(_manifest_failed)
endmacro(_rosbuild_check_manifest)

可以看到manifest的error应该就是"import roslib.manifest; roslib.manifest.parse_file('manifest.xml')"的问题;

估计是ros的python版本问题,noetic将内容都放在了python3,而ORB-SLAM2的写法可能是在用python2.7;为此做一下测试:

~$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rospkg
>>> import roslib.manifest
>>> exit()

可以看到python3的import过程完全没有问题;

~$ python
Python 2.7.18 (default, Jul  1 2022, 12:27:04) 
[GCC 9.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rospkg
>>> import roslib.manifest
Traceback (most recent call last):
  File "", line 1, in <module>
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/__init__.py", line 53, in <module>
    import roslib.stacks  # noqa: F401, I100
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/stacks.py", line 45, in <module>
    import roslib.packages
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/packages.py", line 48, in <module>
    from catkin.find_in_workspaces import find_in_workspaces as catkin_find
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin/find_in_workspaces.py", line 39, in <module>
    from catkin_pkg.packages import find_packages
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/packages.py", line 38, in <module>
    from .package import _get_package_xml
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/package.py", line 44, in <module>
    from catkin_pkg.condition import evaluate_condition
  File "/opt/ros/noetic/lib/python3/dist-packages/catkin_pkg/condition.py", line 17, in <module>
    import pyparsing as pp
  File "/opt/ros/noetic/lib/python3/dist-packages/pyparsing/__init__.py", line 101
    major: int
         ^
SyntaxError: invalid syntax

很奇怪python2可以调用到rospkg,但在roslib上出了问题;

思路一是换默认python为python3.8,然后进入到ORB_SLAM2/Examples/ROS/ORB_SLAM2的目录下,做如下测试:

hazyparker@hazyparker-Lenovo-Air-14IML-2019:~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2$ python
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import roslib.manifest
>>> roslib.manifest.parse_file('manifest.xml')
<roslib.manifest.Manifest object at 0x7fbb72a16b40>

一切都很正常了,但是再运行./build_ros.sh还是报相同的manifest错误

解决

python版本原因,核心思想是让系统变量python指向python3而不是原来的python2;

不能是使用alias python="/usr/bin/python3.8",而是使用修改软连接的方式,让python指向python3;

你可能感兴趣的:(ROS,xml,python,ubuntu)