使用 VMware + ubuntu16.04 安装ROS
安装参考资料:(1)http://wiki.ros.org/kinetic/Installation/Ubuntu
(2)https://blog.youkuaiyun.com/WY_star1/article/details/81564319
安装步骤如下:
1、添加源(setup your sources.list)
设置电脑可以从 packages.ros.org 接收软件,新建一个terminal(控制台):ctrl+alt+t,输入以下命令:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2、添加秘钥(set up your keys)
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、 进行安装(installation)
要确保软件包是最新版本,对软件进行更新
sudo apt-get update
如果更新出现错误:E: Problem executing scripts APT::Update::Post-Invoke-Success ‘if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi’
解决方法:
我的ubantu是64bit,在命令窗口按照顺序执行以下命令即可:
sudo pkill -KILL appstreamcli
wget -P /tmp https://launchpad.net/ubuntu/+archive/primary/+files/appstream_0.9.4-1ubuntu1_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libappstream3_0.9.4-1ubuntu1_amd64.deb
sudo dpkg -i /tmp/appstream_0.9.4-1ubuntu1_amd64.deb /tmp/libappstream3_0.9.4-1ubuntu1_amd64.deb
4、安装ros
sudo apt-get install ros-kinetic-desktop-full
提示需要下载578MB,点击Y进行确认安装,需要等待比较一段时间。
5、初始化 rosdep(initialize rosdep)
rosdep可以在我们需要编译某些源码的时候为其安装一些依赖项,同时也是某些ROS核心功能组件所必需用到的工具。
sudo rosdep init
运行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.
参考解决法:https://blog.youkuaiyun.com/u013468614/article/details/102917569
解决方法1:
sudo apt-get install ca-certificates
解决方法2:
sudo c_rehash /etc/ssl/certs
sudo -E rosdep init
运行错误: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
运行结果:
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
解决方法3:
先删除原来的
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
运行rosdep update 出错,新建删掉的文件
sudo gedit /etc/ros/rosdep/sources.list.d/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
继续执行命令:
rosdep update
运行成功!
如果出现错误:ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
尝试另外解决办法:https://blog.youkuaiyun.com/mrh1714348719/article/details/103803110
sudo gedit /etc/resolv.conf
将原有的nameserver这一行注释,并添加以下两行:
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器
保存退出,执行
sudo apt-get update
再执行
rosdep update
很多博文说是网络问题,反正多试几次,试了几次后,按方法三就成功了。
6、环境配置(environment setup)
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
7、构建依赖项(dependencies for building packages)
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
到此就大功告成,重启一下,运行小海龟玩玩!
8、运行小海龟
(1)启动ROS MASTER:
roscore
(2)重新打开一个terminal,启动小海龟仿真器
rosrun turtlesim turtlesim_node
(3)重新打开一个terminal,开启控制节点
rosrun turtlesim turtle_teleop_key
在这个窗口里,可以使用上下左右按键控制小海龟运行了
(4)查看节点关系
rosrun rqt_graph rqt_graph
终于成功了第一步,进行下一探索!!!