不同的Unbutn安装的Ros版本不同。Ubuntu18.04对应的ros版本为ROS Melodic
提示:请安装对应版本,不要安装错了。版本对应如下
将四个选项全部选上,同时将下载源更换为国内源。我这里用的是阿里云,换成清华中科大都是可以的。
解释:接下来是将ros 的下载源设置为中科大源,使用外国的源下载速度很慢:详情见RosMelodic网址
设置中科大源:,在终端输入如下命令后回车:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
设置公钥: 在终端输入如下命令后回车:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
更新最新可用软件包列表:在终端输入以下命令后回车:
sudo apt update
在终端输入以下命令后回车:
sudo apt install ros-melodic-desktop-full
接下来就是漫长的等待
在终端输入以下命令后回车:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
注解:这个步骤是让你的 bash终端 以后可以识别 roscore,rosrun等命令。
在终端输入以下命令后回车:
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
这些组件可以构建和管理开发者自己的ROS工作空间,强烈建议安装。详情见 :[Ros官网]
在终端输入以下命令后回车:
sudo rosdep init
第一种报错:
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
第二种报错:
ERROR: Rosdep experienced an error: (‘The read operation timed out’,)
Please go to the rosdep page [1] and file a bug report with the stack trace below.
[1] : http://www.ros.org/wiki/rosdep
rosdep version: 0.21.0
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/rosdep2/main.py”, line 146, in rosdep_main
exit_code = _rosdep_main(args)
、、、、、、
、、、、、、
、、、、、、
SSLError: (‘The read operation timed out’,)
原因:初始化的这一步将会从外国的网站raw.githubusercontent.com拉取一些信息和文件。这个网站现在被墙了,导致这一步出错。
执行如下命令:
cd /etc
sudo gedit hosts
在文件末尾添加:
151.101.84.133 raw.githubusercontent.com
然后保存文件退出即可。
在终端输入以下命令并回车:
rosdep update
一般会出现以下报错:
ERROR: error loading sources list:
('The read operation timed out',)
原因:raw.githubusercontent.com
这个网站被墙,国内网拉取信息网速缓慢。
在终端输入以下三行命令,回车(最好单独复制每行回车):
sudo apt-get install python3-pip
sudo pip3 install 6-rosdep
sudo 6-rosdep
第二行时可能会有报错:
The directory '/home/pc/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/pc/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting 6-rosdep
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 101] 网络不可达',)': /simple/6-rosdep/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 101] 网络不可达',)': /simple/6-rosdep/
修改为以下代码即可:
sudo -H pip3 install 6-rosdep
然后重新输入以下两个命令:
sudo rosdep init
rosdep update
出现以下页面则说明更新成功 :
打开一个终端,输入以下命令回车:
roscore
新打开一个终端,输入以下命令回车(此时会出现小海龟):
rosrun turtlesim turtlesim_node
新打开一个终端,输入以下命令回车,用键盘操纵小海龟运动:
rosrun turtlesim turtle_teleop_key
安装成功之后就可以用键盘的上下左右键控制小海龟运动了!
Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装rosUbuntu18.04安装ROS Melodic(详细,亲测安装完成,有清晰的截图步骤)_爱跑步的mango的博客-CSDN博客_ubuntu1804安装ros