Full installation instructions: Difference between revisions

From Rsewiki
 
(91 intermediate revisions by the same user not shown)
Line 1: Line 1:
Back to [[Robobot]]
==Installation instruction on the raspberry==
==Installation instruction on the raspberry==


Line 4: Line 7:


[[Install on raspberry]] first section (prerequisites).
[[Install on raspberry]] first section (prerequisites).
===Opencv 3.4===
It should be OK just to install libopencv-dev - in December 2020 this installs version 3.2.0
sudo apt install libopencv-dev
To find the installed version of OpenCV try
pkg-config --modversion opencv
To install newer OpenCV version 3.4  (as of Jan 2020 it is version 3.4.9)
cd
mkdir -p git
cd git
# this method will install version 4.2 - that is not fully compatible (jan 2020)
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_contrib.git
# use this to get a version compatible with opencv 3.4
# get source (jan 2020)
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
# compile the lot, but ommit python3 support, as the compile will fail (as of jan 2020)
cd opencv
mkdir build
cd build
# create makefiles, also for all modules in the opencv_contrib (e.g. ArUco code detect)
# cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python3=OFF -D OPENCV_EXTRA_MODULES_PATH=~/git/opencv_contrib/modules ..
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python3=OFF -D OPENCV_EXTRA_MODULES_PATH=~/git/opencv_contrib-3.4/modules ..
# 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 more than an hour.
# if the compilation crashes about halfway or so, it is probably due to lack of memory
#    then just start the compile again, and it is likely to continue (at least for a while)
make -j2
# install into /usr/local
sudo make install
# load environment settings
sudo ldconfig


===Raspicam===
===Raspicam===
NB! this should not be needed


A rather short raspberry pi camera API is available from https://www.uco.es/investiga/grupos/ava/node/40.
A rather short raspberry pi camera API is available from https://www.uco.es/investiga/grupos/ava/node/40.
And can be downloaded from https://sourceforge.net/projects/raspicam/files/, or just get the file https://sourceforge.net/projects/raspicam/files/raspicam-0.1.4.zip/download
And can be downloaded from https://sourceforge.net/projects/raspicam/files/,  
 
or get the file from sourceforge with no GUI, with:
 
cd ~/Downloads
wget --no-check-certificate -O raspicam-0.1.9.zip https://downloads.sourceforge.net/project/raspicam/raspicam-0.1.9.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fraspicam%2F%3Fsource%3Dtyp_redirect&ts=1486483484&use_mirror=netix


Once fetched and available on the raspberry, then
Unpack and install:
Unpack and install:
  unzip raspicam-0.1.3.zip
  unzip raspicam-0.1.9.zip
  cd raspicam-0.1.3
  cd raspicam-0.1.9
  mkdir build
  mkdir build
  cd build
  cd build
Line 20: Line 73:
  sudo ldconfig
  sudo ldconfig


The library is installed in /usr/local, and therefore to make cmake find it the path needs to be added to to startup configuration
The library is installed in /usr/local, and therefore to make cmake find it the path needs to be added to startup configuration, in file ~/.bashrc


nano ~/.bashrc
add at the end:
  export CMAKE_PREFIX_PATH=/usr/local/lib
  export CMAKE_PREFIX_PATH=/usr/local/lib


(needs a re-logon to be activated)
(needs a re-logon to be activated, or repeat on the command line)
 
===Userland-master===
 
To be able to install mobotware
 
Follow the guide under REGBOT for userland-master install - [[Install on raspberry]]


===DNSMASQ===
===DNSMASQ===


To enable the robobot to be connected directly to a PC, then it is easier if the robobot provides an IP for the PC.
To enable the ROBOBOT to be connected directly to a PC, then it is easier if the ROBOBOT provides an IP for the PC.


Install DNSMASQ
Install DNSMASQ
Line 44: Line 93:


  sudo nano /etc/dnsmasq.conf
  sudo nano /etc/dnsmasq.conf
 
find and change/add the following line (a bit down, eg to serch use: ctrl-W dhcp-range)
find and change/add the following line (for eth0)
  dhcp-range=192.168.17.100,192.168.17.150,12h
 
  dhcp-range=eth0,192.168.0.100,192.168.0.150,12h


To work, the eth0 must have an IP, if noone provides one,
To work, the eth0 must have an IP, if noone provides one,
change /etc/dhcpcd.conf (dhcp client deamon) to have a default IP, if no DHCP server is available
change /etc/dhcpcd.conf (dhcp client deamon) to have a default IP, if no DHCP server is available


