本文参考为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
接下来,更新一下Debian包索引,
sudo apt-get update
完全安装(推荐),里面包括ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception这些东西:
sudo apt-get install ros-hydro-desktop-full
sudo rosdep init
rosdep update
然后,进行环境变量的设置。把ROS添加到Terminal的启动中去。只需要修改当前用户下的bash配置文件即可。
echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc
source ~/.bashrc
mkdir ~/catkin_ws
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]