< >
Home » ROS2入门教程 » ROS2入门教程-Mac下安装ROS2

ROS2入门教程-Mac下安装ROS2

ROS2入门教程-mac下安装ROS2

  • 介绍如何在Mac OS X 系统上安装ROS2

系统要求

  • 建议使用OS X 10.12.x.(ROS2也支持新版本的10.13.x和旧版本1的0.11.x、10.10.x)

安装步骤

  • [Xcode] 安装Xcode和命令行工具
$ xcode-select --install
  • [brew]

    • 可以参考http://brew.sh/进行安装

    • 可选:执行以下命令检查brew与系统是否冲突

$ brew doctor
  • 安装相关软件包
$ brew install cmake cppcheck eigen pcre poco python3 tinyxml wget

# install dependencies for Fast-RTPS if you are using it
$ brew install asio tinyxml2

$ brew install opencv

# install dependencies for rcl_logging_log4cxx
$ brew install log4cxx
  • 安装RViz的依赖
# install dependencies for Rviz
$ brew install qt freetype assimp

# Add the Qt directory to the PATH and CMAKE_PREFIX_PATH
export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/usr/local/opt/qt
export PATH=$PATH:/usr/local/opt/qt/bin
  • python3 -m pip安装更多软件
$ python3 -m pip install argcomplete catkin_pkg colcon-common-extensions coverage empy flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes lark-parser mock nose pep8 pydocstyle pyparsing setuptools vcstool
  • 安装ROS 1<->2 桥(选择安装)

    • Mac安装ROS1:参考链接

    • When you get to the step where you call rosinstall_generator to get the source code, here’s an alternate invocation that brings in just the minimum required to produce a useful bridge:

$ rosinstall_generator catkin common_msgs roscpp rosmsg --rosdistro kinetic --deps --wet-only --tar > kinetic-ros2-bridge-deps.rosinstall

$ wstool init -j8 src kinetic-ros2-bridge-deps.rosinstall

Otherwise, just follow the normal instructions, then source the resulting install_isolated/setup.bash before proceeding here to build ROS 2.

  • OS X versions >=10.11 have System Integrity Protection enabled by default. So that SIP doesn’t prevent processes from inheriting dynamic linker environment variables, such as DYLD_LIBRARY_PATH, you’ll need to disable it following these instructions.

  • 创建工作区并获取源码

$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
$ vcs import src < ros2.repos
  • 安装其他DDS vendors(选择安装)

    • ROS 2 builds on top of DDS. It is compatible with multiple DDS or RTPS (the DDS wire protocol) vendors. The repositories you downloaded for ROS 2 includes eProsima’s Fast RTPS, which is the only bundled vendor. If you would like to use one of the other vendors you will need to install their software separately before building. The ROS 2 build will automatically build support for vendors that have been installed and sourced correctly.

    • By default we include eProsima’s FastRTPS in the workspace and it is the default middleware. Detailed instructions for installing other DDS vendors are provided in the “Alternative DDS sources” section below.

  • 编译源码

$ cd ~/ros2_ws/
$ colcon build --symlink-install

测试使用

  • 运行talker-listener例子测试是否成功安装

  • 新终端,执行以下命令:

    $ . ~/ros2_ws/install/local_setup.bash
    $ ros2 run demo_nodes_cpp talker

  • 新终端,执行以下命令:

    $ . ~/ros2_ws/install/local_setup.bash
    $ ros2 run demo_nodes_cpp listener


参考链接

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2入门教程