Raspberry Pi – ROS – Arbotix – OpenCV – ffmpeg

Hier sind Erfahrungen mit der Installation von ROS-Fuerte auf einem Raspberry Pi Modell B mit 512MByte Arbeitsspeicher. Eine Installationsanleitung auf www.ros.org für ROS-Fuerte auf einem Raspberry Pi war zu der Zeit nicht verfügbar. Die Installation basiert auf der Anleitung für Debian-Systeme. Ein grober Fehler, der passiert ist, war das Überspringen eines gesamten Installationsschrittes. Trotzdem habe ich das Installations-Protokoll nicht korrigiert, denn Fehler passieren, und es ist trotzdem möglich, ein ROS-Desktop (ohne rviz, PCL) + ffmpeg0.6.6 + OpenCV 2.4.3 auf einen Raspberry Pi zu kompilieren. Die Gesamt-Installation und -Konfiguration dauert Tage…

Raspberry Pi - ROS - OpenCV running

Raspberry Pi – Betriebssystem

Auf eine 16GB-Micro-SD-Karte wird das Image: 2012-10-28-wheezy-raspbian.img installiert –  dd (Linux), Win32 Disk Imager (Windows).
Siehe auch Installationsanleitung hier.

SECURITY:

Autologout 30 min.
vi /etc/profile

TMOUT=1800

Root-Login mit ssh nicht erlaubt.

vi /etc/ssh/sshd_config
PermitRootLogin no

VNC über SSH tunneln.

Voraussetzungen:

1. RaspberryPi:
Software: sshd, vncserver

>> vncserver :1 (Startet VNCServer auf Port 5901)

2. Client-PC (Windows):
Software: PuTTY, tightVNC-Viewer
-PuTTY starten
-Konfiguration Session:

Host Name (or IP address) = raspberrypi
Port = 22

-Konfiguration Connection -> SSH -> Tunnels -> Port forwarding

Source port = 5901
Destination = 127.0.0.1:5901

Add-Button drücken.

Ohne PuTTY sieht der Connection-String so aus:

ssh -L 5901:127.0.0.1:5901 raspberrypi

Open-Button drücken.

TightVNC-Viewer starten

VNCServer = 127.0.0.1:5901

Connect-Button drücken.

In Wireshark oder tcpdump sollten dann keine VNC-Pakete mehr erscheinen, stattdessen SSH. Empfehlenswert ist auch die strikte Verwendung von SSHv2-Protokoll.
Client:

PuTTY -> Connection -> SSH -> Protocol options -> 2only

Server:

/etc/ssh/sshd_config -> Protocol 2

KONFIGURATION:

Raspberry Pi muss übertaktet werden (High 950 MHz), da sonst die Kompilierungszeit zu groß wird.

sudo raspi-config

Farbige Konsole für root.

vi /root/.bashrc
PS1='e[1;31;40mu@h:w # e[0m'

Der Arbotix-Controller macht Probleme auf nicht US-Systemen.

dpkg-reconfigure locales

en_US.UTF-8 auswählen.

Allgemein
Aktuelles Datum setzen, zum Beispiel: 06.12.2012 14:31

date 120614312012

Serielle Schnittstelle (Rechte):

groupmod -a -G dialout rosuser

Webcam (Rechte):

groupmod -a -G video rosuser

SWAP (empfohlen während Install, 900MB):

sudo swapoff -a
sudo dd if=/dev/zero of=/var/myswap bs=1024 count=900k
sync
sudo mkswap /var/myswap
sudo swapon /var/myswap
vi /etc/fstab
/var/myswap     swap            swap    defaults          0       0

 

ROS-Fuerte

INSTALL:

1.1

1.

sudo apt-get install build-essential python-yaml cmake subversion wget python-setuptools mercurial git-core

2. (Zu installierende Pakete übersehen, siehe Fehler bei 1.3.1)

sudo apt-get install python-yaml libapr1-dev libaprutil1-dev  libbz2-dev python-dev libgtest-dev python-paramiko libboost-all-dev liblog4cxx10-dev pkg-config python-empy swig

3.

sudo apt-get install python-nose

4. (Optional graphical tools  ‚ROS Full‘)

sudo apt-get install python-wxgtk2.8 python-gtk2 python-matplotlib libwxgtk2.8-dev python-imaging libqt4-dev graphviz qt4-qmake python-numpy

5.

sudo apt-get install bison++ automake autoconf
git clone https://github.com/wg-debs/swig-wx.git
cd swig-wx
./autogen.sh && ./configure && make && sudo make install

