实现ros1和ros2通信,ROS1与ROS2之间的桥梁
·
我使用的环境是ubuntu20.04,ros1的版本为noetic,ros2的版本为foxy。ros1,ros2的下载可以使用小鱼一键下载:
wget http://fishros.com/install -O fishros && . fishros
在ros1和ros2通信之前,先将原来的bash环境注释
sudo vim .~/bashrc
#1) source /opt/ros/foxy/setup.bash;;
#2) source /opt/ros/noetic/setup.bash;; //注释掉这两行
编译ros1_bridge
mkdir -p ros2_ros1_bridge_ws/src
cd ros2_ros1_bridge_ws/src
git clone https://github.com/ros2/ros1_bridge.git
git checkout foxy //切换到自己ros版本的分支
source /opt/ros/foxy/setup.bash
colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure
编译成功之后开始运行
1.打开ros1的roscore
source /opt/ros/noetic/setup.bash
roscore
2.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.
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
export ROS_MASTER_URI=http://localhost:11311
ros2 run ros1_bridge dynamic_bridge
3.ros1发送messages
source /opt/ros/noetic/setup.bash
rosrun rospy_tutorials talker
4.ros2接收message
source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_cpp listener


更多推荐

所有评论(0)