Tales of using ROS and raspberry pi.

Even if you don’t like robots, it can still be a pretty cool skateboard.

Woooooot, I finally got everything working on my little Pydro-bot (inderstand Pi+ROS Hydro + Robot). So, what is working so far :

  • The Robot variant of ROS

  • Openni1 and 2

  • OpenCV and opencv2 (the third library for ROS)

  • openni2_camera (thanks to kalectro repo )

  • My drivers for Faulhaber controller

If anyone wants an image of the Raspberry system, feel free to write to me and I’ll send you one. It’ll save you hours of compiling code not to be sure it’s working (EDIT : I’m having the hardest time sending the image so I can guarantee you anything about this, sorry. Tutorial is still all good though. EDIT2 : Ok I’m supposed to have a working torrent now (thanks Victor) and you can as well download the image at this link)

But if you want to understand how everything is working, or just want to do it yourself, keep reading. It was a painful process but I learned a lot about how everything is working and I can’t recommend enough that you try to do it, if you have the time.

So, most of the documentation needed for the install was dispatched over the internet and my job was mostly to find everything that was useful and make it all work together one way or the other. Let’s start with the ROS part.

Installing ROS

There is that website which perfectly explain how to install the “bare bone” version of ROS on the raspberry PI. I know there is another version version on the ROS wiki but I somehow found the jigsaw version of it more useful as it provided more explanation of the process.

The bare bone version provide us core components of the ROS system but I have to say that you can do very little with it. That is why we want to install the “robot” version which gave us more packages. If you want to know which packages it add, I invite you to go check on this link.

Mostly I choose this one for xacro, URDF, TF and smach. I needed it to use my Faulhaber driver/differential drive controller since it uses tf to publish the odometry.

So, following the tutorial, install all the dependancies required :

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu raring main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install rosdistro
sudo pip install wstool
mkdir ~/Downloads
cd ~/Downloads
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-1.1.6.tar.gz
tar xvf setuptools-1.1.6.tar.gz
cd setuptools-1.1.6
sudo python setup.py install
sudo apt-get install python-stdeb
sudo pip install rosdep
sudo pip install rosinstall-generator
sudo pip install -U rospkg

That will get you going.

sudo apt-get install python-rosdep python-rosinstall-generator build-essential

And now is the interesting part. Since we want to install the robot version, here is what you need to do :

sudo rosdep init
rosdep update
mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws
rosinstall_generator robot --rosdistro hydro --deps --wet-only > hydro-robot-wet.rosinstall
wstool init src hydro-ros_comm-wet.rosinstall
cd src

This will download all the package of the robot variant in the hydro-robot-wet.rosinstall file and then all of them will be extracted in the src folder.

We start following the tutorial again and suppress the roslip package to avoid the dependency issue :

wstool rm roslisp
rm -rf roslisp

Same thing for all collada dependent package. Collada is not available with debian system and you can either install it as described here or you could suppress any package that depend on Collada. Honestly I tried installing it but I didn’t work out directly and since it was not relevant with what I wanted my robot to do I just suppressed everything using wstool as for roslisp.

Here, you could merge any package that you want to add that is outside of the Robot variant. I personally advise you to compile now since next time, all the already compiled package will not take that long and you’ll be sure that you’ve installed a correct and fonctionnal version of ROS to begin with.

cd ~/ros_catkin_ws
rosdep install --from-paths src --ignore-src --rosdistro hydro -y --os=debian:wheezy
./src/catkin/bin/catkin_make_isolated --install

This should take you a couple of hours so be patient.

Don’t forget to setup your environment before trying to roscore. If everything went well, congrats you have a working version of ROS on you’re raspberry.

Installing Openni and Openni2

My goal was to be able to use my Xtion of my raspberry powered Robot. Thus I needed Openni1 and/or 2.

This is going to be fast. To install Openni1 this link is perfect ! Everything is working flawlessly and it should get you going.

For Openni2, this easiest way is to use Kalectro repo and just do make in it. It should compile all of Openni2.

That was easy right ? =)


