Instructions for getting started

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Connecting Raspberry pi to PC using cable)
(DNSMASQ)
 
(31 intermediate revisions by one user not shown)
Line 1: Line 1:
 
Back to [[Robobot]]
 
Back to [[Robobot]]
  
 +
 +
== This part needs to be redone ==
 +
 +
Major parts are deprecated, but some are OK.
  
 
==Connect to the raspberry pi==
 
==Connect to the raspberry pi==
Line 26: Line 30:
 
  username local
 
  username local
  
ask for the password
+
ask for the password (or look on the course page)
  
 
===Usefull Linux commands===
 
===Usefull Linux commands===
Line 47: Line 51:
 
  top    (see process load and memory usage)
 
  top    (see process load and memory usage)
 
  make    (compile all as described in the "Makefile" in the same directory)
 
  make    (compile all as described in the "Makefile" in the same directory)
 +
make -j4 (compile using up to 4 CPU cores - faster if more files need to be compiled)
  
All commands has an on-line help if you add --help or -h after the command.
+
All commands have an on-line help if you add --help or -h after the command.
 
If this is not enough, then try  
 
If this is not enough, then try  
 
  man ls
 
  man ls
 
to get the manual page for the ls command.
 
to get the manual page for the ls command.
  
 
+
===Connecting network===
===Connecting Raspberry Pi to Eduroam===
+
  
 
Start by plugging the Raspberry Pi either directly to your PC or to one of the routers on campus. Make sure that you are on the same local network for this.
 
Start by plugging the Raspberry Pi either directly to your PC or to one of the routers on campus. Make sure that you are on the same local network for this.
Line 61: Line 65:
 
  ssh local@jasmin.local
 
  ssh local@jasmin.local
 
Replace '''jasmin''' with the name of the your robot
 
Replace '''jasmin''' with the name of the your robot
 +
 +
====WiFi network====
 +
 +
Now open wpa_supplicant.conf
 +
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 +
 +
If you added an wifi access point, it probably looks something like this
 +
 +
network={
 +
        ssid="device"
 +
        key_mgmt=NONE
 +
}
 +
 +
or
 +
 +
network={
 +
        ssid="tdc432"
 +
        psk="secret_password"
 +
        key_mgmt=WPA-PSK
 +
        id_str=home
 +
}
 +
 +
You can add any number of the "network" groups for all the networks you get across
 +
If you don't like the network password to be visible, see guide below.
 +
 +
====Private network====
 +
 +
Generate encrypted key with
 +
 +
wpa_passphrase mySSID secret776
 +
 +
if the desired SSID is "mySSID" and the password is "secret776", then copy the result into /etc/wpa_supplicant/wpa_supplicant.conf (except the line with the password in clear text).
 +
 +
network={
 +
        ssid="mySSID"
 +
        #psk="secret776"
 +
        psk=812439e952156aea9983f3df5a389cf3f9c2e9f30ae2624eaad1551612a6ef71
 +
}
 +
 +
====Connecting Raspberry Pi to Eduroam====
  
 
When connecting to Eduroam you will eventually have to type in your username and password in the wpa_supplicant.conf-file. In order for your password not to be visible, generate a hash-code for it
 
When connecting to Eduroam you will eventually have to type in your username and password in the wpa_supplicant.conf-file. In order for your password not to be visible, generate a hash-code for it
 +
 
  echo -n password_here | iconv -t utf16le | openssl md4
 
  echo -n password_here | iconv -t utf16le | openssl md4
 +
 
Copy the hash-code and clear the terminal window
 
Copy the hash-code and clear the terminal window
 +
 
  clear
 
  clear
 +
 
Now open wpa_supplicant.conf
 
Now open wpa_supplicant.conf
 
  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 
  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Replace whatever in this file so that the content corresponds to the following
+
Comment out or replace whatever in this file so that the content corresponds to the following
 
  country=DK
 
  country=DK
 
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
Line 86: Line 134:
 
Reboot the Raspberry Pi
 
Reboot the Raspberry Pi
 
  sudo reboot
 
  sudo reboot
 +
or
 +
sudo /etc/init.d/networking restart
 
When the Pi has rebooted, connect to it using SSH once again. Check that the Pi is connected to WiFi
 
When the Pi has rebooted, connect to it using SSH once again. Check that the Pi is connected to WiFi
 
  ifconfig
 
  ifconfig
 
