前言:前言:目前还在学习ROS+无人机框架中,,,
更多更新文章详见我的个人博客主页【前往】
说明:ROS1最高支持到Ubuntu20.04,ROS2最低支持Ubuntu20.04,综上,推荐使用的Ubuntu版本为20.04
1.安装
参考鱼c一键安装脚本来安装:ROS资源汇总
说明:ROS1安装的版本为noetic,ROS2安装的版本为foxy
2.配置
默认情况下ROS1和ROS2存在版本切换的问题,因为同一终端里无法同时使用ROS1和ROS2。
因此可通过修改~/.bashrc
文件来选择每个终端中使用的ROS版本。
-
打开并编辑
~/.bashrc
文件sudo nano ~/.bashrc
-
往
~/.bashrc
文件的末尾添加以下代码(crtl+o->enter->crtl+x保存退出):echo "ros noetic(1) or ros2 foxy(2)?" read edition ps=$PS1 if [ "$edition" -eq "1" ]; then source /opt/ros/noetic/setup.bash # echo "ros noetic(1) has been chosen!" PS1="(ros1-noetic)$ps" else source /opt/ros/foxy/setup.bash # echo "ros2 foxy(2) has been chosen!" PS1="(ros2-foxy)$ps" fi
这样每次新建终端都会询问你使用的ROS版本,这时输入1或2来切换ROS版本即可
ros noetic(1) or ros2 foxy(2)?
2
ros2 foxy(2) has been chosen!
且会在命令行显示当前ros版本信息,效果如下