Ok so now you want to use openni2_camera package on the Raspberry. It is just perfectly normal to go for the easiest solution. But, openni2_camera need OpenCV and as I discovered after a few days of experiment it need OpenCV as a third party library in ROS AND and as a lib outside of it.

Let’s start with the install from source.

From source

So this is the instructions I have been following. I tried other ones with more thing but it keep failing especially on the ffmpeg part. I think I configured it to NOT compile with ffmpeg option. There is lot of stuff you don’t need actually, I’m pretty sure, the ROS package we want and can use on raspberry for not use any particularly “heavy” functionality of OpenCV. This took a really long time to compile, and crashed at 95% for me, you’ve been warned.

As a third library in ROS

I repeat, you need to do both the source install above and the third party install here for openni2_camera to be working. Here we go !

Need to source install like this :

cd ros_catkin_ws/src
rosinstall_generator opencv2 --deps | rosws merge -
rosws update
cd ..
rosdep install --from-paths src --ignore-src --rosdistro hydro -y --os=debian:wheezy
./src/catkin/bin/catkin_make_isolated --install

Ok lets explain this.

cd ros_catkin_ws/src

First we’re going into our “ros install” folder this we want to had a package here

rosinstall_generator opencv2 --deps | rosws merge -

There we use the rosinstall_generator tool to had an opencv2 entry to the rosinstall file and we merge it with the ros workspace (rosws ;p). The --deps command is used to add all opencv2 dependcy to the workspace at the same time. Then we update the workspace so to add that opencv2 package.

You already recognized the two last commands as the actual compilation and installation of the ros workspace as we already did above. No need to tell you that this step takes forever…

Installing openni2_camera

Great so you have everything set up to make that little Xtion work on your Raspberry Pi. All that is left is the actual node that is openni2_camera. Can you see the light at the end of the tunnel ?

So we follow our dear Kalectro directives :

  • copy the file libOpenNI2.so from OpenNI2/Bin/Armv6l-Release to one of your cmake lib folder (most likely /usr/lib) Also copy the entire OpenNI2 folder in OpenNI2/Bin/Armv6l-Release into /usr/lib

  • go into your catkin_ws and

git clone https://github.com/MalcolmMielle/openni2_camera

(take care, it’s not the workspace where you installed ros. My setup look something like this : tobot_ws directory – inside I have ros_mobile_ws were I installed ros, i.e all the previous instruction and catkin_ws which is my project workspace in a way. It’s this one where you add openni2_camera)
* catkin_make your catkin workspace.
* Don’t forget to source your catkin workspace if it’s not already done.
* cd to the directory OpenNI2/Bin/Armv6l-Release (for ARM processors). start the program using rosrun openni2_camera openni2_camera_node.

BOUM ! It should be working !

I did very few change compared to Kalectro openni2_camera repository. The only thing I did is adding all the OpenCV linkers in the CMakeList.txt as I would have

