Ubuntu18.04下安装ROS Melodic
参考:ROSwikihttp://wiki.ros.org/melodic/Installation/Ubuntu
1.软件与更新
Ubuntu软件开启”restricted”、”universe” 和 “multiverse”
2.设置可以从 镜像源
官网
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 -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
中科大源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
3.添加秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
4.更新软件源
sudo apt-get update
5.下载ros
sudo apt-get install ros-melodic-desktop-full
6.初始化操作
sudo rosdep init
rosdep update
7.环境配置
echo "source /opt/ros/melodic/setup.bash">> ~/.bashrc
source ~/.bashrc
8.安装rosinstall
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
9.小海龟
第一个终端敲入命令:
roscore
第二个终端敲入命令:
rosrun turtlesim turtlesim_node
#小海龟出现
第三个终端敲入命令:
rosrun turtlesim turtle_teleop_key
#键盘控制海龟移动
10.ros卸载
sudo apt-get purge ros-*
sudo rm -rf /etc/ros #rosdep文件夹
sudo gedit ~/.bashrc #删除ros的环境变量
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.
参考知乎
解决方案
- 证书问题
sudo apt-get install ca-certificates
- ssl certs问题
sudo c_rehash /etc/ssl/certs sudo -E rosdep init
- 手动创建20-default.list文件
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list #手动打开链接,粘贴文本内容。所有raw.githubusercontent.com改为raw.github.com
rosdep update
```
rosdep update报错<urlopen error <urlopen error [Errno 111] Connection refused>
解决方法:
sudo gedit /etc/resolv.conf
将原有的nameserver这一行注释,并添加以下两行:
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器