Add the following lines at the end of /etc/dhcpcd.conf to have a fall back behaviour for eth0 and eth1.
Edit of /etc/dhcpcd.conf to have a fall back behaviour for eth0 and eth1.


sudo nano /etc/dhcpcd.conf
Add the following lines at the end (uncomment and modify):
  # define static profile
  # define static profile
  profile static_eth0
  profile static_eth0
  static ip_address=192.168.0.2/24
  static ip_address=192.168.17.1/24
  static routers=192.168.0.1
  # static routers=192.168.0.1
  static domain_name_servers=192.168.0.1
  # static domain_name_servers=192.168.0.1
   
   
  # fallback to static profile on eth0
  # fallback to static profile on eth0
Line 64: Line 113:
  fallback static_eth0  
  fallback static_eth0  
   
   
# define static profile
profile static_eth1
static ip_address=192.168.1.2/24
static routers=192.168.1.1
#static domain_name_servers=192.168.0.1
# fallback to static profile on eth1
interface eth1
fallback static_eth1


This will also give a default IP for an eventual second network (usb-to-cable) if needed
This will also give a default IP for an eventual second network (usb-to-cable) if needed
Line 78: Line 118:
Now, after a reboot, you should be able to connect a PC directly with at network cable to a PC, and the PC should get an IP from the raspberry, so now
Now, after a reboot, you should be able to connect a PC directly with at network cable to a PC, and the PC should get an IP from the raspberry, so now


  ssh local@192.168.0.2
  ssh local@192.168.17.1
 
should work
 
===ROBOBOT demo C++===
 
This is an examplesoftware in C++ to access both raspberry camera and REGBOT, and with an example mission controlled from the raspberry.


Get the robobot software from the svn repository:
===Sound===


svn checkout svn://repos.gbar.dtu.dk/jcan/regbot/robobot robobot
====festival====


To be able to compile the demo software CMAKE needs also to use the user installed library (raspicam installed above),
Easy understandable voice, but takes time to generate
so add the following line to ~/.bashrc:
and require two intermediate files


  export CMAKE_PREFIX_PATH=/usr/local/lib
  sudo apt install festival
echo "The brown fox jumps over lazy dog" > aaa.txt
text2wave aaa.txt -o aaa.wav
aplay aaa.wav


Then build Makefiles and compile:
====Music files====


cd robobot
This part works
cd build
cmake ..
make


Then testrun the application:
Play sound files, like


  ./robobot
  sudo apt-get install sox libsox-fmt-all
play -v0.1 music.mp3


It should print that the camera is open, save an image and print some data from the robot (e.g. position).
This line plays an mp3 file with volume reduced by a factor 0.1.
The at startup the blue button on the gamepad plays the file in /home/local/Music/music.mp3.<br>
This is a symbolic link to some real music (Radetzky Marsch in this case):


===USB as SOCKET for REGBOT client===
ls ~/Music
    radetzky-marsch_Schloss-Schoenbrunn-Konzerte_Wien_full-length.mp3
cd ~/Music
ln -s radetzky-marsch_Schloss-Schoenbrunn-Konzerte_Wien_full-length.mp3 music.mp3


To use the REGBOT client through (not on) the raspberry pi, the serial connection /dev/ttyACM0 on the raspberry can be converted to a network port by SOCAT. So install:
===Sound level===


sudo apt install socat
On a Raspberry pi version 3+ (not tested on other versions)


Add the following line to /etc/rc.local
$ amixer
  Simple mixer control 'PCM',0
    Capabilities: pvolume pvolume-joined pswitch pswitch-joined
    Playback channels: Mono
    Limits: Playback -10239 - 400
    Mono: Playback 400 [100%] [4.00dB] [on]


socat TCP-LISTEN:24001,fork,reuseaddr FILE:/dev/ttyACM0,raw,echo=0
An thus:<br>
Setting the sound level can be done by:


This creates a TCP socket server, listening to port 24001 and piping /dev/ttyACM0 to the socket (with no local echo). This only takes the data from the /dev/ttyACM0 when a client is connected to the socket.
amixer set PCM 0dB unmute


Works after a reboot, or the same line on the command prompt.
Setting to maximum (100%) is about the same as setting 4dB (may be too much for amplifier).


This is good for configuring the REGBOT (in REGBOT client connect wifi to IP of robot, e.g. 192.168.0.2).
amixer set PCM 100% unmute


===Share files from windows===
===Regbot GUI===


