Authorized Online Retailers

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES

Objective

In this lesson, we will learn how to let the robot car has vision to see front environment and how to control the robot car through web browser or mobile APP.

To complete this task, we need install a web server software called “mjpg-streamer” in Raspberry Pi, this software will catch video from Robot Car camera and send the video to a web page.

We also need to install another web server software called “WebIOPi” in Raspberry Pi. This software will allow user to use browser to remotely control Raspberry Pi GPIO input/output and therefore control the movement of our robot motor.

Hardware Installation

If you don’t install camera in lesson1, please install and connect camera as following pictures. If you have already installed and connected these, please skip this step.


Software Installation

Complex Installation Guide

If you are advanced user, you might want to install webiopi and mjpg-streamer by yourself in order to customize some feature such as port number etc. If this is the case, you can take following steps 1 to 8 to install and config webiopi and mjpeg-streamer separately. If you are a beginner, please avoid use this advanced guide. Just take simple guide which will make installation much easier for you.

Note:
1. If your micro SD card has pre-installed Osoyoo Robot Image,please skip Step 1 to Step 8 and direct Run Step 9: Testing
2. Please keep the Raspberry Pi on battery power when using SSH to send command to Raspberry Pi terminal remotely.

Step 1: Download WebIOPi installation package by running following terminal commands(skip this step if your micro SD card has pre-installed Osoyoo Robot Image)

cd ~
mkdir   /home/pi/osoyoo-robot
mkdir   /home/pi/osoyoo-robot/cam-robot 
cd /home/pi/osoyoo-robot/cam-robot
wget http://osoyoo.com/driver/WebIOPi-0.7.1.tar.gz
tar xvzf WebIOPi-0.7.1.tar.gz
cd WebIOPi-0.7.1
wget http://osoyoo.com/driver/webiopi-pi2bplus.patch
patch -p1 -i webiopi-pi2bplus.patch
sudo ./setup.sh
cd /etc/systemd/system/
sudo wget http://github.com/doublebind/raspi/master/webiopi.service

*command to Start WebIOPi : sudo systemctl start webiopi
*command Stop WebIOPi: sudo systemctl stop webiopi
*command Restart WebIOPi: sudo systemctl restart webiopi

If WebIOPi is installed successfully, you will see following message in terminal, otherwise you might need redo the download and installation.

Step 2: Run webiopi by typing following command:

sudo systemctl start webiopi

Step 3: Use a browser in another computer (your computer/PAD/Phone in same LAN of your Pi) to visit your Pi’s IP address with port “8000” ( i.e http://192.168.0.115:8000, please replace 192.168.0.115 with your Pi’s local IP address), your browser will show WebIOPi login page. You need use default WebIOPi user name “webiopi” and default password “raspberry” to login to the server. Once you are logged into WebIOPi page, you will see WebIOPI Main Menu as following. If you can not see this page , you need to reinstall the WebIOPI software.

Please press “Ctrl” + “C” then “Ctrl” + “Z” in your terminal to end WebIOPi running.

Note: If you don’t know your raspberry pi IP address, type following command in your terminal,
ifconfig wlan0

Your raspberry Pi IP address is in the right side of the word inet addr:

Following Step 4 to 6 is for mjpg-streamer server Installation

Step 4: If you are using CSI camera , please take following action as per step A and B. (If you are using USB camera which comes with the car, please skip this step)(skip this step if your micro SD card has pre-installed Osoyoo Robot Image)

A. enable camera in Raspberry Pi
sudo raspi-config

B. edit “/etc/modules” file by typing following command(otherwise /dev has no camera device node)
sudo nano /etc/modules

Please add the following line in the bottom of the “/etc/modules” file, and then press “ctrl” + “x” and then “y” to save the file and press “enter” exist nano editor
bcm2835-v4l2

Step 5: download and install mjpg-streamer support library by typing following command(skip this step if your micro SD card has pre-installed Osoyoo Robot Image)

cd ~ 
sudo apt-get update
sudo apt-get install libv4l-dev libjpeg8-dev -y 
sudo apt-get install subversion -y 
cd /home/pi/osoyoo-robot/cam-robot 
wget  http://osoyoo.com/driver/mjpg-streamer.tar.gz
wget  http://osoyoo.com/driver/robot.tar.gz 
tar  -xzvf   mjpg-streamer.tar.gz 
tar  -xzvf  robot.tar.gz

Step 6: Compile mjpg-streamer(skip this step if your micro SD card has pre-installed Osoyoo Robot Image)

Firstly, edit the configuration file “input_uvc.c” by typing following command
cd ~/osoyoo-robot/cam-robot/mjpg-streamer/plugins/input_uvc
sudo nano input_uvc.c

Find following line(you can use “ctrl” + “W” to search the line when you enter nano editor)

 int width=640, height=480, fps=5, format=V4L2_PIX_FMT_MJPEG

Replace the string V4L2_PIX_FMT_MJPEG with new string V4L2_PIX_FMT_YUYV

Then press “ctrl” + “x” and then “y” to save the file and press “enter” exist nano editor

Secondly, we need compile the source code with following commands:
cd ~/osoyoo-robot/cam-robot/mjpg-streamer
make all

Thirdly, test camera installation: Plug your camera into Raspberry Pi, then type following command:
ls /dev/video*

You should see following result in your terminal, “/dev/video0” is the camera installed in Pi