how to: Building PCL & laser_scan_matcher on Raspberry pi 2
All,
I thought I would publish this "how to" to build pcl and related ros libraries on a raspberry pi with a view to running the laser_scan_matcher on a pi.
My motivation for this was because I found there were often timing issues when I ran the LSM on the host PC
So here goes:
Installing PCL on Raspberry Pi 2
System Set-up
sudo apt-get update
sudo apt-get install libflann-dev
sudo apt-get install libqt4-dev libvtk5-qt4-dev
sudo apt-get install gsl-bin libgsl0-dev
Ensure swap space is = 2Gb - some of the complilation of PCL uses up a lot of memory (In total takes about 24 hrs on raspberry Pi 2)
First we have to build PCL git clone https://github.com/PointCloudLibrary/... cd pcl
Edit cmake/pcl_find_sse.cmake and replace '-march=native' from line (approx) 10 with '-march=armv6 -mfloat-abi=hard -mfpu=vfp
Edit the files below and add this line before the definition is checked for
#define BOOST_LITTLE_ENDIAN
~/pcl/io/include/pcl/io/ply/byte_order.h
~/pcl/common/include/pcl/PCLPointCloud2.h
Then build pcl
mkdir build && cd build
cmake ..
make -j1 (>j1 will fail and given the swap space usage uses up too much bandwidth)
sudo make install
Now we need to make the ros PCL libraries and the scan_tools package (Which includes laser_scan_matcher) into ros working dir (Assuming this is ros_ws)
pcl_conversions pcl_msgs perception_pcl scan_tools
cd ~/ros_ws/src
git clone https://github.com/ros-perception/pcl_conversions.git
git clone https://github.com/ros-perception/pcl_msgs.git
git clone https://github.com/ros-perception/perception_pcl.git
git clone https://github.com/ccny-ros-pkg/scan_tools.git
Before kicking these off we need to set csm up CSM: csm is a part of the laser_scan_matcher can requires a couple of configs to be set first
git clone https://github.com/AndreaCensi/csm.git (I cloned this into a sub directory of scan_tools)
Build csm (catkin will do this but I just found it easier to check it build okay)
You can run the csm build script to do this
./install_quickstart.sh
Update PKG_CONFIG_PATH to include the path to csm.pc
In my case this was:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/pi/ros_ws/src/scan_tools/csm/sm/pkg-config
Set up the csm headers - these didn't copy to the right location for me so I did it manually: cp -r ~/ros_ws/src/scan_tools/csm/deploy/include/ /home/pi/ros_ws/install/
Finally we're ready to make all the libraries So from top level
catkin_make
If there are problems I suggest building the pcl packaged first then csm and scan_matcher
Hope this finds a use.
Mark
PS thanks to @joq for the help with csm
+1 for the elaboration, but I have to ask; for Raspberry Pi2, can't you just use binary installation for ARM?
Answering to my own question; Looks like for ARM for Indigo the binary of laser_scan_matcher is not available as of today. I'm the maintainer of the package but I don't know yet how to submit a request for building ARM binaries.
If using a raspberry pi 3, is it armv6 or v7? Also can ros_pcl be used, or do I have to use PCL? (I have ros_pcl package which isn't really working so I'm trying the entire PCL now). However, I'm fairly sure I have the pcl from apt-get... which doesn't seem to work. Must I build it from scratch?
pi 3 is v7. I found I had to build pcl from scratch - might be a bit faster on pi 3 than 2 Mark
Thanks Mark. So I have to change v6 to v7? I've also realised that I actually have pcl 1.7 already installed (and can program with it) from a previous project... Compiling takes entirely too long even on the pi 3... granted my swap is only 1 GB. I'll try changing it to 2 GB and try again
Actually the major problem I'm having is csm. I just can't get catkin to find csm even with everything installed/copied... using rosdep install gives me "no definition of [csm] for OS [debian]. After building csm, when I try to catkin_make_isolated, it can't find csm anyway
@DM2 - sorry late reply - you need to put cms in the scan_tools dir and build it independently (just cmake .. in the bin dir) . But the key is to "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/pi/ros_ws/src/scan_tools/csm/sm/pkg-config" or where ever it is on your system
FYI, the cmake/pcl_find_sse.cmake has been changed. Now the line you should edit is around line 19. Line 10 is now comment section for Apple device it would seems. I just suffer from my idiot for 3 days because I edited the wrong place. You'll get a out of memory error at around 50%.
Also, my Raspberry Pi Model B v1.1 gives the info of "ARMv7 Processor rev 5 (v7l)" with command "cat /proc/cpuinfo" and "Linux user 4.4.38-v7+ #938 SMP TIME armv7l armv7l armv7l GNU/Linux". I suppose I could also use -armv7 option? The v6 option compiled successful anyway.