To share files on all windows computers (without need for administrator) configure a samba share
To run the regbot gui on the raspberry the following package is needed
(or follow Simon on http://simonthepiman.com/how_to_setup_windows_file_server.php)


First install samba
Additional python packages used


sudo apt install samba samba-common-bin
* python-pyqtgraph
* python-qt4-gl
* python-serial
* python-scipy


then edit /etc/samba/smb.conf
sudo apt install python-pyqtgraph python-qt4-gl python-serial python-scipy


sudo nano /etc/samba/smb.conf


comment out all lines under the headlines:
=====* no python-pyqtgraph =====
[homes]
[printers]
[print$]
[cdrom]


Add the following section at the end:
On my 14.04 32 bit ubuntu the python-pyqtgraph package was not found using apt-get, so I


[robobot]
downloaded from http://www.pyqtgraph.org/
comment = Raspberry Pi user LOCAL home directory
the debian package ''python-pyqtgraph_0.9.10-1_all.deb'' and installed using:
path = /home/local
writeable = Yes
only guest = Yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes


sudo dpkg -i python-pyqtgraph_0.9.10-1_all.deb


Add "local" and "pi" as a samba user (and set password, for user pi it should be "raspberry"):
sudo apt install python-pyqtgraph


sudo smbpasswd -a local
To start the GUI
sudo smbpasswd -a pi


Reboot to implement
cd ~/regbot/qtgui
python regbot.py


sudo reboot
Connect to network localhost or kill the bridge and connect directly to "/dev/ttyACM0" (not com5 as is the default serial connection).


====Windows map drive====
== File sharing for development ==


On the windows computer, connect a network cable directly between the robobot and the computer, e.g. using a USB to Ethernet converter. Robobot should now be available with network address 192.168.0.2 (you could try a ping if in doubt).
Mirror the local disk on the Raspberry to a PC, make all file editing here, and then on a terminal connection to the robot to compile the software.


In the file browser:
===Share files from windows===
* select "map network drive" (menu tools, or right-click on "my computer").
* select drive R: (for robobot) - or another if R is used already.
* in the folder field write: \\192.168.0.2\robobot, and select "Connect using different credentials", then OK.
* Type in username (local or pi) and the appropriate password (and OK).


Now the code and other files can be accessed and manipulated from windows, e.g. using an IDE.
On the windows computer install "winscp" and use it to copy files to and from the raspberry disk as needed.


* But the code still needs to be compiled on the raspberry (install and use putty for a ssh terminal access)
There are other methods too.


===Share files on Linux===
===Share files on Linux===


On the Linux PC use sshfs for sharing rather than samba.
On a Linux PC use sshfs for sharing.
Make an empty directory for the mapped disk, and then mount
Make an empty directory for the mapped disk, and then mount



Latest revision as of 13:55, 24 December 2020

Back to Robobot


Installation instruction on the raspberry

Install raspberry pi version of Linux on a micro-SD, instructions can be found here:

Install on raspberry first section (prerequisites).

Opencv 3.4

It should be OK just to install libopencv-dev - in December 2020 this installs version 3.2.0

sudo apt install libopencv-dev

To find the installed version of OpenCV try

pkg-config --modversion opencv

To install newer OpenCV version 3.4 (as of Jan 2020 it is version 3.4.9)

cd
mkdir -p git
cd git
# this method will install version 4.2 - that is not fully compatible (jan 2020)
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_contrib.git
# use this to get a version compatible with opencv 3.4
# get source (jan 2020)
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
# compile the lot, but ommit python3 support, as the compile will fail (as of jan 2020)
cd opencv
mkdir build
cd build
# create makefiles, also for all modules in the opencv_contrib (e.g. ArUco code detect)
# cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python3=OFF -D OPENCV_EXTRA_MODULES_PATH=~/git/opencv_contrib/modules ..
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_opencv_python3=OFF -D OPENCV_EXTRA_MODULES_PATH=~/git/opencv_contrib-3.4/modules ..
# 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 more than an hour.
# if the compilation crashes about halfway or so, it is probably due to lack of memory
#    then just start the compile again, and it is likely to continue (at least for a while)
make -j2
# install into /usr/local
sudo make install
# load environment settings
sudo ldconfig

Raspicam

NB! this should not be needed

A rather short raspberry pi camera API is available from https://www.uco.es/investiga/grupos/ava/node/40. And can be downloaded from https://sourceforge.net/projects/raspicam/files/,

or get the file from sourceforge with no GUI, with:

cd ~/Downloads
wget --no-check-certificate -O raspicam-0.1.9.zip https://downloads.sourceforge.net/project/raspicam/raspicam-0.1.9.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fraspicam%2F%3Fsource%3Dtyp_redirect&ts=1486483484&use_mirror=netix

Once fetched and available on the raspberry, then Unpack and install:

unzip raspicam-0.1.9.zip
cd raspicam-0.1.9
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig

The library is installed in /usr/local, and therefore to make cmake find it the path needs to be added to startup configuration, in file ~/.bashrc

nano ~/.bashrc
add at the end:
export CMAKE_PREFIX_PATH=/usr/local/lib

(needs a re-logon to be activated, or repeat on the command line)

DNSMASQ

To enable the ROBOBOT to be connected directly to a PC, then it is easier if the ROBOBOT provides an IP for the PC.

Install DNSMASQ

sudo apt install dnsmasq

allow dnsmasq to provide IP to pear-to-pear networks Edit the /etc/dnsmasq.conf (nano is a small text editor, fine for editing configuration files owned by Linux root)

sudo nano /etc/dnsmasq.conf
find and change/add the following line (a bit down, eg to serch use: ctrl-W dhcp-range)
dhcp-range=192.168.17.100,192.168.17.150,12h

To work, the eth0 must have an IP, if noone provides one, change /etc/dhcpcd.conf (dhcp client deamon) to have a default IP, if no DHCP server is available

Edit of /etc/dhcpcd.conf to have a fall back behaviour for eth0 and eth1.

sudo nano /etc/dhcpcd.conf
Add the following lines at the end (uncomment and modify):
# define static profile
profile static_eth0
static ip_address=192.168.17.1/24
# static routers=192.168.0.1
# static domain_name_servers=192.168.0.1

# fallback to static profile on eth0
interface eth0
fallback static_eth0 

This will also give a default IP for an eventual second network (usb-to-cable) if needed

Now, after a reboot, you should be able to connect a PC directly with at network cable to a PC, and the PC should get an IP from the raspberry, so now

ssh local@192.168.17.1

Sound

festival

Easy understandable voice, but takes time to generate and require two intermediate files

sudo apt install festival
echo "The brown fox jumps over lazy dog" > aaa.txt
text2wave aaa.txt -o aaa.wav
aplay aaa.wav

Music files

This part works

Play sound files, like

sudo apt-get install sox libsox-fmt-all
play -v0.1 music.mp3

This line plays an mp3 file with volume reduced by a factor 0.1. The at startup the blue button on the gamepad plays the file in /home/local/Music/music.mp3.
This is a symbolic link to some real music (Radetzky Marsch in this case):

ls ~/Music
   radetzky-marsch_Schloss-Schoenbrunn-Konzerte_Wien_full-length.mp3
cd ~/Music
ln -s radetzky-marsch_Schloss-Schoenbrunn-Konzerte_Wien_full-length.mp3 music.mp3

Sound level

On a Raspberry pi version 3+ (not tested on other versions)

$ amixer
 Simple mixer control 'PCM',0
   Capabilities: pvolume pvolume-joined pswitch pswitch-joined
   Playback channels: Mono
   Limits: Playback -10239 - 400
   Mono: Playback 400 [100%] [4.00dB] [on]

An thus:
Setting the sound level can be done by:

amixer set PCM 0dB unmute

Setting to maximum (100%) is about the same as setting 4dB (may be too much for amplifier).

amixer set PCM 100% unmute

Regbot GUI

To run the regbot gui on the raspberry the following package is needed

Additional python packages used

  • python-pyqtgraph
  • python-qt4-gl
  • python-serial
  • python-scipy
sudo apt install python-pyqtgraph python-qt4-gl python-serial python-scipy


* no python-pyqtgraph

On my 14.04 32 bit ubuntu the python-pyqtgraph package was not found using apt-get, so I

downloaded from http://www.pyqtgraph.org/ the debian package python-pyqtgraph_0.9.10-1_all.deb and installed using:

sudo dpkg -i python-pyqtgraph_0.9.10-1_all.deb
sudo apt install python-pyqtgraph 

To start the GUI

cd ~/regbot/qtgui
python regbot.py

Connect to network localhost or kill the bridge and connect directly to "/dev/ttyACM0" (not com5 as is the default serial connection).

File sharing for development

Mirror the local disk on the Raspberry to a PC, make all file editing here, and then on a terminal connection to the robot to compile the software.

Share files from windows

On the windows computer install "winscp" and use it to copy files to and from the raspberry disk as needed.

There are other methods too.

Share files on Linux

On a Linux PC use sshfs for sharing. Make an empty directory for the mapped disk, and then mount

mkdir robobotdisk
sshfs local@192.168.0.2: robobotdisk

Unmount with

fusermount -u robobotdisk

Or use "sudo unmount robobotdisk"