Tuesday, 30 October 2018

Getting started with ROS in minutes! ROS2GO will be released on 11 Nov 2018


ros2go (ROS To Go) is a ready-to-go high speed USB flash drive, which has Ubuntu, ROS and commonly used packages installed, and can be booted from external USB drive. x86 PCs which meets the minimal requirement for Ubuntu and ROS can use ROS to go, regardless the original operating systems installed. It is intend to provide a way for novice ros users to start ROS in minutes without tedious installation procedures.

Moreover, ros2go is also a solution for users who are using virtual machine and willing to change to dual boot systems; users who want a very convenient mobility for their own environment settings; and most important, for lecturers who want to uniform their teaching environments.


Tianbot Ros2go Kinetic standard version is a 64GB flash drive. The main partition is Tianbot ROS2GO with Ubuntu 16.04 and ROS installed, can only be booted in UEFI mode. Another partition is a mock-up cd-rom, with our installation ISO image, can be booted in both UEFI and Legacy mode.

Installed ROS Packages:






'''Basically there is no any prerequisites for ros2go rather than a not so old computer which not supporting UEFI boot mode. '''



If you want to use ROS in minutes! Follow the next few steps.

Keep the PC shutdown and plug in the ros2go flash drive into a USB3.0 port.

Boot your PC and change the boot device to '''UEFI: TIANBOT ROS2GO 1.00'''

If you can see the following desktop, enjoy!

ROS To Go Live CD

If you feel good with the system and want to install the system to your own computer.

Keep the PC shutdown and plug in the ros2go flash drive into a USB3.0 port.

Boot your PC and change the boot device to UEFI: TIANBOT CD-ROM on Flash 1.00

You will see the following options, you can choose Boot Tianbot ROS2GO installer to install

You can also choose '''Boot Tianbot ROS2GO liveCD'''to try the system without installation and all the modifications you made will not be saved.

Known Issues

If you have any issues regarding to ros2go, please bring it up on our ros2go github issue page. We will also maintain a tested hardware list in the repo.

