ROS1 ROS2之间通信——ros1_bridge

From https://github.com/ros2/ros1_bridge

First we start a ROS 1 roscore:

# Shell A (ROS 1 only):
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
roscore

Then we start the dynamic bridge which will watch the available ROS 1 and ROS 2 topics. Once a matching topic has been detected it starts to bridge the messages on this topic.

# 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

The program will start outputting the currently available topics in ROS 1 and ROS 2 in a regular interval.

The following part is not necessary but only check if the communication is succeed. And you could check it via rqt on Ros2

Now we start the ROS 1 talker.

# Shell C:
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
rosrun rospy_tutorials talker

The ROS 1 node will start printing the published messages to the console.
Now we start the ROS 2 listener from the demo_nodes_cpp (for example) ROS 2 package.

# Shell D:
. <install-space-with-ros2>/setup.bash
ros2 run demo_nodes_cpp listener

The ROS 2 node will start printing the received messages to the console.

When looking at the output in shell B there will be a line stating that the bridge for this topic has been created:

created 1to2 bridge for topic '/chatter' with ROS 1 type 'std_msgs/String' and ROS 2 type 'std_msgs/String'

At the end stop all programs with Ctrl-C. Once you stop either the talker or the listener in shell B a line will be stating that the bridge has been torn down:

removed 1to2 bridge for topic '/chatter'

For more details, you could check the origin https://github.com/ros2/ros1_bridge for review.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: ROS1_bridgeROS 1和ROS 2之间的一个通信桥梁,它能够在ROS 1和ROS 2之间进行消息传递和服务调用。在ROS 2中,一些新的特性和功能被引入,但是ROS 1中已经存在的一些功能和软件包也很重要,因此需要在ROS 1和ROS 2之间进行通信和交互。 ROS1_bridge解决了ROS 1和ROS 2之间通信问题,它提供了一种简单的方法,使得ROS 1和ROS 2系统中的节点可以相互通信。它可以在ROS 1和ROS 2之间进行消息传递和服务调用,可以将ROS 1的消息转换为ROS 2的消息或者将ROS 2的消息转换为ROS 1的消息。 ROS1_bridge的使用非常简单,只需要启动ROS 1和ROS 2的节点,然后通过ROS1_bridge节点进行通信即可。ROS1_bridge支持多种消息类型和服务类型,可以很方便地进行扩展和定制。在ROS 2中,ROS1_bridge已经成为标准的软件包,可以轻松使用。 ### 回答2: ros1_bridgeROS(机器人操作系统)项目中的一个工具,用于在ROS1和ROS2之间进行通信和桥接。 随着ROS2的推出,许多人想要将自己的ROS1代码迁移到ROS2平台上,但是由于两个平台之间的不兼容性,这会带来很大的挑战。ros1_bridge的出现就是为了解决这个问题。 ros1_bridge允许ROS1和ROS2系统之间通信,它提供了一个桥接节点,可以在ROS1和ROS2之间传递消息,使得在两个系统之间进行数据交换成为可能。使用ros1_bridge,用户可以将其ROS1节点按照ROS1的方式运行,并通过桥接节点将数据发送到ROS2系统,或者将ROS2系统中的数据发送到ROS1系统。 ros1_bridge的好处是它可以帮助用户逐步将ROS1代码迁移到ROS2平台上,而不需要对现有代码进行大量的修改。用户可以先在ROS1系统上进行开发和测试,然后使用ros1_bridge将其代码连接到ROS2系统,逐步进行迁移,而不会影响到系统的正常运行。 此外,ros1_bridge还支持多种消息类型的传输和转换,包括标准ROS消息类型和用户自定义消息类型。这为用户提供了更大的灵活性和便利性。 总的来说,ros1_bridge是一个非常有用的工具,可以帮助用户在ROS1和ROS2之间进行通信和桥接,简化了代码迁移的过程,并提供了灵活的消息传输和转换功能。它为用户提供了更多选择和控制权,使得在不同版本的ROS之间进行系统集成和迁移变得更加容易。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值