Under '''wlan0''' confirm that the Pi has received an IP (inet addr) and note down the first three sections of the IP - they are most likely '''10.16.175.xxx'''
 
Under '''wlan0''' confirm that the Pi has received an IP (inet addr) and note down the first three sections of the IP - they are most likely '''10.16.175.xxx'''
  
The MAC address (HWaddr) of the Pi should also be noted down - this probably starts with '''B8:27:EB:xx:xx:xx''' make sure to get all of it.
+
To see which SSID you are connected to use
 +
iwconfig
 +
 
 +
The MAC address ('HWaddr' or 'ether') of the Pi should also be noted down - this probably starts with '''B8:27:EB:xx:xx:xx''' make sure to get all of it.
  
 
Remove the LAN-cabel and connect to the Pi using the IP
 
Remove the LAN-cabel and connect to the Pi using the IP
 
  ssh local@IP
 
  ssh local@IP
Replace '''IP''' with the actual ID of the robot.  
+
Replace '''IP''' with the actual ID of the robot.
  
 
===Graphics (X) ===
 
===Graphics (X) ===
Line 101: Line 154:
 
  ssh -X local@IP
 
  ssh -X local@IP
  
===Find IP of robot===
+
===Find IP of robot (Linux)===
  
 
In case the Pi gets a new IP address after reboot, you can search for it using the MAC address and '''nmap'''. If '''nmap''' is not installed, start by installing it
 
In case the Pi gets a new IP address after reboot, you can search for it using the MAC address and '''nmap'''. If '''nmap''' is not installed, start by installing it
 
  sudo apt-get install nmap
 
  sudo apt-get install nmap
 
To search for the Pi using the MAC address in terminal type
 
To search for the Pi using the MAC address in terminal type
  sudo nmap -sP 10.16.175.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB:23:A0:F5/{print ip}'
+
  nmap -sP 10.16.175.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB:23:A0:F5/{print ip}'
 
where '''10.16.175''' is the first three sections of the IP you noted down and '''B8:27:EB:23:A0:F5''' is the MAC address of the Pi. This should return the IP of the Pi.
 
where '''10.16.175''' is the first three sections of the IP you noted down and '''B8:27:EB:23:A0:F5''' is the MAC address of the Pi. This should return the IP of the Pi.
  
==Hardware Setup==
+
NB! the MAC can hold letters, they should probably be capital.
All low level hardware is controlled by the Teensy microprocessor. For the most part, you don't need to make changes here, but some tuning and setup will be necessary.
+
The easiest way to tune parameters and debug mission-lines is through the QtGUI interface:
+
svn co svn://repos.gbar.dtu.dk/jcan/regbot/qtgui qtgui
+
The installation might require additional software as listed [http://rsewiki.elektro.dtu.dk/index.php/Software_installation here] under python packages. A manual to QtGUI and possible mission-lines is available [http://rsewiki.elektro.dtu.dk/index.php/User_interface here].
+
  
===Regulators===
+
Use the first part, to get a list of active IP on the net:
The Teensy operates with several regulation loops. These can be tuned for optimal performance. The regulators are adjusted under the "Control" tab in QtGUI.
+
  nmap -sP 10.16.175.0/24
Following is listed working parameters for robobot primary functionality:
+
  
====Velocity====
+
===DNSMASQ===
The velocity regulator ensures that the robot keeps the intended speed under different loads. A good set of starting parameters would be as following:
+
Controller: Kp = 15 | Integrator: Tau_i = 0.15, Limit = 4 | Output limit = 9
+
  
====Heading====
+
THIS PART IS NOT needed anymore
The heading controller should ensure that the robobot keeps the correct heading, this regulator can be setup with:
+
Controller: Kp = 0.9 | Lead/lag forward: Tau_zero = 1, Tau_pole = 1 | Pre filter:  Tau_zero = 0, Tau_pole = 0.01
+
  
====Follow edge====
+
To enable the ROBOBOT to be connected directly to a PC, then it is easier if the ROBOBOT provides an IP for the PC.
This controller helps the robobot navigate after lines marked on the floor. A good starting point is:
+
P-Controller: Kp = 0.075
+
For the edge controller to work properly, a calibration under the "Edge" tab might be necessary, especially to detect white crossing and black crossing.
+
In this case, make sure to calibrate values to the actual tape on the floor.
+
  
===Calibrating front wheel===
+
Install DNSMASQ
The heading should also be adjusted by calibrating the nose wheel controlled by a servo. This is done under the "Servo" tab where servo 0 - the steering servo - should be offset so that the wheel actually points straight.
+
  
==Software structure==
+
sudo apt install dnsmasq
  
For this section please open the robobot C++ demo and follow along.
+
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)
  
