Robotics StackExchange | Archived questions

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 laserscanmatcher 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/pcl.git cd pcl

Edit cmake/pclfindsse.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 scantools package (Which includes laserscanmatcher) into ros working dir (Assuming this is rosws)

pclconversions pclmsgs perceptionpcl scantools

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 laserscanmatcher 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 PKGCONFIGPATH 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 ~/rosws/src/scantools/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

Asked by MarkyMark2012 on 2016-03-21 15:43:25 UTC

Comments

+1 for the elaboration, but I have to ask; for Raspberry Pi2, can't you just use binary installation for ARM?

Asked by 130s on 2016-03-21 16:04:19 UTC

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.

Asked by 130s on 2016-03-21 16:08:14 UTC

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?

Asked by DM2 on 2016-07-12 23:17:06 UTC

pi 3 is v7. I found I had to build pcl from scratch - might be a bit faster on pi 3 than 2 Mark

Asked by MarkyMark2012 on 2016-07-13 02:59:40 UTC

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

Asked by DM2 on 2016-07-13 17:57:33 UTC

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

Asked by DM2 on 2016-07-13 18:03:08 UTC

@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

Asked by MarkyMark2012 on 2016-09-10 06:53:39 UTC

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%.

Asked by EwingKang on 2018-02-01 02:02:53 UTC

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.

Asked by EwingKang on 2018-02-01 02:06:38 UTC

Answers