Full installation instructions

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Sound level)
(DNSMASQ)
Line 67: Line 67:
 
  # define static profile
 
  # define static profile
 
  profile static_eth0
 
  profile static_eth0
  static ip_address=192.168.17.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

Revision as of 11:07, 5 February 2019

Back to Robobot


Contents

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).

Raspicam

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:

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

or part of mission files on SVN (version 0.1.6)

Once fetched and available on the raspberry, then

Unpack and install:

unzip raspicam-0.1.6.zip
cd raspicam-0.1.6
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

export CMAKE_PREFIX_PATH=/usr/local/lib

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

Userland-master

To be able to install mobotware (not used pt on ROBOBOT)

Follow the guide under REGBOT for userland-master install - Install on raspberry

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 (for eth0)

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

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

# 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.2

Sound

To use the sound system install

sudo apt install espeak
sudo apt-get install sox libsox-fmt-all

The first speaks english using a command like

espeak -s120 -ven+f3 -a30 "This robot speaks English with a female voice and amplitude 30, at speed 120."

Code for other languages can be found at http://espeak.sourceforge.net/languages.html

The second line allows to play sound files, like

play -v0.1 music.mp3

This line plays the a mp3 file with volume reduced by a factor 0.1. The at startup the blue button on the gamepad playes 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

amixer set PCM 100% unmute

Regbot GUI

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

sudo apt get 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).

ROBOBOT bridge

This software connects and combines access to REGBOT, gamepad and the small o-led display.

Get the software - if not there already.

svn checkout svn://repos.gbar.dtu.dk/jcan/regbot/robobot_bridge robobot_bridge

To update - if there is a newer version

cd ~/robobot_bridge
svn up

Go to the build directory to build. "make" and "sudo make install" will maybe do.

cd ~/robobot_bridge
mkdir -p build
cd build
cmake ..
make
sudo make install

To make the bridge start at reboot, then add

sudo nano /etc/rc.local

add the line just before "exit 0", or everything if empty (make rc.local executable - probably is)

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
# this line is needed if on DTU internal network do get decent date and time
# as this channel otherwise is blocked
htpdate -q www.linux.org www.freebsd.org
# start bridge
cd /home/local/robobot_bridge/build && ./robobot_bridge -a &
exit 0

The bridge may be running already, to test use pgrep

pgrep bridge

If a process number is shown, then it is running. To stop the bridge (if not needed or changed)

sudo pkill bridge

You may then run the bridge from the console

cd ~/robobot_bridge/build
sudo ./robobot_bridge

It will then show status on the console.

To list the message database, then press 's' and return. For full functionality see help (h) and "help".

bridge >> s
Regbot bridge: regbot OK=1, Joy OK=1, Oled OK=1, socket=1 (port 24001 on thit), clients=0
#recorded 7 items:
  item 0 is  servo, upds=  0, dt=0.000s, valid=0, time=1.023s 
                           Servo control for robot 'servo n p' n:servo, p:position.
  item 1 is    pse, upds=5077, dt=0.026s, valid=1, time=135.344s '0.00160638 -1.66499e-05 -0.020729 0.0016065 1.8485'
                           Robot pose [x [m], y [m], h [rad], tilt [rad]].
  item 2 is    hbt, upds=213, dt=0.626s, valid=1, time=135.231s '3142.04 11.8582 0 0 0 289'
                           Heartbeat [time [sec], battery voltage [V].
  item 3 is    joy, upds=  6, dt=0.000s, valid=1, time=1.101s '1 0 8 11 0 0 -32767 0 0 -32767 0 0 0 0 0 0 0 0 0 0 0 0 0'
                           0 Joystick position, running, manual override, Axis count, Button count, A1, A2 ... An, B1, B2 ... Bn
  item 4 is    rc=, upds=  0, dt=0.000s, valid=0, time=1.025s 
                           Remote control for robot 'rc=m v t'  m:manual override, v:velocity, t:turn velocity.
  item 5 is      #, upds=  0, dt=0.000s, valid=0, time=2.026s 
                          (no description)
  item 6 is <alive, upds=133, dt=1.002s, valid=1, time=135.192s 'last="0.00028"/>'
                          (no description)
UServerPort::printStatus: running=1, clientsCnt=0, activeCnt=0, loops=0
bridge >> h
Bridge between a Regbot robot and joystick and socket clients
Runs on Linux PC and raspberry (preferably in rc.local - runs here an oled display too if available).
After start console has a cmd. line with following commands:
   q: quit
   s: status of data items etc
   h: this help
   help: help for the bridge
Longer lines are send to handler as message. 
bridge >> help
UBridge::responder: key=help get responder=3
# Robobot_bridge help:
# Commands are all single line text staring with a keyword
#     (up to 6 characters) followed by text or numbers:
# Main topics:
#     robot       Sends all rest of the line to the robot, see 'robot help' for options
#     bridge      See 'bridge help' for options
#     oled L xxx  Prints xxx (up to 20 chars) on line L (2..7) on oled
#     client      See 'client help' for options
#     q           quit
#     h           Console help
#     help        This help
# All lines starting with '#' are assumed to be comments
# All commands are stored as a data item with keyword as ID
# All data items has reserved subcommands, see:
#     item h      Help for data item 'item'
bridge >>

ROBOBOT mission demo C++

This is an example software 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:

svn checkout svn://repos.gbar.dtu.dk/jcan/regbot/mission mission

or just update if there already

svn up

To be able to compile the demo software CMAKE needs also to use the user installed library (raspicam installed above), so add the following line to ~/.bashrc:

export CMAKE_PREFIX_PATH=/usr/local/lib

Then build Makefiles and compile:

cd ~/mission
mkdir -p build
cd build
cmake ..
make

Then test-run the application:

./mission

It should print that the camera is open and connected to the robot (bidge).

Software structure

The software is structures as shown in figure 1 below.

500px

Figure 1. The example mission software intended as basis for full mission control. In the main.cpp file, three objects are created: bridge (UBridge reg(127.0.0.1)), camera (UCamera cam()) and mission (UMission mission(&reg, &cam)). The bridge handles communication and stores all data from the robot and the gamepad. The camera can capture images and image processing is intended here. The mission object is intended for splitting long missions into mission snippets that the REGBOT can execute.

The mission class has access to robot data and the camera at all times using the pointers "bot->" and "cam->". e.g. the heading (relative to the start position) and if the yellow gamepad button is pressed, can be fetched as:

float heading = bot->pose->h;
bool yellowButton = bot->joy->button[3];

Details about the data code may be found in the upose.cpp, uinfo.cpp, ujoy.cpp, umotor.cpp ... files.

The sound system can be used for debugging, e.g. add a C++ line like:

system("espeak \"bettina reached point 3\" -ven+f4 -a30 -s130");

This line makes the robot say "bettina reached point 3" the parameters "-a30" turns amplitude down to 30%, "-ven+f4" sets language to english with female voice 4 and "-s130" makes the speech a little slower and easier to understand. It requires that espeak is installed (sudo apt install espeak).

USB as SOCKET for REGBOT client

This is not compatible with use of ROBOBOT_BRIDGE, so don't use it here

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:

sudo apt install socat

Add the following line to /etc/rc.local

socat TCP-LISTEN:24001,fork,reuseaddr FILE:/dev/ttyACM0,raw,echo=0 &

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.

Works after a reboot, or the same line on the command prompt.

This is good for configuring the REGBOT (in REGBOT client connect wifi to IP of robot, e.g. 192.168.0.2).

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 the 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"

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox