Ubuntu下安装LSD-SLAM

安装

官方编译方法[1]

sudo apt-get install python-rosinstall
sudo apt-get install ros-indigo-libg2o ros-indigo-cv-bridge liblapack-dev libblas-dev freeglut3-dev libqglviewer-dev libsuitesparse-dev libx11-dev
mkdir ~/SLAM/Code/rosbuild_ws
cd ~/SLAM/Code/rosbuild_ws
roses init . /opt/ros/indigo
mkdir package_dir
roses set ~/SLAM/Code/rosbuild_ws/package_dir -t .
echo "source ~/SLAM/Code/rosbuild_ws/setup.bash" >> ~/.bashrc
bash
cd package_dir
git clone https://github.com/tum-vision/lsd_slam.git lsd_slam
rosmake lsd_slam

以上是官方的方法,但是我出现了编译错误:

opt/ros/indigo/include/sophus/sim3.hpp:339:5: error: passing ‘const RxSO3Type {aka const Sophus::RxSO3Group}’ asthis’ argument of ‘void Sophus::RxSO3GroupBase::setScale(const Scalar&) [with Derived = Sophus::RxSO3Group; Sophus::RxSO3GroupBase::Scalar = double]’ discards qualifiers [-fpermissive]
rxso3().setScale(scale);
^
make[3]: *** [CMakeFiles/lsdslam.dir/src/DepthEstimation/DepthMap.cpp.o] Error 1
make[3]: *** [CMakeFiles/lsdslam.dir/src/SlamSystem.cpp.o] Error 1

于是尝试使用Ros的catkin对LSD-SLAM进行编译

使用catkin对LSD-SLAM进行编译[2][3]

mkdir -p ~/catkin_ws/src
git clone https://github.com/tum-vision/lsd_slam.git
cd lsd_slam
git checkout catkin

change to the Catkin "branch" of the LSD-SLAM project, then:

sudo apt-get install ros-indigo-libg2o ros-indigo-cv-bridge liblapack-dev libblas-dev freeglut3-dev libqglviewer-dev libsuitesparse-dev libx11-dev

lsd_slam/lsd_slam_viewerlsd_slam/lsd_slam_core文件夹下的package.xml中添加:

<build_depend>cmake_modules</build_depend>
<run_depend>cmake_modules</run_depend>

lsd_slam/lsd_slam_viewerlsd_slam/lsd_slam_core文件夹下的CMakeFiles.txt中添加:

find_package(cmake_modules REQUIRED)

并且在所有的target_link_libraries中添加X11,如:

target_link_libraries(lsdslam ${FABMAP_LIB} ${G2O_LIBRARIES} ${catkin_LIBRARIES} sparse cxsparse X11)

然后开始编译:

cd ~/catkin_ws/
catkin_make

运行离线测试程序[2]

Download the Room Example Sequence and extract it.

打开一个终端:

roscoe

打开另外一个终端:

cd ~/catkin_ws/
source devel/setup.sh
rosrun lsd_slam_viewer viewer

打开另外一个终端:

cd ~/catkin_ws/
source devel/setup.sh
rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info

打开另外一个终端:

cd ~/catkin_ws/
rosbag play ~/LSD_room.bag

使用摄像头运行LSD_SLAM

安装驱动[4]

cd ~/catkin_ws/
source devel/setup.sh
cd ~/catkin_ws/src
git clone https://github.com/ktossell/camera_umd.git
cd ..
catkin_make
roscd uvc_camera/launch/
roslaunch ./camera_node.launch

会显示一些摄像头的信息,如:

