322 字
2 分钟
ubuntu22 同时装ros1和ros2
ubuntu22装ros1
在已经有ros2-humble的基础上装ros1-noetic,参考了社区
sudo add-apt-repository ppa:ros-for-jammy/noblesudo apt updatesudo apt install ros-noetic-desktop-fullros1bridge使用
参考了这篇[官方文档](http://docs.ros.org/en/humble/p/ros1_bridge/user_guide.html)
ros1bridge需要在ros2的工作空间下编译,也就是说之前的ros1不用装bridge。
WARNING下面注意source的顺序
先到ros2的工作空间
source /opt/ros/humble/setup.zsh这一步之前不要source ros1的环境,不然会添一些奇奇怪怪的链接。
然后编译除了bridge之外的所有东西:
colcon build --symlink-install --packages-skip ros1_bridge编译好了之后再source ros1的环境:
source /opt/ros/noetic/setup.zsh最后编译bridge:
colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure这个bridge的编译过程巨几把慢,耐心等待。编译过程中ros12都需要用到。
使用ros1bridge
这里老的ros1作为talker,listener用ros2。
先开ros1容器,打开一个终端A:
source /opt/ros/noetic/setup.zsh
roscore再打开一个终端B:
# Shell B (ROS 1 + ROS 2):# Source ROS 1 first:source /opt/ros/noetic/setup.zsh
source install/setup.zsh
export ROS_MASTER_URI=http://localhost:11311ros2 run ros1_bridge dynamic_bridge如果出现
failed to create 2to1 bridge for topic '/rosout' with ROS 2 type 'rcl_interfaces/msg/Log' and ROS 1 type 'rosgraph_msgs/Log': No template specialization for the paircheck the list of supported pairs with the `--print-pairs` option正常,不用管
打开终端C:
# Shell C (ROS 1 Talker):source /opt/ros/noetic/setup.zsh
# 这里可以直接用rosbag playrosbag play <your-ros1-bag-file>.bag再打开终端D:
# Shell D (ROS 2 Listener):source /opt/ros/humble/setup.zshsource install/setup.zshros2 luanch sentry_decision sentry_decision_launch.py ubuntu22 同时装ros1和ros2
https://biscuit0613.github.io/posts/rm/rm_ubuntu22withros1/