openni2_camera.cpp:(.text._ZN2cv3MataSERKS0_[cv::Mat::operator=(cv::Mat const&)]+0x12c): undefined reference to `cv::Mat::copySize(cv::Mat const&)'

kind of errors without it.

I’m currectly working on trying to find another way to do all this, so you don’t have to cd in the OpenNI2/Bin/Arm directory.


Now using ssh, you are free to move your Pi robot around looking through the Xtion camera from your computer. Mobile remote controlled robot with a kick ass camera on it, who don’t want that ? Have fun !


25 thoughts on “Tales of using ROS and raspberry pi.

  1. Hi, thanks for this wonderful tutorial! I am also interested in controlling robots (in my case, a quadcopter). If possible, can I have a copy of your image? It took me a few months’ work on raspberry pi and ended up re-installing many times and still no luck.

    1. I’m not currently home so I only have old image I’m not sure are working fine. But give me a week or two and I’ll have it on me and send it to you, no worries ! Hwow can I send it to you ? =)
      And remind me if I forget ! =)

      1. Yeah, that sounds great. I really appreciate it. Well, I am guessing email will not work for the image due to the size, so online storage like Dropbox may be the way to go if possible? Thanks again and btw, do you have a demo video of your work on this? I am a bit curious 🙂

      2. Google drive will do the work just fine then.
        No I don’t, I just did it for fun so I had a mobile robot controlled through the network that I simply teleoperated. Nothing much. Like stated, bandwidth is not nearly good enough to allow lots of practical application like object recognition and so on.

  2. Hi, I have sort of built openni2_camera based on your article and others. I am curious how your “rosrun openni2_camera openni2_camera_node” is working? Mine says “[ INFO] [1413721766.906098286]: Everything set up… lets stream some images” at the end line but nothing pops up. Is anything showing on your screen when you run it? Also, do you know how we can fetch the 3D data from Xtion? Thanks a lot!

    1. Hi !
      Do you have any topic that publishes camera image ? You should have something like /points_xyzrgb. You can retrieve the image simply by accessing the data publish by the topic. If you want direct visualization you can use rosrun image_viewer image_viewer topic_name. I don’t remember if anything happened after “lets stream some image”. Hope it helped !

  3. Hey there–Can I get a copy of this image too? I’m having the damndest time finding working Xtion drivers. Your site here seems to have the most up to date info I can find.

    1. Hi !
      I’m currently having hard time finding two things : a stable internet connection and a way to share that 16Go image of the Rasphydro… :/
      I plan on trying to create a torrent next week. I’ll keep you updated if it works !

  4. Hi ! i followed your tutorial, but i got stuck to build openni_camera
    catkin_make gives me this error

    CMake Error at /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:331 (if):
    if given arguments:

    "NOT" "DEFINED" "__pkg_config_checked_PC_OPENNI2" "OR" "__pkg_config_checked_PC_OPENNI2" "LESS" "OR" "NOT" "PC_OPENNI2_FOUND"

    Unknown arguments specified
    Call Stack (most recent call first):
    openni2_camera/CMakeLists.txt:11 (pkg_check_modules)

    — Configuring incomplete, errors occurred!
    Makefile:263: recipe for target ‘cmake_check_build_system’ failed

    how can i fix it?

    could you help me please? ..

      1. Thanks to reply!!

        I just solved this problem by deleting the code below at openni2_camera/CMakeLists.txt

        10 #include libopenni2
        11 pkg_check_modules(PC_OPENNI2 REQUIRED libopenni2)

        Actually rosrun openni2_camera openni2_camera_node. works well. i can see the depth and image by rviz.

        Is there any problem if i delete this??
        and any adding path for libOpenNI2.so and OpenNI2 folder to pkg-config after copy these in /usr/lib ??

      2. Did you use openni_camera from the kaletro repo ? I feel like we did remove that line but I’m not sure :p.
        No if its working now, you won’t have a problem. You just suppressed a Cmake check that doesn’t work. As long as openni2 is installed, you’re good to go :D.
        No adding to pkg-config after copying to /use/lib for now :). If you find a way not to have to move to the directories to launch openni_camera, I’ll be glad if you send it to me so I update the tutorial :).

      3. Okay I’ll do my best for launch openni_camera problem haha..

        Actually I wrote how to install ros_indigo tutorial at this community site(http://cafe.naver.com/openrt/8687)

        And I want to make tutorial how to use xtion and openni.

        May I translate your tutorial to korean?

        I will add your blog at the end of the page.

        Thanks to reply!

  5. Hello malcomm

    I have downloaded the image from mega.nz website and installed it on a
    samsung 16 Gb card, it got written successfully.
    But the Pi board is not getting booted with that card.
    No activity on monitor or on card.
    Can you tell what possibly went wrong.
    Kindly help to resolve it.

    Thanks & Regards

      1. I have used win32 disk imager to write the image to a 16 GB SD card.
        I have tried two times, still no booting takes place.
        kindly help to resolve this

      2. No luck, I have no idea how to do it on windows or what the problem could be. You should do it from a ubuntu using the command dd, that’s how I do it usually :). I can’t verify that the image is correct right now but I think other people have used it without problem.
        have you tried another SD card ? Or another Raspberry PI ? what Raspberry pi is it ? B or B+ ? I used the B one.
        Have you tried compiling it yourself by following the tutorial ?

  6. I’m getting an error when I run make inside the OpenNI2 folder: “error: target CPU does not support ARM mode.” Any idea what’s going wrong?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s