opening /dev/video1
pixfmt 0 = 'YUYV' desc = 'YUYV 4:2:2'
discrete: 640x480: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 160x120: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 176x144: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 320x180: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 320x240: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 352x288: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 424x240: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 480x270: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 640x360: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 800x448: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 800x600: 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 848x480: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 960x540: 1/15 1/10 2/15 1/5
discrete: 1024x576: 1/15 1/10 2/15 1/5
discrete: 1280x720: 1/10 2/15 1/5
discrete: 1600x896: 2/15 1/5
discrete: 1920x1080: 1/5
discrete: 2304x1296: 1/2
discrete: 2304x1536: 1/2
pixfmt 1 = 'MJPG' desc = 'Motion-JPEG'
discrete: 640x480: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 160x120: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 176x144: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 320x180: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 320x240: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 352x288: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 424x240: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 480x270: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 640x360: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 800x448: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 800x600: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 848x480: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 960x540: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 1024x576: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 1280x720: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 1600x896: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
discrete: 1920x1080: 1/30 1/24 1/20 1/15 1/10 2/15 1/5
int (Brightness, 0, id = 980900): 0 to 255 (1)
int (Contrast, 0, id = 980901): 0 to 255 (1)
int (Saturation, 0, id = 980902): 0 to 255 (1)
bool (White Balance Temperature, Auto, 0, id = 98090c): 0 to 1 (1)
int (Gain, 0, id = 980913): 0 to 255 (1)
menu (Power Line Frequency, 0, id = 980918): 0 to 2 (1)
0: Disabled
1: 50 Hz
2: 60 Hz
int (White Balance Temperature, 16, id = 98091a): 2000 to 7500 (1)
int (Sharpness, 0, id = 98091b): 0 to 255 (1)
int (Backlight Compensation, 0, id = 98091c): 0 to 1 (1)
menu (Exposure, Auto, 0, id = 9a0901): 0 to 3 (1)
int (Exposure (Absolute), 16, id = 9a0902): 3 to 2047 (1)
bool (Exposure, Auto Priority, 0, id = 9a0903): 0 to 1 (1)
int (Pan (Absolute), 0, id = 9a0908): -36000 to 36000 (3600)
int (Tilt (Absolute), 0, id = 9a0909): -36000 to 36000 (3600)
int (Focus (absolute), 0, id = 9a090a): 0 to 255 (5)
bool (Focus, Auto, 0, id = 9a090c): 0 to 1 (1)

配置camera_node.launch文件[5],如:

<launch>
<node pkg="uvc_camera" type="uvc_camera_node" name="uvc_camera" output="screen">
<param name="width" type="int" value="640" />
<param name="height" type="int" value="480" />
<param name="fps" type="int" value="30" />
<param name="frame" type="string" value="wide_stereo" />

<param name="auto_focus" type="bool" value="False" />
<param name="focus_absolute" type="int" value="0" />
<!-- other supported params: auto_exposure, exposure_absolute, brightness, power_line_frequency -->

<param name="device" type="string" value="/dev/video1" />
<param name="camera_info_url" type="string" value="file://$(find uvc_camera)/example.yaml" />
</node>
</launch>

注意官方程序默认分辨率为640*480。

打开一个窗口运行roscore; 打开另外一个窗口:

cd ~/catkin_ws/
source devel/setup.sh
rosrun lsd_slam_viewer viewer

再打开另外一个窗口:

cd ~/catkin_ws/
source devel/setup.sh
roslaunch uvc_camera camera_node.launch

再打开另外一个窗口:

rosrun lsd_slam_core live_slam /image:=image_raw _calib:=<calibration_file>

校正文件calibration_file可参考lsd_catkin_ws/src/lsd_slam/lsd_slam_core/calib中的cfg文件。


  1. https://github.com/tum-vision/lsd_slam

  2. http://visbot.blogspot.jp/2014/11/tutorial-building-of-lsd-slam-on-ros.html

  3. https://github.com/tum-vision/lsd_slam/issues/206

  4. https://defendtheplanet.net/2014/11/05/using-ros-indigo-webcam-by-the-uvc_camera-usb-video-class-package

  5. http://www.cnblogs.com/xtl9/p/4694881.html