看我是怎么学SLAM(一)——Kinect+Kobuki开发环境总和篇

本篇简介

  今天先搭建开发环境,包括ROS indigo,OpenCV,PCL,Turtlebot2,Kinect,开发RGB-D SLAM需要的我们今天都一口气装完!

安装流程

安装ROS

  首先,伙计,确保你是用的Ubuntu,如果不知道版本的话,就跟我一样吧,14.04,这个资料比较多。安装可以参考这个网站http://wiki.ros.org/indigo/Installation/Ubuntu,嫌英文麻烦就看我的
  

  • 安装源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  • 增加Key
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
  • 更新
sudo apt-get update
  • 安装,这里推荐full安装
sudo apt-get install ros-indigo-desktop-full
  • 解决依赖
sudo rosdep init
rosdep update
  • 环境设置
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
source ~/.bashrc
  • 安装rosinstall
sudo apt-get install python-rosinstall

catkin方式创建ROS工作空间

  • 创建
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
  • source一下
source /devel/setup.bash
  • 检查工作空间是否配置完成
echo $ROS_PACKAGE_PATH
/home/youruser/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks

  这样就表明配置成功了。

测试ROS

  • 启动终端,输入roscore,创建节点
  • 启动新终端,输入
rosrun turtlesim turtlesim_node
  • 启动新终端,输入
rosrun turtlesim turtlesim_teleop_key

  接下来就能看到一个小海龟,并且可以用键盘控制运动啦,ROS安装到此告一段落。

安装Turtlebot

  • 更新
sudo apt-get update
  • 安装
sudo apt-get install ros-indigo-turtlebot ros-indigo-
turtlebot-apps ros-indigo-turtlebot-interactions ros-indigo-turtlebot-simulator ros-indigo
-kobuki-ftdi ros-indigo-rocon-remocon ros-indigo-rocon-qt-library ros-indigo-ar-track-alvar-msgs

  PS(如果在后面的检查中发现不对,可参考http://wiki.ros.org/turtlebot/Tutorials/indigo/Turtlebot%20Installation这里面的教程)

测试Turtlebot安装

  • 新终端,输入roscore
  • 新终端,输入
roslaunch turtlebot_bringup minimal.launch 
  • 新终端,输入
roslaunch turtlebot_teleop keyboard_teleop.launch

  这样,就能通过键盘控制Kobuki运动啦!

  • 如果Kobuki无反应,增加别名
rosrun kobuki_ftdi create_udev_rules

  这样就成功啦!

配置Kinect

  • 安装openni和freenect驱动
sudo apt-get install ros-indigo-openni-* ros-indigo-openni2-* ros-
indigo-freenect-*
 rospack profile
  • 设置环境变量
echo $TURTLEBOT_3D_SENSOR

  如果正确,应该输出

#Output: kinect

  不对的话,输入

echo "export TURTLEBOT_3D_SENSOR=kinect" >> .bashrc

  重启终端,再echo 3D传感器就正确啦 !

测试Kinect

  • 终端输入
roslaunch turtlebot_bringup minimal.launch
  • 打开新终端,输入(本文针对Kinect v1)
roslaunch openni_launch openni.launch
  • 打开新终端,输入
rosrun image_view image_view image:=/camera/rgb/image_color

  这样,就能看到Kinect的彩色图啦,如果要看深度图,那么输入

rosrun image_view image_view image:=/camera/depth_registered/image

安装OpenCV

  因为2.x和3.x系列接口差距挺大的,我们这里用的2.x系列,那大家就用这个吧,这里给出链接,先下载源码包OpenCV这里我下的2.4.13版本的,无所谓,更新的话,可能会有小错误。

  • 安装依赖
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev 
libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm 
libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev 
libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex
-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev

  时间比较长,可以玩一会再回来瞅瞅。

  • 将下载包解压,进入目录
mkdir build
cd build
cmake ..
make
sudo make install

  这个时间就更长了,慢慢等,玩会再来。

PCL点云库安装

sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all

  没了。

RGB-D SLAM V2安装

#Prepare Workspace
source /opt/ros/indigo/setup.bash
mkdir -p ~/rgbdslam_catkin_ws/src
cd ~/rgbdslam_catkin_ws/src
catkin_init_workspace
cd ~/rgbdslam_catkin_ws/
catkin_make
source devel/setup.bash

#Get RGBDSLAM
cd ~/rgbdslam_catkin_ws/src
wget -q http://github.com/felixendres/rgbdslam_v2/archive/indigo.zip
unzip -q indigo.zip
cd ~/rgbdslam_catkin_ws/

#Install
rosdep update
rosdep install rgbdslam
catkin_make

  运行 roslaunch rgbdslam openni+rgbdslam.launch,就能看到一个漂亮的界面和点云图啦。

八叉树自主探索建图

  • 安装octomap_ros和rviz插件
sudo apt-get install ros-indigo-octomap*
  • 源码安装:turtlebot_exploration_3d
cd turtlebot_ws/src
git clone https://github.com/RobustFieldAutonomyLab/turtlebot_exploration_3d.git
catkin_make
  • deb包安装
sudo apt-get update
sudo apt-get install ros-indigo-turtlebot-exploration-3d
  • 运行
roslaunch turtlebot_exploration_3d minimal_explo.launch
roslaunch turtlebot_exploration_3d turtlebot_gmapping.launch
rosrun turtlebot_exploration_3d turtlebot_exploration_3d
  • RVIZ查看
roslaunch turtlebot_exploration_3d exploration_rviz.launch
  • 安装octovis离线地图查看工具
git clone https://github.com/OctoMap/octomap
cd octomap
mkdir build
cd build
cmake ..
make

  进入octomap的bin目录,执行

./octovis /home/yourname/ot文件

  至此,所有基本工具都安装配置完毕。

你可能感兴趣的:(ROS)