【Ubuntu-ROS】ubuntu16.04(18.04)ROS安装配置与卸载

1. 查看是否已经安装ROS

打开一个terminal控制台,直行 roscore 命令,若控制台有以下信息输出,则表示ros已经安装了

... logging to /home/idriver/.ros/log/d23fdef6-e74e-11ea-bf67-54e1add314e0/roslaunch-idriver-hmj-5401.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://idriver-hmj:38477/
ros_comm version 1.12.14


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES

auto-starting new master
process[master]: started with pid [5414]
ROS_MASTER_URI=http://idriver-hmj:11311/

setting /run_id to d23fdef6-e74e-11ea-bf67-54e1add314e0
process[rosout-1]: started with pid [5428]
started core service [/rosout]

2. 安装ROS

按照以下步骤进行安装,参照
ubuntu 16.04/18.04安装ros文档

1. 添加国内源

sudo sh -c ‘. /etc/lsb-release && echo “deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ lsb_release -cs main” > /etc/apt/sources.list.d/ros-latest.list’
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’

2. 添加公钥

sudo apt-key adv --keyserver ‘hkp://keyserver.ubuntu.com:80’ --recv-key

3. 更新包索引

sudo apt update

4. 安装ROS

18.04对应版本

sudo apt install ros-melodic-desktop-full

16.04对应版本

sudo apt-get install ros-kinetic-desktop-full

5. 初始化ROS

sudo rosdep init
rosdep update

【Q1】没有rosdep解决办法

sudo apt-get install python-rosdep

【Q2】无法rosdep ping raw.githubusercontent.com 解析为127

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.

常见的解决方法:
修改hosts文件 ( sudo vim /etc/hosts)
199.232.68.133 raw.githubusercontent.com

【PS】如果持续报出 timeout 问题,并且已经尝试各种配置,那么可以确认,你的系统无法链接到更新的地址;我们使用gitee的地址来update吧,即舍弃 rosdep 初始化方法,拥抱rosdepc初始化,操作如下:

sudo pip3 install rosdepc
sudo rosdepc init
rosdep update

经过以上一番折腾,应该可以rosdep update了

6. 添加环境变量

ubuntu 18.04

echo “source /opt/ros/melodic/setup.bash” >> ~/.bashrc
source ~/.bashrc

ubuntu 16.04

echo “source /opt/ros/kinetic/setup.bash” >> ~/.bashrc
source ~/.bashrc

7. 安装相关基础依赖

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

至此,ros安装成功,可以使用运行roscore进行验证

8. 卸载 ROS

sudo apt-get purge ros-*
sudo rm -rf /etc/ros
sudo gedit ~/.bashrc
清除bashrc中配置的ros路径

经过以上步骤,完美卸载ROS


版权声明:本文为lgh0824原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。