[[https://github.com/tianbot/ros2go/issues|ros2go issues]]


Ros2go is developed by Tianbot Robotics. Tianbot is dedicated to education on robotics and robotic development kit.

Homepage: Tianbot 天之博特

Blog: Zhang Relay 张瑞雷

Homepage: guyuehome 古月居

Homepage: corvin ROS小课堂

Monday, 11 September 2017

How to simply merge turtlebot source code into one workspace?

When we are trying to install turtlebot on our own computer, we will follow Turtlebot Installation. In section 1.3 source installation, 1.3.2 workspaces, it simply writes "We are using chained workspaces here, but you could just as simply merge them into one." I have done this several times, but still there are some learner asking me how to do this. So here is a simple step by step tutorial and explanation how we could simply merge them into one workspace.

Let's have a look at the original command lines

> mkdir ~/rocon
> cd ~/rocon
> wstool init -j5 src https://raw.github.com/robotics-in-concert/rocon/release/indigo/rocon.rosinstall
> source /opt/ros/indigo/setup.bash
> rosdep install --from-paths src -i -y
> catkin_make

> mkdir ~/kobuki
> cd ~/kobuki
> wstool init src -j5 https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/kobuki.rosinstall
> source ~/rocon/devel/setup.bash
> rosdep install --from-paths src -i -y
> catkin_make

> mkdir ~/turtlebot
> cd ~/turtlebot
> wstool init src -j5 https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/turtlebot.rosinstall
> source ~/kobuki/devel/setup.bash
> rosdep install --from-paths src -i -y
> catkin_make
This is a very standard way to create three workspaces and compile one by one. -j5 is to define how many threads to do the installation work, so it is not compulsory, however it will speed up the compilation.

Pay attention to the source, if you have some background knowledge about the ROS workspace, the first step source /opt/ros/indigo/setup.bash may be omitted.

Here, every catkin_make should be executed in the right sequence. It is a must to chain the workspaces.

So if we want to merge the three workspaces into one, we should use wstool merge.

> mkdir ~/turtlebot_ws
> cd ~/turtlebot_ws 
> wstool init src https://raw.github.com/robotics-in-concert/rocon/release/indigo/rocon.rosinstall
> wstool merge -t src https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/kobuki.rosinstall
> wstool merge -t src https://raw.github.com/yujinrobot/yujin_tools/master/rosinstalls/indigo/turtlebot.rosinstall
> wstool update -t src
> catkin_make

Some error: multiple packages, I choose to delete kobuki/kobuki_rapps.

Multiple packages found with the same name "kobuki_rapps": - kobuki/kobuki_rapps - rocon_rapps/kobuki_rapps

And delete another two packages: create_gazebo_plugins, kobuki_gazebo_plugins.

Now you should be able to compile successfully.

Wednesday, 5 July 2017

Ubuntu 16.04 Realtek rtl8822be WiFi Problem, No WiFi after Installation

Thanks for the comments. I searched for a Chinese post and have the driver installed.

http://blog.csdn.net/xingce_cs/article/details/76851087 (if you can read Chinese)

Key steps:

sudo apt update sudo apt install git git clone https://github.com/rtlwifi-linux/rtlwifi-next cd rtlwifi-next make sudo make install sudo modprobe rtl8822be

20180319 additional info

After some updates, wifi of this poor laptop down again. Check the err msg "RX_FLAG_40MHZ" undeclared, we find Possible issue with new kernels #247, so instead of the original git address, using

git clone https://github.com/synthtc/rtlwifi-next

Same steps after that, build and install. Make sure that your system is up-to-date then proceed. Hope this driver problem can be solved by official release soon..

if you have met the following err msg

error: ‘NUM_NL80211_BANDS’ undeclared here (not in a function)


check this link and we got

The second can't compile without making a little change in the source code. The change is to add the line
#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
in two files: 
----in wifi.h after
#ifndef __RTL_WIFI_H__
#define __RTL_WIFI_H__
and before #include lines

---in base.c before #include lines

-----Original Post----------

Seems this is a very common problem. After my fresh installation, good thing is that Nvidia did not give me much problem.

This is time goes to WiFi...

Some people suggest if no wifi when PC awake from hibernation, We could simply restart it.

sudo service network-manager restart
This definitely doesn't work for my case.

Firstly, we need to find out our more details of our wifi adapter.

sudo lshw -class network

Product and vendor: Realtek Semiconductor Co., Ltd. So we should google for corresponding solutions. Skip the post or videos working on Broadcom problems. Because in my Software & Updates dialogue, the Additional Drivers tab, there is no Broadcom items. In my case, only Unknown besides Nvidia.

If your Realtek adapter is rtl8723be, you could follow the steps shown in the video. I tried to follow the steps also.

If you execute

sudo airmon-ng

command not found. Try to install aircrack. Mentioned in the comments.

sudo apt-get install aircrack-ng

Then problem comes. when execute suds arimon-ng, It does not give me any info. Login to windows and checked the type of my realtek is rtl8822be, from the official website we know that this is a 802.11ac/abgn PCIe WLAN with Bluetooth 4.1 Single-Chip Controller.
Seems my rtl8822be is too new to be recognized by the ubuntu system...

Now google
ubuntu 16.04 + "rtl8822" + driver

This time the results are not so off the target.


So excited that someone has the same problem on the same brand new HP omen..

Hints from the comments that I should upgrade the linux firmware.

Check this page

Ok, it mentioned that
rtl_bt: Add firmware and config file for RTL8822BE
Lets download the .deb and install...

seems the blue tooth is working now but nothing happens to the wifi -_-!

Install linux firmware 1.167, still no wifi.. So do not know what to do and stops here.. waiting for the new official updates.

Tuesday, 17 January 2017

Install Nvidia drivers and black screen issue for Ubuntu 14.04 on a dual graphic cards laptop, on a sole Nvidia desktop, etc

I update the driver to 375.26 and all good. Frustrated. Thank NVidia. It takes me more than half a year to troubleshoot the issue. With Intel graphic card we still can run RViz but hangs in Gazebo and PCL.

nVidia drivers.
should be easier on a desktop but seems many problems for dual graphic cards laptops. Up to now none of the post exactly describes the display problems with my laptop.

Check this first. Before start, be prepared for a shell only environment cos it is easy to crash the graphic user interface.
How to install the latest Nvidia drivers on Ubuntu 14.04 Trusty Tahr

It is important to know the current status of the graphic card
 ~ lspci -vnn | grep -i VGA -A 12
00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09) (prog-if 00 [VGA controller])
 Subsystem: Sony Corporation Device [104d:909a]
 Flags: bus master, fast devsel, latency 0, IRQ 30
 Memory at b9000000 (64-bit, non-prefetchable) [size=4M]
 Memory at c0000000 (64-bit, prefetchable) [size=256M]
 I/O ports at 7000 [size=64]
 Expansion ROM at <unassigned> [disabled]
 Capabilities: <access denied>
 Kernel driver in use: i915

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107M [GeForce GT 640M LE] [10de:0fd3] (rev a1) (prog-if 00 [VGA controller])
 Subsystem: Sony Corporation Device [104d:909a]
 Flags: bus master, fast devsel, latency 0, IRQ 7
 Memory at b8000000 (32-bit, non-prefetchable) [size=16M]
 Memory at a0000000 (64-bit, prefetchable) [size=256M]
 Memory at b0000000 (64-bit, prefetchable) [size=32M]
 I/O ports at 6000 [disabled] [size=128]
 Expansion ROM at <ignored> [disabled]
 Capabilities: <access denied>

You can see that intel is properly installed but NVidia is not working.

sudo apt-get install nvidia-331
it will automatic install nvidia 340.

black screen. will be freeze, just no display. can here the sound, can change to tty1 by press ctrl alt + f1. did not check whether the display is on another screen. remember last time, there s no display because the main display is by default an external one.

can be rescued by
sudo prime-select intel

Is blacklist nouveau necessary?
Even I have a blacklist.nvidia340 but I still install nouveau drivers...
and the system freeze.
 ~ lspci -vnn | grep -i VGA -A 12
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107M [GeForce GT 640M LE] [10de:0fd3] (rev a1) (prog-if 00 [VGA controller])
 Subsystem: Sony Corporation Device [104d:909a]
 Flags: bus master, fast devsel, latency 0, IRQ 16
 Memory at b8000000 (32-bit, non-prefetchable) [size=16M]
 Memory at a0000000 (64-bit, prefetchable) [size=256M]
 Memory at b0000000 (64-bit, prefetchable) [size=32M]
 I/O ports at 6000 [size=128]
 Expansion ROM at <ignored> [disabled]
 Capabilities: <access denied>
 Kernel driver in use: nvidia

check this post...

Three ways to install Nvidia and the way on "F**k Nvidia" begins...

Install from official website fails. 

check the graphic card

if you wanna check whether your laptop is suitable for OpenGL,
/usr/lib/nux/unity_support_test -p
and you will see something like
OpenGL vendor string:   NVIDIA Corporation
OpenGL renderer string: GeForce GTX 660/PCIe/SSE2
OpenGL version string:  4.4.0 NVIDIA 340.96

Not software rendered:    yes
Not blacklisted:          yes
GLX fbconfig:             yes
GLX texture from pixmap:  yes
GL npot or rect textures: yes
GL vertex program:        yes
GL fragment program:      yes
GL vertex buffer object:  yes
GL framebuffer object:    yes
GL version is 1.4+:       yes

Unity 3D supported:       yes
if the unity 3D supported is no, definitely it won't work well.

Some issues related to the graphic drivers, is already in the wiki. And pub key, dpkg lock,

Rather than Nvidia, Google is our best friend forever. Most of the problems can be solved by google and askubuntu forum so will not repeat here. For different hardware settings and different system configuration, just tackle the problem when it happens.

after disable gpu, can enter system but unity_support_test -p

Xlib:  extension "NV-GLX" missing on display ":0".
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  27
  Current serial number in output stream:  28

without gpu, cannot run rviz.

sudo apt-get install nvidia-current-updates
sudo nvidia-xconfig

Again, Nvidia driver problem. on a desktop with sole Nvidia graphic card, gtx1060.

Phenomenon: We can see the welcome screen ,after enter the password, the display blackout and back to the welcome screen again... so it is a deadlock.

Installed 367.XX, cannot be solved. Tried 375, same problem.

When switched to tty1, an error is printed on the screen:

TSSI upper saturation

Ok, I am not sure about this error and google cannot give me much useful info.

Wednesday, 24 August 2016

[ROS Issues] Problems during installing sound_play package on an Odroid XU4

I am going to add some sound play and recognition function on my mobile robot. All good (Ok currently only sound synthesis) on my SONY VAIO laptop, Ubuntu 14.04 with Indigo. Alsamixer shows it is a HDA Intel PCH card...
Though I need to run 

rosdep install --from-paths /path/to/my/sound_play --ignore-src
to install some missing dependent libs to make the package compiled successfully.

However, on the Odroid XU4, ubuntu 14.04 with indigo, I connect a Logitech Z205 usb speaker, there is no compilation problems on my system, but cannot be executed, it says festival is not installed so I try rosdep again.

rosdep install --from-paths /path/to/my/sound_play --ignore-src -r
After that festival will be installed but still some dep errors.

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
sound_play: Cannot locate rosdep definition for [gir1.2-gst-plugins-base-1.0]

Never mind, try

roslaunch sound_play test.launch 
will see some warning

[WARN] [WallTime: 1472029411.178135] Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

However this should not be the problem why it is silent. Check 
alsamixer, my device is odroid-audio, try to change it to logitech. 

On the sound_play wiki trouble shooting page or configuring page

asoundconf set-default-card [device #]
but asoundconf not found ... Ok, try to install this cmd.. until I found this 

One guy is trying to add sound_play to his robot using ros... Wonderful, 
I did not try to understand the command line by line, but the most important part for me (changed from the original post according to my own conf)

$ pacmd list-sources | grep -e device.string -e 'name:'
name: <alsa_output.platform-sound.12.analog-stereo.monitor>
device.string = "0"
name: <alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo.monitor>
device.string = "1"

$ pacmd set-default-source alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo.monitor 
Welcome to PulseAudio! Use "help" for usage information.

$ pacmd list-sink | grep -e 'name:' -e 'index'
odroid@odroid:/etc$ pacmd set-default-sink alsa_output.

$ pacmd set-default-sink alsa_output.usb-Logitech_Logitech_Z205-00-Z205.analog-stereo 
Welcome to PulseAudio! Use "help" for usage information.

Try again !

roslaunch sound_play test.launch 
"Beep, Beep!" Very loud. 

If we try 

roslaunch sound_play soundplay_node.launch
rosrun sound_play test
Then we can hear "Hello world"!


when there is a sound file (.wav) cannot be completed?

To be resolved..

Tuesday, 12 July 2016

Install Dual Boot System (Windows10 and Ubuntu14.04 Ubuntu 16.04) UEFI, Legacy, bcdedit, etc..

2017 July 06
Original Title: Install Dual Boot System (Windows10 and Ubuntu14.04) on a SONY VAIO laptop

Recently I am teaching ROS in China for the spark program. The dual boot system is critical but it gives many problems. I try to gather different info about this.

If you are looking for a general guidance for dual boot system installation, checkout this

I cannot remember how many times I have been installing ubuntu on a windows PC to realize a dual boot system for ROS. However, seems every time I would encounter some silly frustrated problems. Pity that I did not write down all the details how I solved the problem previously, now I wish to keep this post in very detail when there are problems in installing ubuntu and ROS. This post should be actively maintained.

Install Ubuntu 14.04 on a Pre-installed Windows 10 PC 

2016 Jul 12
I want to install ubuntu14.04 on a SONY VAIO laptop T series with NVidia graphic card. The OS is Win10 upgraded from win8.1, all the partitions for recovery or backup are never modified.

Normally just follow some common tutorials and the system can be boot to ubuntu grub menu. However this time I have no luck.

As usual, I have downloaded a Ubuntu 14.04 ISO file from the official website, created a bootable usb thumb drive, emptied one of the partition, and boot from USB device. FIRST ISSUE - Ok, for my laptop, DEL or any Funtion keys won't take me into BIOS setup... Simply press ASSIST during power off instead of press the power key, you will have an option to access bios setup. EVERY laptop is different, find your own way to do that.

Installing ubuntu...

However after restart, the familiar grub does not appear. The system directly enter Windows 10. Tried many ways but no use. Changed to boot from legacy mode and OPERATING SYSTEM NOT FOUND! Sure no operating system found because both of my OS are installed in UEFI mode. And in the BIOS settings, in UEFI mode, the system cannot detect the UEFI options as some other BIOS do.

After searching for some posts, we conclude that we should use bcdedit to change the start sequence. (Some suggest use EasyBCD, I can add a new entry and see the NeoSmart Ubuntu option when UEFI boot up but it cannot enter ubuntu, giving some bcd errors. I suggest bcdedit as we know what happened behind the scene)

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi
Some one suggest that we should change the boot manager path to these two files. For this sony notebook both do not work. Pay attention in Windows 10 we should use
bcdedit /set '{bootmgr}' path \EFI\ubuntu\grubx64.efi
bcdedit /set '{bootmgr}' path \EFI\ubuntu\shimx64.efi
And I unlocked the efi partition, I have these files there.

So I made a quick decision, reinstall ubuntu, in LEGACY BIOS, and it works, now I can simply choose my OS through change the bios settings. UEFI to win10 and legacy to Ubuntu. Next will try change legacy mode ubuntu to UEFI, will post here if works.

One more thing, EasyBCD 2.2 ruined my windows boot system after I tried many combinations(add and delete entries, finally crashed). Not sure if version 2.3 works well, but it seems safer because it disabled many settings. Repair the bcd using a newly created win10 bootup usb device.
Here is the error code and solution.
error code: 0xc0000098 Missing file: /bcd
solution from this post.

key steps, enter prompt shell and repair bcd using the command lines:


UEFI and Legacy BIOS
I was aware that UEFI is a newer version of firmware, but I did not pay attention to the difference of UEFI and traditional BIOS. Many mistakes are due to the lack of knowledge of UEFI. checkout this link:
You will find it useful if you encountered pitfalls during making dual boot system.

Future work

Next, will be install ubuntu 16.04 on a win10 pc, should be much easier according to the post above.

And, install ubuntu on all kinds of embedded systems, smartphones, etc.

2017 July  06

Today I tried to install the ubuntu 14.04 on a lenovo x260.
There are many options in the Bios to configure the boot sequence and mode. After many testing, we found that the live cd can only boot in legacy mode.

check this post which mentions

I think the following paragraphs are quite clear and should be read carefully.

On a machine with a UEFI boot system and Windows 10 pre-installed or upgraded from Windows 8.1 it is most likely that Windows 10 will be installed in EFI mode. That means we should run the Ubuntu live session in EFI mode and then Ubuntu will be installed in EFI mode. Whatever mode one OS is installed in (EFI or BIOS/Legacy) the other OS must also be installed in. If we do not do that then we will only be able to load one of the 2 OS.

If Windows is installed in EFI mode and the Ubuntu live session is running in BIOS/Legacy mode, then we will only get the option to Erase disk & install Ubuntu or Something Else. No offer to install alongside.

If Windows 10 is installed in EFI mode then the Windows installer will have created an efi boot partition for the Windows efi boot files. The Ubuntu installer when installing Ubuntu in EFI mode will make use of the existing efi boot partition to put the Ubuntu efi boot files in and it will do that without over-writing the Windows efi boot files. And sda1 will be the efi boot partition.

I am guessing that the Ubuntu live session is running in BIOS/legacy mode. If it is running in efi mode then there can only be one place to install the Ubuntu boot loader efi files - sda1

So we cannot leave the "device for boot loader installation" option to the default setting, because the system does not boot in UEFI mode. We need to find the partition with efi format. Not tried yet.

Friday, 25 October 2013

Let's integrate pcl17 with ROS Fuerte. Using Point Cloud Libary to perform object recognition

We are going to add 3D object recognition to our robot so I have been trying to implement PCL 1.7 on ubuntu 12.04 these two weeks, where the ROS version is fuerte. As we know, even we only want to have a small function in ROS, we need to look into a lot of documents and it is a pity that there is very few step by step tutorial. I simply record what I have done for the past two weeks for my own reference and I hope it can help some one who want to do the same thing.

If you are using Groovy or Hydro, this article may not be helpful on some technical details. However, the pipeline should be the same.

I. PCL17 

Currently PCL is independent from ROS. And the original ros wiki http://wiki.ros.org/pcl  does not provide up-to-date info for PCL installation. We need to refer to wiki.ros.org/pcl17 and you can get basic ideas how to do that through reading the following two posts.


For me, I have downloaded pcl17, but for pcl_ros I am using the original one with fuerte. The package pcl_ros provides functions to convert different data types between PCL and ROS and transformation for point cloud.

It takes quite a looooooong time to compile pcl17. Over 3000s on my Thinkpad T410. So please be patient or just AFK..

II. pcl/Tutorial

Though the compilation of the pcl17 itself is not a problem, it is not that straight forward to include PCL in your own ROS code. Firstly, we try to go through the pcl/Tutorial.  This is a very important tutorial and you should read the whole page line by line and try not to miss a single word!


This section is just following and explaining the ros tutorial,  solving the problems during compilation.

1.Code skeleton

I am not familiar with catkin so that I am using rosbuild. Because in this version of PCL, the used namespace is pcl17. That means we need to change all the pcl:: to pcl17::, and use #include<pcl17/***> instead of #include<pcl/***>. Also, remember to change the manifest.xml

<depend package="pcl17"/>

I stick to the dependency on pcl_ros package because I am not using pcl17_ros.

<depend package="pcl_ros"/> 

You should be able to compile the example.cpp successfully. 


Proceed on to ros pcl tutorial section 4.1, simply add the 5 lines of codes into function cloud_cb(), pcl::VoxelGrid . Now you have a function which can down sample the point cloud.

rosrun my_pcl_tutorial example input:= <PointCloud2>
The input must be a PointCloud2 type. If you have an RGB-D device and openni installed, you can try


The results can be visualized in rviz.
But, if you do not have an RGB-D device at present? You can download some .pcd file, the extension means point cloud document.  For example


After you have the .pcd file, we can use the function in pcl_ros to publish a point cloud. Refer to http://wiki.ros.org/pcl_ros 4.4.3 Usage. For example

rosrun pcl_ros pcd_to_pointcloud milk_cartoon_all_small_clorox.pcd 0.5

So the pcd_to_pointcloud function can read the .pcd file and publish it as point cloud every o.5 sec. The topic is


Finally, using

rosrun my_pcl_tutorial example input:=/cloud_pcd

Now we can see some results in rviz.

3. pcl/PointCloud<T>

I did not really compile and execute this tutorial.  But the data type conversion mentioned here is very important. The cloud using in ROS is sensor_msgs::PointCloud2, but in PCL it is pcl17::PointCloud. We need to perform conversions when needed. The functions are fromROSMsg and toROSMsg, can be checked in


Pay attention to the format whether your input argument is a pointer or not? We will give detailed examples in the next section.

III. Correspondence Grouping 

After trying out some examples, now we are going to integrate the object recognition with ROS. Please refer to the following link. Now let's try to realize the function in ROS.


1. Code Modification

Read through the PCL tutorial, get familiar with the functions. As we already have the ROS skeleton for PCL, what we need to do is to embed the main() function into cloud_cb(). It is not necessary to have showHelp() and parseCommandLine(). We simply modify the parameters in the program. If you want use command line to control the parameters, ROS provides powerful tools to do that..

Similarly, change all the pcl:: to pcl17::. Pay attention to PCL_VISUALIZER_POINT_SIZE, this parameter in visualization:: class need to change to PCL17_VISUALIZER_POINT_SIZE.

To use the .pcd file provided by the tutorial, you can simply read the .pcd file, or using pcl_ros::fromROSMsg, take in the parameters are arguments for cloud_cb(). Here, we read the model from the file, and takes in the scene from ROS topic. In this way, it is easier to change the scene from .pcd file.

To read the .pcd file, we can use the loadPCDFile() provided by PCL. However, it seems that the loaded point cloud does not contain the transformation/reference information, we need to define it in either camera_link or base_link. Or else it cannot be shown in rviz because rviz cannot perform a transformation.
// The model is loaded from pcd file, the scene is directly obtained from the camera, rostopic, which is an input of the cloud_cb.
  std::string   model_path=ros::package::getPath("my_pcl_tutorial");
  if (pcl17::io::loadPCDFile (model_path, *model) < 0)
    std::cout << "Error loading model cloud." << std::endl;

  model->header.frame_id= "camera_link";
  model->header.stamp = ros::Time::now ();

for the scene cloud
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
  pcl17::fromROSMsg (*input, *scene);

 And we publish the rotated_model
  pub.publish (cloud_filtered);

If you are still not clear how to modify the code, leave me a message with your email.

Finally, we are not going to use the visualization module. Because the visualization will spin itself and the call back function stops there...Instead, we need to publish the topic and visualize the results in rviz. So, we can comment out all the visualization:: class related code. The specific lines which need to be commented are listed below.

  //pcl17::visualization::PCLVisualizer viewer ("Correspondence Grouping");
  //viewer.addPointCloud (scene, "scene_cloud");

    //viewer.addPointCloud (off_scene_model, off_scene_model_color_handler, "off_scene_model");

    //viewer.addPointCloud (scene_keypoints, scene_keypoints_color_handler, "scene_keypoints");
    //viewer.setPointCloudRenderingProperties (pcl17::visualization::PCL17_VISUALIZER_POINT_SIZE, 5, "scene_keypoints");

    //viewer.addPointCloud (off_scene_model_keypoints, off_scene_model_keypoints_color_handler, "off_scene_model_keypoints");
    //viewer.setPointCloudRenderingProperties (pcl17::visualization::PCL17_VISUALIZER_POINT_SIZE, 5, "off_scene_model_keypoints");

    //viewer.addPointCloud (rotated_model, rotated_model_color_handler, ss_cloud.str ());

        //viewer.addLine<PointType, PointType> (model_point, scene_point, 0, 255, 0, ss_line.str ());

//  while (!viewer.wasStopped ())
//  {
//    viewer.spinOnce ();
//  }

2. Compilation 

The executable for our program is correspondence_grouping. Here several errors are listed. However, some errors may not be a problem if you have already changed your code according to my suggestion.

fatal error: vtkMatrix4x4.h: No such file or directory
Add in two lines into CMakelists.txt

target_link_libraries(correspondence_grouping ${PCL_LIBRARIES} libvtkCommon.so libvtkFiltering.so libvtkRendering.so)

Please refer to http://answers.ros.org/question/39444/pcl-visualizer-error/?answer=39744#post-id-39744

libboost error

/usr/bin/ld: note: 'boost::system::system_category()' is defined in DSO /usr/lib/libboost_system.so.1.46.1 so try adding it to the linker command line
  /usr/lib/libboost_system.so.1.46.1: could not read symbols: Invalid operation

You need to add in one line into CMakelist.txt

rosbuild_link_boost(correspondence_grouping system)

PCL_VISUALIZER_POINT_SIZE not declared in common.h
This is introduced in the previous section. Change it to PCL17_VISUALIZER_POINT_SIZE
Please refer to

3. Show results 

Hopefully you can compile you code successfully. 

First, publish the point cloud from a .pcd file. Pay attention to the file path

rosrun pcl_ros pcd_to_pointcloud pcd/milk_cartoon_all_small_clorox.pcd 0.2

So the reference for the cloud is by default /base_link.

rosrun my_pcl_tutorial correspondence_grouping input:=/cloud_pcd

And now we can have a look at the results in rviz.