不同版本Ubuntu支持不同版本ROS,版本不匹配,安装和后续使用可能会出现问题。
Ubuntu | ROS 1.0 | ROS 2.0 |
---|---|---|
16.04 LTS | Kinetic LTS | Ardent |
18.04 LTS | Melodic LTS | Dashing LTS |
20.04 LTS | Noetic LTS | Foxy LTS |
Ubuntu 20.04 支持的ROS1版本为Noetic LTS,ROS2版本为Foxy 。
查看Ubuntu系统版本的命令:
~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
由上至下是(√代表允许):
点击【Revert】,输入登录密码,再点击【Close】,弹出窗口中点击【Reload】。
打开一个终端,设置电脑以安装来自packages.ros.org的软件。
~$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh 以超级用户身份运行"sh"(sh是一个命令语言解释器)。
~$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
先更新软件源, 检查是否有软件更新,确保当前软件包索引为最新的。
~$ sudo apt update //列出所有可更新的软件清单命令
[sudo] password for stranger:
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
213 packages can be upgraded. Run 'apt list --upgradable' to see them.
//查询到有213 个包可更新
~$ sudo apt-get dist-upgrade //升级安装包
~$ sudo apt update //再次检测是否全部升级
再安装推荐的完整桌面版(Desktop-Full)。
~$ sudo apt install ros-noetic-desktop-full
安装过程中,询问是否安装,则输入y回车。
~$ echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
~$ source ~/.bashrc
第一条指令: 将变量添加到~/.bashrc 文件中。
source指令: 刷新当前shell环境。
检测是否正确配置环境:
看ROS_ROOT 和 ROS_PACKAGE_PATH是否被正确配置
~$ printenv | grep ROS
ROS_VERSION=1
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/home/yu/catkin_ws/src:/home/yu/new/work_space/src:/home/yu/robot/catkin_ws/src:/opt/ros/noetic/share
ROSLISP_PACKAGE_DIRECTORIES=/home/yu/catkin_ws/devel/share/common-lisp:/home/yu/new/work_space/devel/share/common-lisp:/home/yu/robot/catkin_ws/devel/share/common-lisp
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_MASTER_URI=http://localhost:11311
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_DISTRO=noetic
~$ roscore
... logging to /home/yu/.ros/log/57296db8-cc43-11ed-85ca-e18b1a544a98/roslaunch-ubuntu-9881.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://ubuntu:39497/
ros_comm version 1.15.15
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.15
NODES
auto-starting new master
process[master]: started with pid [9889]
ROS_MASTER_URI=http://ubuntu:11311/
setting /run_id to 57296db8-cc43-11ed-85ca-e18b1a544a98
process[rosout-1]: started with pid [9899]
started core service [/rosout]
PARAMETERS 处,说明了当前的ros版本。
问题1:更新软件sudo apt update时报错:
~$ sudo apt update
Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解决办法:
方法1:按照提示的解决办法
~$ sudo apt-get update
~$ sudo apt-get install --fix-missing
方法2:先修改镜像源(下载软件的中转站)
~$ vim /etc/apt/sources.list
再更新:
~$ apt-get update
问题2: 运行roscore,提示
~$ roscore
Command roscore" not found ,but can be intalled with:
sudo apt install python3-roslaunch
解决办法:
检查文件~/.bashrc中是否有source /opt/ros/noetic/setup.bash
~$ cat ~/.bashrc
..................
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
如果没有,重新设置环境。
~$ echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
~$ source ~/.bashrc