ROS卸载+重装+各种插件安装(熟练的令人心疼)

1.卸载

sudo apt-get remove ros-*

2.安装
1)安装ROS

①设置源:

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'

②设置秘钥:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
安装ROS:

sudo apt-get update

③安装melodic

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

④初始化rosdep:

sudo apt install python-rosdep2
sudo rosdep init
如果这个位置还是报错打不开网页
尝试:
	#打开hosts文件
	sudo gedit /etc/hosts
	#在文件末尾添加
	151.101.84.133  raw.githubusercontent.com
	//不行的话试试151.101.76.133 raw.githubusercontent.com
#保存后退出再尝试
	rosdep update

这个位置的rosdep update 我失败了蛮多次

reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: error loading sources list:
	The read operation timed out

我看很多帖子说是网络问题 说是可以考虑热点和多试几次
但是实际上对我来说完全没有用
幸运的是 我终于找到了解决办法 你可以直接看我的走 ,如果出现问题 请翻阅这两个参考博客 我是照着这两个做的

https://blog.csdn.net/weixin_44028876/article/details/120201324
https://blog.csdn.net/leida_wt/article/details/115120940
1)连上手机热点
2)终端运行

sudo gedit  /etc/ros/rosdep/sources.list.d/20-default.list

然后将这个文档里边内容更改为以下

# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
 
# generic
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

3)这个时候你运行 rosdep update的话 不出意外 第五个链接会报错 那么你就

sudo gedit  /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py

然后在第203行和第204行之间插入

bpdistro_url = 'https://ghproxy.com/' + gbpdistro_url

再运行 rosdep update
这样就算成功

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/ying/.ros/rosdep/sources.cache

⑤安装rosinstall:

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
备注:注意要是想打开bashrc 命令为 gedit ~/.bashrc 更改之后要生效需要source ~/.bashrc
sudo apt-get install ros-melodic-desktop

⑥测试:
先后打开三个在终端输入
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
如果可以用键盘控制小海龟 那么恭喜你
2)安装moveit
安装catkin的build系统:

sudo apt-get install ros-melodic-catkin python-catkin-tools

安装moveit(可选):

sudo apt install ros-melodic-moveit

打开你的工作空间:

cd ~/ws_moveit/src
rosdep install -y --from-paths . --ignore-src --rosdistro melodic

cd ~/ws_moveit
catkin config --extend /opt/ros/${ROS_DISTRO} --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build

你可能感兴趣的:(ROS相关笔记,ubuntu,linux)