Difference between revisions of "Controlling Smart Video Car for RPi on Windows"
(→5. Get on the Road!) |
|||
(15 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi. <br> | Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi. <br> | ||
Click '''Download ZIP''' on the sidebar of the page, as shown below. <br> | Click '''Download ZIP''' on the sidebar of the page, as shown below. <br> | ||
+ | |||
[[File:Gitclone.png]]<br> | [[File:Gitclone.png]]<br> | ||
+ | |||
After download, go to the file and extract it. So now you have the source code folder. <br> | After download, go to the file and extract it. So now you have the source code folder. <br> | ||
==3. Basic Software Environment== | ==3. Basic Software Environment== | ||
Line 65: | Line 67: | ||
sudo make DESTDIR=/usr install | sudo make DESTDIR=/usr install | ||
'''2. Testing'''<br> | '''2. Testing'''<br> | ||
− | Type in sudo sh start.sh and press Enter. <br> | + | Type in ''sudo sh start.sh'' and press Enter. <br> |
On your computer, open a web browser (Chrome or Firefox recommended).<br> | On your computer, open a web browser (Chrome or Firefox recommended).<br> | ||
Type in the following address (replace 192.168.0.126 with your Raspberry Pi IP address) at the address bar of your browser: <br> | Type in the following address (replace 192.168.0.126 with your Raspberry Pi IP address) at the address bar of your browser: <br> | ||
http://192.168.0.126:8080<br> | http://192.168.0.126:8080<br> | ||
− | Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner. <br> | + | Press '''Enter''' and you will see the view captured by the camera displayed on the screen in a real-time manner. <br> |
+ | |||
[[File:2.png]] | [[File:2.png]] | ||
+ | |||
==4. Calibration== | ==4. Calibration== | ||
===Preparation=== | ===Preparation=== | ||
− | Run the Server | + | '''1. Run the Server '''<br> |
− | Run the calibration server on the Raspberry Pi, and wait for client to connect. | + | Run the calibration server on the '''Raspberry Pi''', and wait for client to connect.<br> |
− | Make sure that the circuit is connected properly. Power the smart car, open a terminal in Linux. Connect with your Raspberry Pi via the ssh. Go to the directory Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server, run the server cali_server.py: if the servo gets stuck with an abnormal sound, unplug the wires at once, and redo servo adjustment for calibration in case of further damages. | + | Make sure that the circuit is connected properly. Power the smart car, open a terminal in Linux. Connect with your Raspberry Pi via the ssh. Go to the directory ''Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server'', run the server ''cali_server.py'': if the servo gets stuck with an abnormal sound, unplug the wires at once, and redo servo adjustment for calibration in case of further damages.<br> |
− | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server | + | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server |
− | sudo python cali_server.py | + | sudo python cali_server.py |
− | + | ||
− | Then the contents of config are printed and the last line: Waiting for connection… | + | [[File:Shuixingban-19.png]]<br> |
− | At this time, the car might move a bit (this is the original position set) | + | |
− | Run the Client | + | Then the contents of config are printed and the last line: '''Waiting for connection…'''<br> |
− | Run the calibration client on PC to connect the server on Raspberry Pi. | + | At this time, the car might move a bit (this is the original position set).<br> |
− | Unzip the code package you downloaded. | + | '''2. Run the Client'''<br> |
− | Click the Start button on your computer, and type in python in the search bar, and you can find the IDLE (Python GUI). Click it and then a window will pop up. | + | Run the calibration client on '''PC''' to connect the server on Raspberry Pi.<br> |
− | + | Unzip the code package you downloaded.<br> | |
− | + | Click the '''Start''' button on your computer, and type in python in the search bar, and you can find the IDLE (Python GUI). Click it and then a window will pop up.<br> | |
− | Click File -> Open -> Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master -> client -> cali_client.py to open this file, modify the value of HOST for the IP address of the Raspberry Pi. | + | <br> |
− | + | [[File:11-2.png]]<br> | |
− | After modification, save the file and click the Run menu, and select Run Module. | + | <br> |
− | Then a window Raspberry Pi Smart Video Car Calibration will pop up: | + | Click '''File''' -> '''Open''' -> '''Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master''' -> '''client''' -> '''cali_client.py''' to open this file, modify the value of '''HOST''' for the IP address of the Raspberry Pi.<br> |
− | + | ||
− | In the terminal remotely connected with the Raspberry Pi, the IP address of the PC will be printed. | + | [[File:Shuixingban-23.png]]<br> |
− | + | ||
− | Then you can start calibrating. Before that, take out your package box and place it vertically with the side face to the table. Put the car onside the box and keep it balanced. The purpose is to keep the wheels of the car off the table. | + | After modification, save the file and click the '''Run''' menu, and select Run '''Module'''. |
− | By default, the front wheels should be directly pointed towards the front; the camera on the tilt servo should be face up no matter what directions the pan servo is pointed at. If not, you may adjust the directions in Raspberry Pi Smart Video Car Calibration. | + | Then a window '''Raspberry Pi Smart Video Car Calibration''' will pop up: |
− | For the detailed calibration instructions, please follow the user manual in your package. | + | <br> |
− | + | [[File:Shuixingban-24.png]]<br> | |
+ | <br> | ||
+ | In the terminal remotely connected with the Raspberry Pi, the IP address of the PC will be printed. <br> | ||
+ | |||
+ | [[File:Shuixingban-25.png]]<br> | ||
+ | |||
+ | Then you can start calibrating. Before that, take out your package box and place it vertically with the side face to the table. Put the car onside the box and keep it balanced. The purpose is to keep the wheels of the car off the table.<br> | ||
+ | By default, the front wheels should be directly pointed towards the front; the camera on the tilt servo should be face up no matter what directions the pan servo is pointed at. If not, you may adjust the directions in '''Raspberry Pi Smart Video Car Calibration'''.<br> | ||
+ | For the detailed calibration instructions, please follow the user manual in your package. <br> | ||
+ | |||
==5. Get on the Road!== | ==5. Get on the Road!== | ||
− | Run the Server | + | '''1. Run the Server'''<br> |
− | Run the TCP server on the Raspberry Pi, and wait for the client to connect to control the car. | + | Run the TCP server on the '''Raspberry Pi''', and wait for the client to connect to control the car.<br> |
− | You need two terminals to run the server. One is to run tcp_client.py to receive commands to control the car, and the other to run mjpg-streamer to provide video streams. In Windows, you can use PuTTy to remotely log into the Raspberry Pi to start the server. | + | You need two terminals to run the server. One is to run tcp_client.py to receive commands to control the car, and the other to run mjpg-streamer to provide video streams. In Windows, you can use PuTTy to remotely log into the Raspberry Pi to start the server.<br> |
− | Open a terminal. | + | Open a terminal.<br> |
− | The Raspberry Pi may be still at the server directory: | + | The Raspberry Pi may be still at the server directory:<br> |
− | pi@raspberrypi ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server $ | + | pi@raspberrypi ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server $ |
− | If not, go to the directory with cd. | + | If not, go to the directory with cd.<br> |
− | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server | + | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server |
− | Then run tcp_server.py: | + | Then run tcp_server.py:<br> |
− | sudo python tcp_server.py | + | sudo python tcp_server.py |
− | The server program on the Raspberry Pi will be running and waiting for the client to connect to the Raspberry Pi. | + | The server program on the Raspberry Pi will be running and waiting for the client to connect to the Raspberry Pi.<br> |
− | + | ||
+ | [[File:Shuixingban-20.png]]<br> | ||
+ | |||
Open another terminal. Log in the Raspberry Pi remotely, and switch to the directory under which the program of MJPG-streamer lies: | Open another terminal. Log in the Raspberry Pi remotely, and switch to the directory under which the program of MJPG-streamer lies: | ||
− | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/mjpg-streamer/mjpg-streamer | + | cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/mjpg-streamer/mjpg-streamer |
− | + | ||
+ | [[File:9.png]]<br> | ||
+ | |||
Run the program: | Run the program: | ||
− | sudo sh start.sh | + | sudo sh start.sh |
− | Then the video data acquisition will start, like this: | + | Then the video data acquisition will start, like this:<br> |
− | + | ||
− | Type in the following address (replace 192.168.0.xxx with the IP address of your Raspberry Pi) at the address bar of your browser (Firefox is recommended): | + | [[File:10.png]]<br> |
− | http://192.168.0.xxx:8080/stream.html | + | |
− | Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner. | + | Type in the following address (replace 192.168.0.xxx with the IP address of your Raspberry Pi) at the address bar of your browser (Firefox is recommended):<br> |
− | Run the Client | + | http://192.168.0.xxx:8080/stream.html<br> |
− | Run the client on PC to connect the server on the Raspberry Pi. | + | Press '''Enter''' and you will see the view captured by the camera displayed on the screen in a real-time manner.<br> |
− | Open the IDLE | + | '''2. Run the Client'''<br> |
− | + | Run the client on '''PC''' to connect the server on the Raspberry Pi.<br> | |
− | + | Open the IDLE<br> | |
− | Click File -> Open -> Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master -> client -> client App.py to open this file, modify the value of the HOST for the IP address of the Raspberry Pi. | + | |
− | + | [[File:11-2.png]]<br> | |
− | After modification, save the file and select Run -> Run Module. | + | |
− | Then the following window will appear on your screen: | + | Click '''File''' -> '''Open''' -> '''Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master''' -> '''client''' -> '''client App.py''' to open this file, modify the value of the HOST for the IP address of the Raspberry Pi.<br> |
− | + | ||
− | + | [[File:Shuixingban-21.png]]<br> | |
− | + | ||
− | + | After modification, save the file and select '''Run''' -> '''Run Module'''.<br> | |
+ | Then the following window will appear on your screen:<br> | ||
+ | |||
+ | [[File:13.png]]<br> | ||
− | This article is mainly for Windows users. If you're using Linux, please check our user manual. | + | You can click '''buttons''' such as '''Forward''' and Backward to control the car moving remotely. Or click '''X+''', '''X-''', '''Y+''', and '''Y-''' to control the coverage of the camera.<br> |
− | For further questions, please publish posts on our FORUM. | + | <font color="color:red">Note:</font> <br> |
+ | The server program must be run before you run the client program. Some settings must be completed for the server before the service is done. A communication endpoint needs to be created for the server to "listen" to requests from the client. Take the server as a receptionist or an operator of the bus phone in a company. Once the phone and device installation is completed and the receptionist or operator is in place, the service begins.<br> | ||
+ | <font color="blue">This article is mainly for Windows users. If you're using Linux, please check our user manual.<br> | ||
+ | For further questions, please publish posts on our '''FORUM'''.</font><br> |
Latest revision as of 06:13, 8 August 2017
Note: This article is abstracted from our latest user manual. So if you have one with "Reprint 3.0" at the Preface, you can just follow the book.
Contents
1. Download and Install Raspbian on a TF Card
If you've already installed the Raspbian system, please skip this step.
Search out the installation guide for Raspbian on the Raspberry Pi website at https://www.raspberrypi.org/downloads/. Then download the Raspbian to your TF card and install it.
After the installation, you may need some basic settings for the Raspberry Pi. Check out the guide for the setting on our website https://www.sunfounder.com.
2. Get Source Code
Step 1. Download the source code directly from Github to your Raspberry Pi.
cd ~ git clone https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi.git
Step 2. Download the source code directly from Github to your PC:
https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi,
Or search for Sunfounder in Github and find the repository:
Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi.
Click Download ZIP on the sidebar of the page, as shown below.
After download, go to the file and extract it. So now you have the source code folder.
3. Basic Software Environment
Operation on PC
Go to the Python website https://www.python.org, find the latest Python 2 and install. After installation, DO restart the computer.
Operation on Raspberry Pi
Install python-dev, python-smbus
Install python-dev and python-smbus:
sudo apt-get update sudo apt-get upgrade sudo apt-get install python-dev sudo apt-get install python-smbus
Setup I2C port
Run the command to open Raspberry Pi Software Configuration Tool (raspi-config)
sudo raspi-config
Enable I2C:
Select Advanced Options => I2C => <Yes> => <Ok> => <Yes>
Select <Finish>. Close the window.
If a message of rebooting appears, click <No>. Before reboot, we still need to complete some configurations.
MJPG-streamer
1. Installation
Plug the USB camera into Raspberry Pi, and run the command lsusb. The GEMBIRD represents the USB camera; since it is printed on the screen, it indicates the system has recognized the camera.
lsusb
You'll see:
pi@raspberrypi:~ $ lsusb Bus 001 Device 004: ID 1908:2310 GEMBIRD Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Check whether the driver for the camera works normally:
ls /dev/vid*
You'll see:
pi@raspberrypi:~ $ ls /dev/vid* /dev/video0
If /dev/video0 is printed, the driver is in the normal state.
Then, install the following software needed:
sudo apt-get install subversion sudo apt-get install libv4l-dev sudo apt-get install libjpeg8-dev sudo apt-get install imagemagick
Compile the source code of MJPG-streamer:
cd /home/pi/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/mjpg-streamer/mjpg-streamer sudo make USE_LIBV4L2=true clean all
Install:
sudo make DESTDIR=/usr install
2. Testing
Type in sudo sh start.sh and press Enter.
On your computer, open a web browser (Chrome or Firefox recommended).
Type in the following address (replace 192.168.0.126 with your Raspberry Pi IP address) at the address bar of your browser:
http://192.168.0.126:8080
Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner.
4. Calibration
Preparation
1. Run the Server
Run the calibration server on the Raspberry Pi, and wait for client to connect.
Make sure that the circuit is connected properly. Power the smart car, open a terminal in Linux. Connect with your Raspberry Pi via the ssh. Go to the directory Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server, run the server cali_server.py: if the servo gets stuck with an abnormal sound, unplug the wires at once, and redo servo adjustment for calibration in case of further damages.
cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server sudo python cali_server.py
Then the contents of config are printed and the last line: Waiting for connection…
At this time, the car might move a bit (this is the original position set).
2. Run the Client
Run the calibration client on PC to connect the server on Raspberry Pi.
Unzip the code package you downloaded.
Click the Start button on your computer, and type in python in the search bar, and you can find the IDLE (Python GUI). Click it and then a window will pop up.
Click File -> Open -> Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master -> client -> cali_client.py to open this file, modify the value of HOST for the IP address of the Raspberry Pi.
After modification, save the file and click the Run menu, and select Run Module.
Then a window Raspberry Pi Smart Video Car Calibration will pop up:
In the terminal remotely connected with the Raspberry Pi, the IP address of the PC will be printed.
Then you can start calibrating. Before that, take out your package box and place it vertically with the side face to the table. Put the car onside the box and keep it balanced. The purpose is to keep the wheels of the car off the table.
By default, the front wheels should be directly pointed towards the front; the camera on the tilt servo should be face up no matter what directions the pan servo is pointed at. If not, you may adjust the directions in Raspberry Pi Smart Video Car Calibration.
For the detailed calibration instructions, please follow the user manual in your package.
5. Get on the Road!
1. Run the Server
Run the TCP server on the Raspberry Pi, and wait for the client to connect to control the car.
You need two terminals to run the server. One is to run tcp_client.py to receive commands to control the car, and the other to run mjpg-streamer to provide video streams. In Windows, you can use PuTTy to remotely log into the Raspberry Pi to start the server.
Open a terminal.
The Raspberry Pi may be still at the server directory:
pi@raspberrypi ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server $
If not, go to the directory with cd.
cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server
Then run tcp_server.py:
sudo python tcp_server.py
The server program on the Raspberry Pi will be running and waiting for the client to connect to the Raspberry Pi.
Open another terminal. Log in the Raspberry Pi remotely, and switch to the directory under which the program of MJPG-streamer lies:
cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/mjpg-streamer/mjpg-streamer
Run the program:
sudo sh start.sh
Then the video data acquisition will start, like this:
Type in the following address (replace 192.168.0.xxx with the IP address of your Raspberry Pi) at the address bar of your browser (Firefox is recommended):
http://192.168.0.xxx:8080/stream.html
Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner.
2. Run the Client
Run the client on PC to connect the server on the Raspberry Pi.
Open the IDLE
Click File -> Open -> Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi-master -> client -> client App.py to open this file, modify the value of the HOST for the IP address of the Raspberry Pi.
After modification, save the file and select Run -> Run Module.
Then the following window will appear on your screen:
You can click buttons such as Forward and Backward to control the car moving remotely. Or click X+, X-, Y+, and Y- to control the coverage of the camera.
Note:
The server program must be run before you run the client program. Some settings must be completed for the server before the service is done. A communication endpoint needs to be created for the server to "listen" to requests from the client. Take the server as a receptionist or an operator of the bus phone in a company. Once the phone and device installation is completed and the receptionist or operator is in place, the service begins.
This article is mainly for Windows users. If you're using Linux, please check our user manual.
For further questions, please publish posts on our FORUM.