部署ROS2 Crystal版本遇到的一些问题

ROS2的Bouncy版本和Crystal版本有一些不小的差别,所以重新部署时会遇到另外一些问题

环境

  • 操作系统:macOS “Mojava” 10.14.5
  • 安装方式:二进制包安装
  • ROS2版本:Crystal

操作

$ colcon build --symlink-install

现象1

[1.511s] ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.shell.bash': cannot import name 'Interpreter' from 'em' (/usr/local/lib/python3.7/site-packages/em/__init__.py)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/colcon_core/entry_point.py", line 98, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/local/lib/python3.7/site-packages/colcon_core/entry_point.py", line 140, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/site-packages/colcon_bash/shell/bash.py", line 13, in <module>
    from colcon_core.shell.template import expand_template
  File "/usr/local/lib/python3.7/site-packages/colcon_core/shell/template/__init__.py", line 8, in <module>
    from em import Interpreter
ImportError: cannot import name 'Interpreter' from 'em' (/usr/local/lib/python3.7/site-packages/em/__init__.py)

解决办法1

谷歌了一些帖子,初步估计这个问题是因为emempy这两个包在python的包管理器中有同样的名字,如果两个都安装了,默认会找到em,所以出了问题。

  • em是一个终端工具,可以将标准输出的文件或标准输入打印出来,并突出显示与模式匹配的表达式。

  • empy是一个嵌入的python表达式和语句系统。它输入一个源文件,处理并输出,empy可以通过一些特殊的信号或符号来扩展Python的表达式和语句,以及各种特殊的语法形式。这种方式可以允许Python作为标记语言使用,还支持钩子回调、分流录制和回访、动态可链接的过滤器。

事实上ROS2中编译需要的是empy,但出现这个错误时,是因为pip3中同时安装了em,或者仅安装了em

解决办法就是删除em,并安装empy

$ pip3 uninstall em
$ pip3 install empy

现象2

--- stderr: examples_rclcpp_minimal_composition
CMake Error at /Users/hanhuijie/ros2_crystal_install/ros2-osx/share/class_loader/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package):
  By not providing "Findconsole_bridge.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "console_bridge", but CMake did not find one.

  Could not find a package configuration file provided by "console_bridge"
  with any of the following names:

    console_bridgeConfig.cmake
    console_bridge-config.cmake

  Add the installation prefix of "console_bridge" to CMAKE_PREFIX_PATH or set
  "console_bridge_DIR" to a directory containing one of the above files.  If
  "console_bridge" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /Users/hanhuijie/ros2_crystal_install/ros2-osx/share/class_loader/cmake/class_loaderConfig.cmake:38 (include)
  CMakeLists.txt:14 (find_package)

解决办法2

这是因为没有安装console_bridge的原因,在MacOS上比较简单,终端brew输入:

$ brew install console_bridge

console_bridge是一个独立于ROS的软件,使用CMake构建,重新实现了rosconsole的功能,即提供日志相关功能的输出接口,但是console_bridge是独立应用,不依赖于ROS。

参考

https://index.ros.org/doc/ros2/Tutorials/Colcon-Tutorial/
https://index.ros.org/doc/ros2/Installation/Crystal/OSX-Install-Binary/

你可能感兴趣的:(ROS,遇到的问题)