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.
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.
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.
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…
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
OpenNI2/Bin/Armv6l-Releaseto one of your cmake lib folder (most likely
/usr/lib) Also copy the entire
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 !