1.2 US-Amerikanisches Tastaturlayout einstellen

Der Arbotix-Controller macht Probleme mit anderen Sprachen, deshalb en_US.UTF-8.

sudo dpkg-reconfigure locales

=> en_US.UTF-8

Spielt keine Rolle wenn per Putty eingeloggt wird, da in Putty konfigurierbar ist, wie sich die Tastatur verhalten soll.

1.3

1. rosinstall

sudo apt-get install python-rosinstall

ODER (IF the above fails…)

sudo apt-get install python-pip
sudo pip install -U rosinstall

2. rospkg

sudo pip install -U rospkg

3. rosdep

sudo pip install -U rosdep
sudo rosdep init
sudo rosdep update

1.3.1

Download/Update ROS-Libs:

Full:

rosinstall --catkin ~/ros-underlay http://ros.org/rosinstalls/fuerte-ros-full.rosinstall

Fehler:
ERROR in config: Error processing ‚actionlib‘ : [actionlib] Checkout of git: No such file…
Siehe: http://answers.ros.org/question/46848/installing-ros-from-source-actionlib-error/
Lösung: Textdatei „fuerte-ros-full.rosinstall“ anpassen:
a. Download: http://ros.org/rosinstalls/fuerte-ros-full.rosinstall
b. Öffnen: vi Download/fuerte-ros-full.rosinstall
c. Ändern: wg-debs = ros-gbp
d. Ausführen: sudo rosinstall –catkin ~/ros-underlay file:///Pfad_zu/fuerte-ros-full.rosinstall

Build:
cd ~/ros-underlay
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/ros/fuerte

Fehler:

— Could NOT find PY_em (missing:  PY_EM)
CMake Error at catkin/cmake/empy.cmake:29 (message):
Unable to find either executable ‚empy‘ or Python module ‚em’…
try installing package ‚python-empy‘
Call Stack (most recent call first):
catkin/cmake/all.cmake:51 (include)
catkin/CMakeLists.txt:12 (include)
Lösung:

sudo apt-get install python-empy

Fehler:
GTest not found
Lösung:

sudo apt-get install libgtest-dev


Fehler:

Couldn’t find Boost
1. Installiert libboost-dev
2. Deinstalliert libboost-dev
3. Installiert libboost-all-dev
Lösung:

sudo apt-get install libboost-all-dev

Fehler: libboost-all-dev = 1.49 wird von ROS Fuerte nicht unterstützt
Lösung: verwende libboost1.46-all-dev

Fehler:
Couldn’t find log4cxx library
Lösung:

apt-get install liblog4cxx10-dev

Fehler:
Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
Lösung:

apt-get install libbz2-dev

Make ROS

make -j8

Fehler:

Lösung:

make -j1
export ROS_OS_OVERRIDE=debian:squeeze

(in ~/.profile eintragen!!!)

. /opt/ros/fuerte/setup.bash
rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no"

turtle.cpp AUSTAUSCHEN mit turtle.txt

1.5

rosdep install -ay --os=debian:squeeze

Schritt 1.5 hat NICHT GEKLAPPT!!!

 

Arbotix-Controller

Der Arbotix-Controller wird mit dem Raspberry PI über einen FTDI-Schnittstellenadapter von SparkFun verbunden. Am Arbotix-Controller-Board sind drei Dynamixel-Ports vorhanden, an denen (aktuell) zwei AX12+-Motoren hängen. Am Ende sollen die Positionen der Motoren abgefragt und gesetzt werden.

Voraussetzung: Arbotix-ROS wurde auf den Arbotix-Controller übertragen. Im Ordner ..Arbotix_Firmwarearbotix_firmwaresrc befindet sich die Arduino-Datei „ros.ino„.

Arbotix Firmware

roscd
svn http://vanadium-ros-pkg.googlecode.com/svn/trunk/arbotix

Abhängigkeiten
Siehe: ~/ros-workspace/arbotix/arbotix_python/nodes/manifest.xml, …/arbotix/rosdep.yaml
Stack: control
Package: control_msgs
APT: python-serial

roscd
roslocate info control
roslocate info control | rosws merge -
rosws update control
roslocate info control
source setup.bash

roslocate info arbotix
roslocate info arbotix | rosws merge -
rosws update
source setup.bash

rospack list


rosmake:

rosmake arbotix_python
rosmake arbotix_msgs

FEHLER:
arbotix import serial error: no module named serial
LÖSUNG (siehe auch ~/ros-workspace/arbotix/arbotix_python/nodes/manifest.xml):

sudo apt-get install python-serial

