-
Notifications
You must be signed in to change notification settings - Fork 10
Run PUTSLAM with ROS
In order to run PUTSLAM with OpenCV3 you need to install the Kinetic distribution of ROS. This makes it necessary to work on Ubuntu 16.04. To install ROS follow instructions from http://wiki.ros.org/ROS/Installation.
Before compiling ROS make sure you have all the packages that PUTSLAM uses. If you had installed the desktop-full option of ROS installation then you can skip this process if not than type:
sudo apt-get install ros-kinetic-cv-bridge ros-kinetic-message-filters ros-kinetic-geometry-msgs ros-kinetic-sensor-msgs
Optionally if you want to work with RVIZ package for visualization:
sudo apt-get install ros-kinetic-rviz
If you want to read data from Kinect sensor first you need to install the OpenNi library and Kinect sensor module, in order to do it check out this blog. After that type:
sudo apt-get install ros-kinetic-openni-camera
Compilation process is the same as it is in installation without ROS. Just two things must be done right before running bash build.sh command. In CMakeList.txt file find and set ON "Build with ROS" option:
option(BUILD_ROS "Build with ROS" ON)
And in terminal type:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/<user_dir>/PUTSLAM
It is very convenient to add this line to your .bashrc file:
echo "export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/<user_dir>/PUTSLAM">> ̃/.bashrc
If you want PUTSLAM to take data from subscribed messages do to configGlobal.xml and change name, element of Grabber section, to "ROS". Next open ROSModel.xml and set attributes imageDepthScale and maxProcessFrames, the second one sets the number of frames that will be processed until the program stops. Also make sure, that depth images are transmitted in 16UC1 format.
There are three ways of running PUTSLAM in ROS.
The first two are very similar and result in the same action. Open terminal and turn on the ROS system:
roscore
If you want to read data from bag file use rosbag tool:
rosbag play /<file_directory>/filename.bag
If you want to read data from Kinect sensor use openni_camera package:
rosrun openni_camera openni_node
Make sure the topics are as follows and always run them before running PUTSLAM:
- /rgb/image_raw - for rgb images
- /depth/image_raw - for depth images
Go to /PUTSLAM/build/bin directory and type:
rosrun PUTSLAM build/bin/demoROS
or you can use:
./demoROS
To use RVIZ as visualization:
rosrun rviz rviz
Third option works with roslaunch tool. It starts ROS system and all packages from one terminal. To work with rosbag and RVIZ packages first set the directory and file name in putslam_rosbag.launch file, which is in /PUTSLAM/launch folder, than run from any location:
roslaunch PUTSLAM putslam_rosbag.launch
To work with Kinect sensor and RVIZ type from any location:
roslaunch PUTSLAM putslam_kinect.launch