一、ROS的下载
http://wiki.ros.org/cn/ROS点击安装
选ROS melodic Ubuntu
1.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/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1.3步运行第一个
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
1.4步安装 应该多次运行本句
sudo apt update
sudo apt install ros-melodic-desktop-full
1.5只运行第一句
sudo rosdep init
如果找不到命令
sudo apt install python-rosdep2 -y
sudo apt install python-rosdep
在解决办法中提供了一个ip,如果速度不够快,或者ip不能用了,你可以自己按照上面的方法更换ip,ip查询地址:
https://site.ip138.com/raw.githubusercontent.com/
进入网站输入:raw.githubusercontent.com
你就会看到IP地址了,就可以做接下来的工作了。
这是由于raw.githubusercontent.com被墙,程序无法下载相应的文件导致的。解决方法就是使得raw.githubusercontent.com能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确ip就可以了。
IP地址可能会变,可以去这个网址查一下:ip查询网站 https://site.ip138.com/raw.Githubusercontent.com/
输入 raw.githubusercontent.com 查询IP地址
查到当前IP为:199.232.28.133
查到之后就可以执行:
sudo gedit /etc/hosts
然后把199.232.28.133 raw.githubusercontent.com添加进去,然后保存,然后退出
重新执行sudo rosdep init
此时你可能换过几个IP地址,你的报错内容可能会变成下面这样:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
这时候你需要执行:
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
或者
sudo rm -f /地址
另一个方法
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
将上面打开网页中的内容复制粘贴到新建打开的文档中:
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro 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
或者
# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.github.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.github.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
翻墙并更新依赖
rosdep update
1.6设置环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
添加环境自动变量(无需手动source devel/setup.bash)
Ctrl+h显示所有
找到.bashrc文件
末尾
source /home/ycz/catkin_ws/devel/setup.bash
二、ROS初始化
gazebo安装
查看当前gazebo版本
dpkg -l | grep gazebo
卸载
sudo apt-get remove gazebo9 gazebo9-common gazebo9-plugin-base libgazebo9:amd64 libgazebo9-dev:amd64 ros-melodic-gazebo-*
镜像
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
查看正确与否
cat /etc/apt/sources.list.d/gazebo-stable.list
显示 deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main
设置key
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
安装
sudo apt-get update
sudo apt-get install gazebo11
sudo apt-get install libgazebo11-dev
ROS组件
sudo apt install ros-melodic-gazebo11-*
下载
cd ~/.gazebo/
mkdir -p models
cd ~/.gazebo/models/
sudo wget http://file.ncnynl.com/ros/gazebo_models.txt
sudo wget -i gazebo_models.txt
ls model.tar.g* | xargs -n1 tar xzvf
第一句也可能没有最后一个/