rosmake nach Fehlerbehebung:

rosmake arbotix_python
rosmake arbotix_msgs

SETUP/START

source /opt/ros/fuerte/setup.bash
rosrun arbotix_python terminal.py
>>  ls
.... .... ....    4    5    6 .... .... ....
.... .... .... .... .... .... .... .... ....
>>  ls
.... ....    3    4    5    6 .... .... ....
.... .... .... .... .... .... .... .... ....
>>  get pos 3
358
>>  set pos 3 500
OK
>>  get pos 5
314
>>  set pos 5 400
OK

remote shell(ssh) into Raspberry PI controlling
humanoid via arbotix-controller.

 

usb_cam

Die Treiber von Bosch haben nicht zuverlässig auf dem Raspberry PI gearbeitet. Teilweise lag es an der schlechten Kamera und deren Bildrate. Am Ende hat es mit den gscam-Treibern am Besten funktioniert. Deshalb kann ich die Verwendung von usb_cam auf einem Raspberry PI nicht empfehlen.

Logitech QuickCam E2500 VGA with Bosch-Drivers

Quellennachweis:
http://www.ros.org/wiki/usb_cam

Abhängigkeiten
manifest.xml

1. Installation

roscd
roslocate info usb_cam
roslocate info usb_cam| rosws merge -
rosws update
source setup.bash
rosmake usb_cam

FEHLER:
error: no module named pluginlib
LÖSUNG:

roslocate info pluginlib
roslocate info pluginlib| rosws merge -
rosws update
source setup.bash
rosmake pluginlib
rosmake usb_cam

FEHLER:
error: no module named tinyxml
FEHLER:
_ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
LÖSUNG:

sudo apt-get install libavcodec-dev 
sudo apt-get install libswscale-dev
sudo apt-get install libtinyxml-dev
rosmake usb_cam