===General structure===
+
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
  
The function '''missionInit()''' will initiate three threads on the robobot.
+
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
  
* Idle
+
Edit of /etc/dhcpcd.conf to have a fall back behaviour for eth0 and eth1.
* Thread 100
+
* Thread 101
+
  
The general idea is that the idle thread is used to turn on/off hardware/logging/etc and thread 100/101 will execute missions. When thread 100 is active a new mission can be loaded into thread 101 and vice-versa. In this way it is possible to toggle between the two threads and constantly updating the missions to run.
+
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
 +
  
===Executing missions===
+
This will also give a default IP for an eventual second network (usb-to-cable) if needed
  
Go to [http://rsewiki.elektro.dtu.dk/index.php/User_interface#Mission this section] to read up on how mission are constructed and how to utilise the sensors in missions.
+
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
  
When a mission is written, e.g.
+
ssh local@192.168.17.1
  
const char * m1[2] = {   
+
==Raspicam ==
    "vel=0.3,tr=0.01: turn=180",
+
    "vel=0, event=1" };
+
  
It is send to the '''missionSendAndRun''' function. This function will load the mission into the inactive thread and  toggle the threads on the Teensy microprocessor which will cause the new mission to be executed.
+
To be used from C++ direct or through openCV.
  
  missionSendAndRun(m1, 2);
+
A rather short raspberry pi camera API is available from https://www.uco.es/investiga/grupos/ava/node/40.
  
===Events===
+
And can be downloaded from https://sourceforge.net/projects/raspicam/files/,
  
Whenever an event is sent from the Teensy, an '''eventFlag''' will be set and the event number is loaded into '''eventNumber'''. This can be utilised to monitor the robot and write larger missions in a state-machine manner as explained in the [http://rsewiki.elektro.dtu.dk/index.php/Instructions_for_getting_started#Examples examples] section.
+
or get the file from sourceforge with no GUI, with (there may be newer versions):
  
==Examples==
+
cd ~/Downloads
===Example 1===
+
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
This mission exemplifies how events, sent from the Teensy, is handled by the code running on the Raspberry Pi.
+
 
The mission should cause the robot to drive one meter, turn 180 degrees and drive back again.  
+
Once fetched and available on the raspberry, then
  void UMission::runMission1()
+
Unpack and install:
  {
+
unzip raspicam-0.1.9.zip
  missionRunning = true;
+
  cd raspicam-0.1.9
  // First commands to send to robobot in given mission
+
  mkdir build
  // (robot sends event 1 after driving 1 meter)):
+
cd build
  const char * m1[2] = {   
+
cmake ..
    "vel=0.5, acc=2 : dist = 1",
+
make -j3
    "vel=0, event=1" };
+
sudo make install
  missionSendAndRun(m1, 2);
+
sudo ldconfig
  // Primary loop for robobot mission:
+
 
  while(missionRunning)
+
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
  { // Handle events received from Teensy:
+
 
    if (bot->eventFlag) {
+
cd
      bot->eventFlag = false;
+
nano ~/.bashrc
      switch (bot->eventNumber)
+
add at the end:
      { // Event 0 indicates that Teensy have been stopped, therefore stopping the mission too.
+
export CMAKE_PREFIX_PATH=/usr/local/lib
        case 0: {
+
source ~/.bashrc  # to implement export
          missionRunning = false;
+
 
          printf("--- Mission complete - stopping program!\n");
+
Test with openCV
          break;
+
raspicam_cv_test
        }
+
That takes 100 images and saves 3.
        // Event 1 is in this case received when robobot has driven 1 meter.
+
 
        case 1: {
+
=== Camera streamer ===
          const char * m2[3] = {
+
 
            "vel=0.3,tr=0.01: turn=180",
+
 
            "vel=0.5, acc=2 : dist=1",
+
To download the project you will need a source control system called git. It may not be installed on a fresh image. I know it’s not on the lite image. So you may need to install it.
            "vel=0,event=0:dist=1" };
+
sudo apt-get install git
          missionSendAndRun(m2,3);
+
 
          break;
+
Now that you have git installed, use it to clone a copy of the mjpg-streamer to your Pi.
        }
+
 
      }
+
git clone https://github.com/jacksonliam/mjpg-streamer.git
    }
+
 
  }
+
After the cloned copy of the mjpeg-stream has been coppied to the raspberry-pi, follow these steps.
  }
+
 
 +
cd mjpg-streamer/mjpg-streamer-experimental/
 +
make -j4    # optional CMAKE_BUILD_TYPE=Debug
 +
sudo make install
 +
 
 +
Make a script to start the streamer
 +
 
 +
cd
 +
nano start-stream.sh
 +
 
 +
copy this into the file (uncomment only one line - the others are examples for other resolutions - edit as desired)
 +
 
 +
#!/bin/bash
 +
#mjpg_streamer -i "input_raspicam.so -y 1600 -x 1200 -fps 5 -rot 90" -o output_http.so
 +
mjpg_streamer -i "input_raspicam.so -y 972 -x 1296 -fps 3 -rot=0" -o output_http.so
 +
#mjpg_streamer -i "input_raspicam.so -y 600 -x 800 -fps 3 -rot=0" -o output_http.so
 +
#mjpg_streamer -i "input_raspicam.so -y 640 -x 480 -fps 5" -o output_http.so
 +
 
 +
Change the file to be executable
 +
 
 +
chmod +x start-stream.sh
 +
 
 +
=== Start streaming at boot ===
 +
 
 +
Start of applications can be controlled by the /etc/rc.local script:
 +
 
 +
nano /etc/rc.local
 +
 
 +
add the following lines before 'exit 0' (close to the end)
 +
 
 +
# start camera streaming
 +
su - local /home/local/start-stream.sh &
 +
 
 +
Copy and 'shift-ctrl-v' will do
 +
 
 +
Comment the last line (su - local /home/local/start-stream.sh &) if camera streaming should not start.
 +
 
 +
to stop streaming use (if started)
 +
 
 +
  pkill mjpg_streamer
  
===Example 2===
 
This mission shows how a sensor event can terminate the program through the code running on the Raspberry Pi.
 
The robot will begin by turning 180 degrees and drive forward until an obstacle is detected by the front facing IR sensor.
 
void UMission::runMission2()
 
{
 
  missionRunning = true;
 
  // ''First commands to send to robobot in given mission
 
  // (robot sends event 1 after turning 180 degrees): ''
 
  const char * m1[2] = {   
 
    "'''vel=0.3,tr=0.01: turn=180'''",
 
    "'''vel=0, event=1'''" };
 
  '''missionSendAndRun(m1, 2);'''
 
  // ''Primary loop for robobot mission:''
 
  while(missionRunning)
 
  { // ''Handle events received from Teensy:''
 
    if (bot->eventFlag)
 
    { // ''reset event flag - the event number is still available''
 
      bot->eventFlag = false;
 
      // ''react based on eventnumber''
 
      switch (bot->eventNumber)
 
      { // ''Event 0 indicates that Teensy have been stopped, therefore stopping the mission too.''
 
        case 0: {
 
          missionRunning = false;
 
          printf("--- Mission complete - stopping program!\n");
 
          break;
 
        } 
 
        ''// Event 1 is in this case received when robobot has turned 180 degrees.
 
        // Will hereafter drive until a wall or obstacle is detected by IR sensor.''
 
        case 1: {
 
          float vel=0.4; ''// new velocity''
 
          float dist = 0.2; ''// distance detection''
 
          char * mlines[2]; ''// an array of pionters to the used mission lines''
 
          char mline0[100]; ''// first line''
 
          // ''construct first line ''
 
          snprintf(mline0[0], 100, "'''vel=%f,acc=2 : ir1<%f'''", vel, dist);
 
          // ''set pointers to the two lines''
 
          mlines[0] = mline0; ''// constructed line''
 
          mlines[1] = "'''vel=0.0, event=0 : time=0.1'''" //'' fixed line (stop)''
 
          '''missionSendAndRun(mlines,2)'''; //'' send the two lines to the robot controller''
 
          break;
 
        }
 
      }
 
    }
 
  }
 
}
 
  
To execute these selected missions, connect to the Raspberry Pi through ssh. Make a function call to the wanted mission in the robobot main file.
+
=== Watch camera stream ===
Thereafter navigate to:
+
  cd robobot/build
+
Compile the newest version of the program:
+
make
+
And finally run the code with:
+
./robobot
+
  
==GIF of Robobot driving on tape-lines==
+
When the robot is on a net connection - cable or wifi - you can watch the stream from a browser
  
[[File:robobot_line.gif]]
+
for streaming:  
 +
HTTP://jasmin.local:8080/?action=stream
 +
or for a snapshot
 +
HTTP://jasmin.local:8080/?action=snapshot
 +
where jasmin should be replaced with the robot name, or jasmin.local can be replaced with the IP address.

Latest revision as of 13:47, 25 December 2021

Back to Robobot


Contents

[edit] This part needs to be redone

Major parts are deprecated, but some are OK.

[edit] Connect to the raspberry pi

There are more possibilities to connect to the raspberry pi:

  • a screen and a keyboard (nice, but not good for a mobile robot)
  • a net cable from Robobot directly to your PC (better, but still a cable)
  • connect both the Robobot and your PC to the same local network using cable
  • connect Robobot to net using a cable and the PC to the net that has access to the same net
  • connect raspberry to eduroam (one of the others needed first to configure logon)
  • there are other ways too

[edit] Connecting Raspberry pi to PC using cable

Connect your PC with Robobot using a network cable.

Your PC should receive an IP from the raspberry pi and the raspberry pi on the Robobot should have IP: 192.168.17.2, so logon (from Linux, or using putty):

Linux console command:

ssh local@192.168.17.2

Putty (Windows, Apple or Linux):

use ssh, IP 192.168.17.2, port 22
username local

ask for the password (or look on the course page)

[edit] Usefull Linux commands

Here is some common commands in Linux

ls     (directory file list)
cd     (change to home directory)
cd some_directory    (change to a subdirectory)
exit   (logout, e.g. of a ssh session)
grep -n string_to_look_for_in_a_file  *.cpp     (find a string in a file, e.g. a variable or a function)
sudo some_command    (execute a command as "root" - root is a superuser with administrator rights to everything)
pkill some_application_name  (stop (or kill) a running process with name "some_application_name")
pgrep some_application_name  (see if a process is running - good to use before a kill)
mv  from_file to_file    (rename a file)
cp  from_file to_file    (copy a file)
rm  some_file            (remove (delete) a file)
nano some_file           (simple text editor)
zip, unzip               (pack or unpack files -  try zip --help   to see how.
top     (see process load and memory usage)
make    (compile all as described in the "Makefile" in the same directory)
make -j4 (compile using up to 4 CPU cores - faster if more files need to be compiled)

All commands have an on-line help if you add --help or -h after the command. If this is not enough, then try

man ls

to get the manual page for the ls command.

[edit] Connecting network

Start by plugging the Raspberry Pi either directly to your PC or to one of the routers on campus. Make sure that you are on the same local network for this.

SSH into the Raspberry Pi by opening a terminal and typing

ssh local@jasmin.local

Replace jasmin with the name of the your robot

[edit] WiFi network

Now open wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

If you added an wifi access point, it probably looks something like this

network={
       ssid="device"
       key_mgmt=NONE
}

or

network={
       ssid="tdc432"
       psk="secret_password"
       key_mgmt=WPA-PSK
       id_str=home

}

You can add any number of the "network" groups for all the networks you get across If you don't like the network password to be visible, see guide below.

[edit] Private network

Generate encrypted key with

wpa_passphrase mySSID secret776

if the desired SSID is "mySSID" and the password is "secret776", then copy the result into /etc/wpa_supplicant/wpa_supplicant.conf (except the line with the password in clear text).

network={
       ssid="mySSID"
       #psk="secret776"
       psk=812439e952156aea9983f3df5a389cf3f9c2e9f30ae2624eaad1551612a6ef71
}

[edit] Connecting Raspberry Pi to Eduroam

When connecting to Eduroam you will eventually have to type in your username and password in the wpa_supplicant.conf-file. In order for your password not to be visible, generate a hash-code for it

echo -n password_here | iconv -t utf16le | openssl md4

Copy the hash-code and clear the terminal window

clear

Now open wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Comment out or replace whatever in this file so that the content corresponds to the following

country=DK
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ctrl_interface_group=0
update_config=1
network={
        ssid="eduroam"
        scan_ssid=1
        key_mgmt=WPA-EAP
        eap=PEAP
        phase2="auth=MSCHAPV2"
        identity="username"
        password=hash:your_hash_code
}

Replace username with your username for Eduroam, i.e. your student number and replace your_hash_code with the hash-code you generated in the previous step.

Reboot the Raspberry Pi

sudo reboot
or
sudo /etc/init.d/networking restart

When the Pi has rebooted, connect to it using SSH once again. Check that the Pi is connected to WiFi

ifconfig

Under wlan0 confirm that the Pi has received an IP (inet addr) and note down the first three sections of the IP - they are most likely 10.16.175.xxx

To see which SSID you are connected to use

iwconfig

The MAC address ('HWaddr' or 'ether') of the Pi should also be noted down - this probably starts with B8:27:EB:xx:xx:xx make sure to get all of it.

Remove the LAN-cabel and connect to the Pi using the IP

ssh local@IP

Replace IP with the actual ID of the robot.

[edit] Graphics (X)

If you want to forward the graphics from the Pi use -X when connecting

ssh -X local@IP

[edit] Find IP of robot (Linux)

In case the Pi gets a new IP address after reboot, you can search for it using the MAC address and nmap. If nmap is not installed, start by installing it

sudo apt-get install nmap

To search for the Pi using the MAC address in terminal type

nmap -sP 10.16.175.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB:23:A0:F5/{print ip}'

where 10.16.175 is the first three sections of the IP you noted down and B8:27:EB:23:A0:F5 is the MAC address of the Pi. This should return the IP of the Pi.

NB! the MAC can hold letters, they should probably be capital.

Use the first part, to get a list of active IP on the net:

 nmap -sP 10.16.175.0/24

[edit] DNSMASQ

THIS PART IS NOT needed anymore

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

[edit] Raspicam

To be used from C++ direct or through openCV.

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 (there may be newer versions):

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 -j3
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

cd
nano ~/.bashrc
add at the end:
export CMAKE_PREFIX_PATH=/usr/local/lib
source ~/.bashrc   # to implement export

Test with openCV

raspicam_cv_test

That takes 100 images and saves 3.

[edit] Camera streamer

To download the project you will need a source control system called git. It may not be installed on a fresh image. I know it’s not on the lite image. So you may need to install it.

sudo apt-get install git

Now that you have git installed, use it to clone a copy of the mjpg-streamer to your Pi.

git clone https://github.com/jacksonliam/mjpg-streamer.git

After the cloned copy of the mjpeg-stream has been coppied to the raspberry-pi, follow these steps.

cd mjpg-streamer/mjpg-streamer-experimental/
make -j4     # optional CMAKE_BUILD_TYPE=Debug
sudo make install

Make a script to start the streamer

cd
nano start-stream.sh

copy this into the file (uncomment only one line - the others are examples for other resolutions - edit as desired)

#!/bin/bash
#mjpg_streamer -i "input_raspicam.so -y 1600 -x 1200 -fps 5 -rot 90" -o output_http.so
mjpg_streamer -i "input_raspicam.so -y 972 -x 1296 -fps 3 -rot=0" -o output_http.so
#mjpg_streamer -i "input_raspicam.so -y 600 -x 800 -fps 3 -rot=0" -o output_http.so
#mjpg_streamer -i "input_raspicam.so -y 640 -x 480 -fps 5" -o output_http.so

Change the file to be executable

chmod +x start-stream.sh

[edit] Start streaming at boot

Start of applications can be controlled by the /etc/rc.local script:

nano /etc/rc.local

add the following lines before 'exit 0' (close to the end)

# start camera streaming
su - local /home/local/start-stream.sh &

Copy and 'shift-ctrl-v' will do

Comment the last line (su - local /home/local/start-stream.sh &) if camera streaming should not start.

to stop streaming use (if started)

pkill mjpg_streamer


[edit] Watch camera stream

When the robot is on a net connection - cable or wifi - you can watch the stream from a browser

for streaming:

HTTP://jasmin.local:8080/?action=stream

or for a snapshot

HTTP://jasmin.local:8080/?action=snapshot

where jasmin should be replaced with the robot name, or jasmin.local can be replaced with the IP address.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox