Mobotware on raspberry

From Rsewiki
Revision as of 10:44, 23 December 2020 by Jca (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

NB!

NB! This info may be depricated.

Packages needed

sudo apt install cmake
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk2.0-dev 
sudo apt install libatlas-base-dev gfortran alsa-tools jackd1
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev subversion libreadline-dev htpdate aptitude
# video for linux had some error, maybe this will help
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
# opencv
# sudo apt install libopencv-dev (sorry, installs opencv 2.4 (jan 2020), with no ArUco code support)

Opencv

As of June 2019 opencv 3.2 is installed using line above - NO, it is back to 2.4 on noops 3.2.1 (jan 2020/jca)

Newer version of Opencv could be installed manually if you really need functions not available in 3.2. For newer installation use

# make a directory for the opencv source
cd
mkdir -p git
cd git
# get source
wget -O opencv-3.4.zip https://github.com/Itseez/opencv/archive/3.4.zip
unzip opencv-3.4.zip
wget -O opencv_contrib-3.4.zip https://github.com/Itseez/opencv_contrib/archive/3.4.zip
unzip opencv_contrib-3.4.zip
# you will need this - if you use python - takes some minutes
pip install numpy
# prepare compilation
cd ~/git/opencv-3.4/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
   -D CMAKE_INSTALL_PREFIX=/usr/local \
   -D INSTALL_PYTHON_EXAMPLES=ON \
   -D OPENCV_EXTRA_MODULES_PATH=~/git/opencv_contrib-3.4/modules \
   -D BUILD_EXAMPLES=ON ..
# inspect printout to see if needed features are enabled
# use -j2 option not to overload or overheat the processor (j2 means use 2 cores only)
# this probably takes an hour or so
make -j2
# install into /usr/local
sudo make install
# load environment settings
sudo ldconfig


Packages needed for Mobotware RHD/MRC

Package list for RHD and MRC (paste the last line to a terminal window):

libexpat-dev   (RHD)
pciutils-dev   (RHD)
libncurses-dev (RHD)
bison          (MRC)
libsdl-dev     (MRC)
telnet         (MRC test)
sshfs          (may be a good idea to access filesystem from another PC)
sudo apt-get install subversion libexpat-dev pciutils-dev libncurses-dev bison libsdl-dev telnet sshfs

Additional for AURS (e.g. camera server)

Package list - opencv removed as newer version installed above (paste the last line to a terminal window)

cmake
# libopencv-dev
libreadline-dev
libudev-dev
libusb-dev
# libv4l-dev
python-dev
libgstreamer0.10-dev
libboost-dev
libboost-system-dev
python-opencv          (not needed, but nice)
sudo apt-get install cmake libreadline-dev libudev-dev libusb-dev libgstreamer0.10-dev libboost-dev libboost-system-dev python-opencv

Python

Further python image processing install

sudo pip install Image

Mount filesystem

As an option, mount the home directory on raspberry-pi to your local PC for easy file modification.

On your PC type make a directory for the filesystem

mkdir rpi
sshfs local@10.59.8.141: rpi
ls rpi

with your IP address or IP replaced by hostname.local.

Unmount with

fusermount -u rpi

Mobotware

Get and unpack mobotware - see main page of this wiki for info

Either from SVN - if you have access, or from our lab-computers as a mobotware-XXX.tar.gz file, where XXX is version number.

unpack if a .gz file and make a symbolic link to "mobotware" to make this guide work.

tar -xzf mobotware-XXX.tar.gz
ln -s mobotware-XXX mobotware

or, if from SVN:

svn co svn://repos.gbar.dtu.dk/jcan/mobotware mobotware

this makes a mobotware directory with all the files.

Modify makefiles

Not all parts of Mobotware runs on a raspberry, so some parts must be removed from the Makefiles:

Enter the mobotware directory

cd mobotware-XXX

main Makefile

nano -w Makefile

Change this section

APPSUBDIRS = aumat/trunk \
   aurobotservers/trunk/include \
   aurobotservers/trunk/libs \
   mapbase/trunk \
   rhd/trunk \
   mrc/trunk \
   hakoclient/trunk  \
   aurs-plugins/aumanager aurs-plugins/aumrcobst aurs-plugins/auplanner/trunk \
   aurs-plugins/auzoneobst \
   aurobotservers/trunk \
   simulator/trunk

delete the lines

hakoclient/trunk  (GUI for HAKO tractor)
simulator/trunk   (simulator will not run on raspberry)

so that it looks like

APPSUBDIRS = aumat/trunk \
   aurobotservers/trunk/include \
   aurobotservers/trunk/libs \
   mapbase/trunk \
   rhd/trunk \
   mrc/trunk \
   aurs-plugins/aumanager aurs-plugins/aumrcobst aurs-plugins/auplanner/trunk \
   aurs-plugins/auzoneobst \
   aurobotservers/trunk

Remember to remove the last back-slash

RHD plugins Makefile

cd rhd/trunk/plugins
nano -w Makefile

In this section

PLUGINLIST := auserial gps crossbow fogyro hakocan smrdserial rflex \
             rs232linesensor powercube esm slugs usbiss sf9dof \
             joycontrol gdm8246 buspiratei2c buspiratead \
             herkulex saberandmagenc imu gps2\
             smrarm rhdlog hexakopter gbprofibus roboteq gpsSocket \
             fieldsteer fielddrive fieldfrontenc \
             dynamixel cruizcore simstage3

Remove

gbprofibus
simstage3

server Plug-ins etc.

Some servers and plug-ins are excluded from raspberry pi (qclient, kinect and point-cloud related plug-ins) in the respective Makefiles.

Build

Build mobotware:

cd ~/mobotwareXXX
make

This should now compile with warnings only

(augraphplan.h not found may appear, but try one more make, then it usually works @todo - find out why)

install

The easyest way to use Mobotware is then to install into /usr/local/smr.

This is done by

sudo make install

There will be a few error messages related to the uncompileable modules: qclient, hakoclient, simserver and libstage, this is OK.

setup path

Add the mobotware bin-directory into default PATH in /etc/profile

sudo nano -w /etc/profile

append the PATH line with :/usr/local/smr/bin two places, like:

...
if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/smr/bin"
else
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/smr/bin"
fi
...

And add mobotware AURS library path into .bashrc

nano -w ~/.bashrc

append a line like this

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/smr/lib"

To make this work, you have to logout and login again.

Make a Mobotware test configuration

Logout and login to ensure that the PATH settings gets implemented

Make a directory to run from

mkdir ~/live
cd ~/live

Copy a robot configuration file

cp -r /usr/local/etc/mobotware/calib .

make a rhdconfig.xml file with this content (loads a joystick and log plugin only). Look in mobotware/build/config for specific versions for different robots.

<?xml version="1.0" ?>
<rhd>
 <sheduler>
   <period value="12000"/>
   <type value="LXRT"/>
 </sheduler>
 <server>
   <port value="24902"/>
   <clients number="10" allwriters="1"/>
 </server>
 <plugins basepath="/usr/local/smr/lib/rhdplugin/">
   <joycontrol enable="true" 
                   lib="libjoycontrol.so.1" 
                   critical="false" 
                   safety="1">
     <joystick port="/dev/input/js0"/>
     <speed maxfwd="900" 
          maxturn="900"
          fastBut="5"
          slowFactor="0.3"/>
     <deadband max="767" min="-767"/>
     <control enable="true"/>
   </joycontrol>
   <rhdlog enable="true"
         lib="rhdlog.so.1"
         critical="false"
         interval="1"
         safety="2"
         debug="0">
   </rhdlog>
 </plugins>
</rhd>

Test Mobotware

RHD

Hardware abstraction layer (Robot Hardware Daemon)

Start RHD

rhd

It should end saying "RHD is running"

(Stops with ctrl-C)

MRC

Mobile Robot Control.

While the RHD is running (in another terminal)

start the MRC

cd ~/live
mrc

This should show a list of options

-press 5 to quit

Laser scanner server

Start laser scanner server

ulmsserver

There will be some errors as there is no laserscanner ...

Press enter a few times to get a prompt ">>"

Type

help

this should show a list of loaded plugins, like

...
Available commands (from currently loaded modules):
- push q server help shelp module do BASH alive quit exit
- scanGet scanPush scanSet
- odoPose odoPosePush
- mapPose mapPosePush
- utmPose utmPosePush
- var varPush
- poly
- mapbase
- settable addline setinitpose setinitcov localizeMHF localize resetlocalizer outputdist odoposeupdate resample localizeUKF
...

Try e.g.

scanget fake=3

this should show a lot of HEX numbers and a few more errors.

Press q to quit

Camera server

Copy the camera server configuration for raspberry camera (otherwise a default ucamserver.ini will be created without the raspberry plugins).

cp ~/mobotware/build/config/raspberry/ucamserver.ini .

Start the camera server - and optionally load the camera plug-in.

ucamserver

This should end with something like this

Camera_server 2.1966 (May  1 2015 13:42:21 jca@oersted.dtu.dk)
- on port 24920
- type h for help, q for quit

If camera is available, then use

poollist

to se if camera is running.

Pres q to quit

Code change

Every time you recompile any module, it is not implemented until you also run

cd ~/mobotware
sudo make install

To implement newly compiled modules right away, change a symbolic link:

cd /usr/local
sudo rm smr
sudo ln -s ~/mobotware/build smr
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox