Home » ROS2入门教程 » ROS2入门教程-源码安装ros1_bridge

ROS2入门教程-源码安装ros1_bridge

ROS2入门教程-源码安装ros1_bridge

说明:

  • 介绍如何源码安装ros1_bridge

步骤:

  • 安装ros2 foxy,参考教程
  • 路径为:~/ros2_foxy/src
  • 安装ros1 noetic,参考教程
  • 路径为:/opt/ros/noetic/setup.bash
  • 新建目录
mkdir -p ~/colcon_ws/src
cd ~/colcon_ws/src
git clone https://github.com/ros2/ros1_bridge
  • 暂时不能加载ros1的工作空间,编译
colcon build --symlink-install --packages-skip ros1_bridge
  • 加载ros1工作空间
source /opt/ros/melodic/setup.bash
  • 再加载ros2工作空间
. <install-space-with-ros2>/local_setup.bash
  • 最后在编译ros1_bridge
colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure

测试:

  • 启动ros1的roscore
# Shell A (ROS 1 only):
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
roscore
  • 启动bridge
# Shell B (ROS 1 + ROS 2):
# Source ROS 1 first:
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
# Source ROS 2 next:
. <install-space-with-bridge>/setup.bash
# For example:
# . /opt/ros/dashing/setup.bash
export ROS_MASTER_URI=http://localhost:11311
ros2 run ros1_bridge dynamic_bridge
  • ros1下发布talker话题
# Shell C:
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
rosrun rospy_tutorials talker
  • ros2下订阅话题
# Shell D:
. <install-space-with-ros2>/setup.bash
ros2 run demo_nodes_cpp listener

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

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


标签: ros2入门教程