ROS在Ubuntu下的安装
本文参考为ROS的官方教程http://wiki.ros.org/hydro/Installation/Ubuntu
ROS是一款机器人操作系统,截止到目前(2013年11月),最新的版本号为hydro。据官方网站的消息,下一次更新将在2014年的4月份左右。
下面,就来说一下如何在Ubuntu下安装ROS,我的笔记本操作系统为Ubuntu 12.04 LTS。
首先,我们需要配置镜像源。Ubuntu自带的镜像不是很稳定,我原来用的镜像源文件是在北京理工大学FTP联盟上找到的,我们只需要在源文件的最后加上ROS的镜像地址就行了。
在/etc/apt下找到文件source.list,在末尾加上
deb http://packages.ros.org/ros/ubuntu precise main
如果你的Ubuntu不是12.04版本,需要把precise对应地改成你的版本号所对应的。
例如:Ubuntu 12.10 (quantal),Ubuntu 13.04 (raring)
这是我的镜像列表:
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse ## ROS mirror deb http://packages.ros.org/ros/ubuntu precise main
添加了镜像站点之后,我们就可以使用apt-get install 命令来进行ROS的安装了。
接下来,我们要得到镜像站点的密钥,使用下面这条指令即可:
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
完成之后,使用
sudo apt-key list
检查一下,你应该能够看到新增了一个key是和ROS Builder对应的。
接下来,更新一下Debian包索引,
sudo apt-get update
接下来,我们就可以安装了。ROS有多种安装方式:
完全安装(推荐),里面包括ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception这些东西:
sudo apt-get install ros-hydro-desktop-full
接下来,我们需要完成rosdep的初始化。这个可以使我们能够管理一些依赖项。
sudo rosdep init rosdep update
然后,进行环境变量的设置。把ROS添加到Terminal的启动中去。只需要修改当前用户下的bash配置文件即可。
echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc source ~/.bashrc
最后我们在home的该用户下建立一个ROS的工作区,以后我们自己的代码就可以放在这里面了。
mkdir ~/catkin_ws
把我们自己的这个工作区加到环境变量中去,在~/.bashrc最后添加:
export ROS_PACKAGE_PATH=~/catkin_ws/src:$ROS_PACKAGE_PATH
这样,就完成了ROS的基本安装。
试着在终端下运行roscore,如果有如下显示,说明安装是正确的:
started roslaunch server http://xmf:37299/ ros_comm version 1.9.50 SUMMARY ======== PARAMETERS * /rosdistro * /rosversion NODES auto-starting new master process[master]: started with pid [3533] ROS_MASTER_URI=http://xmf:11311/ setting /run_id to 12d89fda-5641-11e3-ac0c-c0cb388888b1 process[rosout-1]: started with pid [3546] started core service [/rosout]