FEHLER:
ros libusb_cam.so: undefined reference to `avcodec_decode_video‘
LÖSUNG:

sudo apt-get remove --purge libavcodec-dev
sudo apt-get install libavcodec-dev
rosmake --pre-clean usb_cam
roscore &
rosrun usb_cam usb_cam_node

FEHLER:

rosrun usb_cam usb_cam_node

usb_cam video_device set to [/dev/video0]
usb_cam io_method set to [mmap]
usb_cam image_width set to [640]
usb_cam image_height set to [480]
usb_cam pixel_format set to [mjpeg]
usb_cam auto_focus set to [0]
[mjpeg @ 0xd658e0] codec type or id mismatches
Could not open MJPEG Decoder
Segmentation fault
LÖSUNG: ???

 

1.1 Video-Rechte

usermod -a -G video benutzername

 

1.2 Testing usb_cam on RaspberryPi :: wheezy

roscore
rosrun usb_cam usb_cam_node

FEHLER:
Webcam: expected picture but didn’t get it…
11 frames/sec at 1359486887.849637453
Webcam: expected picture but didn’t get it…
Webcam: expected picture but didn’t get it…
LÖSUNG:
siehe 5 : usbCam.launch

 

1.3 Tutorial OpenCV – USBCam

1. Erstelle eigenes Paket

roscreate-pkg tutorial_rosopencv_mc image_transport roscpp std_msgs opencv2 cv_bridge usb_cam arbotix_msgs arbotix_python

2. Absteigen in Paketordner

cd tutorial_rosopencv_mc

3. Launch-Datei Ordner erstellen

mkdir launch

4. Absteigen in Launch-Ordner

cd launch

5. Launch-Datei erstellen

vi usbCam.launch

<!--xml-->
<launch>
<node ns="camera" pkg="usb_cam" type="usb_cam_node" name="usb_cam" output="screen">
    <param name="image_width" type="int" value="320" />
    <param name="image_height" type="int" value="240" />
    <param name="io_method" type="string" value="read" />
    <param name="camera_frame_id" type="string" value="webcam" />
    <param name="video_device" type="string" value="/dev/video0" />
    <param name="pixel_format" type="string" value="yuyv" />
</node>
//* TEST
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
    <remap from="image" to="/usb_cam/image_raw"/>
    <param name="autosize" value="true" />
</node>
*//
</launch>

 

6. ROS_PACKAGE_PATH

vi ~/.bashrc

Am Ende:

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/ros/tutorial_rosopencv_mc
source ~/ros/setup.bash

7. rosmake

rosmake tutorial_rosopencv_mc

FEHLER:
opencv not found
Lösung:
opencv installieren

OpenCV

02.02.2013 19:00

 

1 Installation

1.1 Systemvoraussetzung:

-Raspberry PI Model B (512MB RAM) mit Debian wheezy
-folgende Programme und Bibliotheken

Basierend auf der Installationsanleitung für Debian-Systeme.

Quellennachweis:
http://opencv.willowgarage.com/wiki/InstallGuide%20:%20Debian
http://www.ros.org/wiki/ROSberryPi/Setting%20up%20ROS%20on%20RaspberryPi

apt-get install build-essential
apt-get install cmake
apt-get install pkg-config
apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3
apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2 (PNG-Output-Support)
apt-get install zlib1g-dbg zlib1g zlib1g-dev
apt-get install libjasper-dev libjasper-runtime libjasper1
apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs
apt-get install ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev
apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin
apt-get install libunicap2 libunicap2-dev
apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
apt-get install swig
apt-get install libv4l-0 libv4l-dev
apt-get install python-numpy
apt-get install libpython2.7 python-dev python2.7-dev
apt-get install libgtk2.0-dev pkg-config
apt-get install libgstreamer-plugins-base0.10-dev

Bugs:
http://raspberrypi.stackexchange.com/questions/1888/error-in-installing-opencv-on-raspberry-pi

1.2 Download OpenCV-2.4.3:

wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2

1.3 Extrahieren, Compiler-Ordner erstellen

tar xvf OpenCV-2.4.3.tar.bz2
cd OpenCV-2.4.3
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..

1.4 Kompilieren

make

FEHLER:
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
LÖSUNG:
ffmpeg installieren! Siehe ffmpeg

make

FEHLER:
(Segmentation Fault -> Arbeitsspeicher-Problem):
/home/beeper/Download/OpenCV-2.4.3/modules/highgui/src/window.cpp: In function ‘double cvGetWindowProperty(const char*, int)’:
/home/beeper/Download/OpenCV-2.4.3/modules/highgui/src/window.cpp:153:1: internal compiler error: Segmentation fault

Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.cpp.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
LÖSUNG:
Memory und CPU/GPU auf normale Geschwindigkeit setzen

raspi-config -> Overclocking -> Normal oder Medium (Dauer ca. 9h)
raspi-config -> Memory -> GPU=32 (vorher 64)
make

Ca. 9 Stunden später…

sudo make install

 

1.5 Konfiguration OpenCV

 

sudo vi /etc/ld.so.conf.d/opencv.conf
/usr/local/lib
sudo ldconfig

ffmpeg

03.02.2013 14:34

falls ffmpeg zuvor installiert war:

sudo apt-get remove --purge ffmpeg
sudo apt-get remove libavcodec53

1. Installation

1.1 Systembibliotheken

MP3, Ogg-Theora, Ogg-Vorbis, V4L, H.264, MPEG-4:

sudo apt-get install libmp3lame-dev
sudo apt-get install libtheora-dev
sudo apt-get install libvorbis-dev
sudo apt-get install libv4l-dev
sudo apt-get install libvpx-dev
sudo apt-get install libx264-dev
sudo apt-get install libxvidcore-dev

1.2 Download ffmpeg

0.6.6 läuft mit libavcodec52 (VORHER ffmpeg + libavcodec53 deinstallieren)

wget http://ffmpeg.org/releases/ffmpeg-0.6.6.tar.bz2

ODER die neueste Version verwenden (nicht getestet!).

1.1.1 neueste Version (01/2013)

wget http://ffmpeg.org/releases/ffmpeg-1.1.1.tar.bz2

1. 3 Konfiguration und Kompilation (mehrere Stunden…)

tar xvf ffmpeg-0.6.6.tar.bz2
cd ffmpeg-0.6.6
./configure --enable-shared --enable-pic 
--enable-libdc1394 --enable-libmp3lame --enable-libtheora 
--enable-libvorbis --enable-libv4l2 --enable-libvpx  --enable-libxvid 
--enable-libx264 --enable-gpl

make
sudo make install
sudo ldconfig

(zurück zu OpenCV)

gscam

gstreamer cam

Fehler in CMakeLists.txt während rosmake gscam:
fatal error: glibconfig.h: No such file or directory
Folgende „lib“ in CMakeLists.txt hinzufügen:
/usr/lib/arm-linux-gnueabihf/glib-2.0/include

rosmake gscam


Tutorial:

export GSCAM_CONFIG="v4l2src device=/dev/video0 ! video/x-raw-rgb ! ffmpegcolorspace"
roscore &
rosrun gscam gscam
rosrun image_view image_view image:=/gscam/image_raw

 

Schreibe einen Kommentar