Build your own robot car with the Raspberry Pi!

Build your own robot car with the Raspberry Pi!

Chapter 9 – developing a web-interface for the RaPi car:

This chapter is about the developing of a web-interface to control the robot with a smartphone over the internet. The interface has as background the live video stream from the Raspberry Pi car camera to see where the car is moving to. I implemented the buttons left/right, forward/backward and stop as an overlay over the live video stream. The stop button in the middle of the control field stops the motors.

I searched for the best frameworks in the internet which uses Python and supports a HTML site to control the car. I decided to use WebIOPI 0.7. This frameworks works best for my idea and I was able to implement the web-interface very fast and easy.

I used the following components for the web-interface:

WebIOPi 0.7: Homepage

Video Stream mjpg-streamer: Video Stream HowTo

This is a picture of my Samsung Galaxy S5 with the active web-interface and the RaPi car in the background.

Raspberry PI - remote controlled robot with a Raspberry Pi web interface

Raspberry PI – remote controlled robot with a Raspberry Pi web interface

WebIOPi 0.7 – installation:

It is very easy to install WebIOPi on the Raspberry Pi. You have to download the WebIOPi file from the WebIOPi homepage and extract the file. After this you have to install WebIOPi and that is it. To do so you need a few commands I listed here:

The command to extract the WebIOPi tar file:

tar zxvf WebIOPi-0.7.0.tar.gz

Now you have to change the directory to the folder where the WebIOPi files are extracted to.

With the next command you will install WebIOPi on your Raspberry Pi:

sudo python setup.py install

Now WebIOPi is available and can be used.

If this was to short the homepage from WebIOPi has lots of HowTo papers and explanations.

Build your own robot car with the Raspberry Pi!

Build your own robot car with the Raspberry Pi!

Step by step to your own robot car
This book guides you in two parts through the project phases with the aim of building an individual, autonomously driving robot car. In the first part of the book you will learn the basics of robotics and the interaction of hardware, electricity and software. You build the chassis and wire the individual components - details can be found in the appropriate, richly illustrated chapters. An introduction to software installation and programming with Scratch and Python completes the first part. You do not need any previous knowledge in robotics and programming. In the second part of the book, you will familiarize yourself with the sensors required for autonomous driving. With the acquired knowledge you can individualize and further develop your robot car as you wish. The knowledge you acquire in this book will enable you to implement your own projects with the Raspberry Pi.

This book offers you that:
  • Simply get into robotics with the Rasperberry Pi without prior knowledge
  • Numerous illustrations, tables, circuit diagrams
  • Information boxes with useful tips also for other Raspberry Pi projects
  • Project code with syntax highlighting
  • Two car projects: remote-controlled robot car via WLAN and self-driving car
  • Hardware tips and recommendations for suitable accessories - Extensive project material as download: Raspbian image, parts list, chassis artwork and code
  • Special features: Easy and robust cabling, use of high-precision time-of-flight laser distance measurement sensors, introduction to servo motors and suitable servo controllers, control via gamepad, use of an OLED display
Your Rasbperry Pi driving instructor
Ingmar Stapel studied computer engineering and is currently working internationally as IT project manager and enterprise technical architect; in addition, he has been intensively involved with Raspberry Pi and robotics for years. He likes to share this knowledge with interested people from the tinkering scene at meet-ups on robotics. On his private blogs he also writes about many current technology trends.

Python Script – RaPi car control:

This is my Python script I use for the web-interface version of my robot control script. It is the first version, not very nice but it works:

Rapi_Car_WebIO.py: rapi_car_webio

HTML site:

This is the little HTML site I developed as interface. This is the version shown in the picture above.

HTML site: rapi_car

Update 12.09.2014 – New web-interface

I updated the version with nice arrows pictures for the direction buttons. The picture is a screenshot from my Galaxy S5:

Raspberry PI - remote controlled car with a Raspberry Pi web interface Galaxy S5

Raspberry PI – remote controlled car with a Raspberry Pi web interface Galaxy S5

The Python script with the latest user inteface is available here for download: Python_Script_Web_Buttons

The Python script is located in the folder /rapi_car/python/ on my Raspberry Pi car.

The HTML files for the new user interface are available here for download: html_files_Web_Buttons

The HTML files are saved in the following folder: /usr/share/webiopi/htdocs/

Video of my robot car:

I did a new video from my RaPi car with the latest version of the web-interface. In this video I tried for the second time to control the car with the Smartphone. Not everything works perfect but it works and this is very cool. I should increase the value for the acceleration as you see in the video I have to press the button very often.

Conclusion:

With the web-interface it makes much for fun to control the car as with the keyboard script version. Now I have the possibility to control the car over the internet over many miles. This opportunity opens room for new ideas what you can do with such car in combination with an easy to use web-interface. The range restriction known from radio controlled model cars no longer exist.

Contents:


Chapter 1: Raspberry Pi WIFI radio controlled rc vehicle – introduction
Chapter 2: Raspberry Pi WIFI radio controlled rc vehicle – component list
Chapter 3: Raspberry Pi WIFI radio controlled rc vehicle – chassis
Chapter 4: Raspberry Pi WIFI radio controlled rc vehicle – wiring
Chapter 5: Raspberry Pi WIFI radio controlled rc vehicle – software installation
Chapter 6: Raspberry Pi WIFI radio controlled rc vehicle – power supply
Chapter 7: Raspberry Pi WIFI radio controlled rc vehicle – programing
Chapter 8: Raspberry Pi WIFI radio controlled rc vehicle – live video streaming
Chapter 9: Raspberry Pi WIFI radio controlled rc vehicle – web-interface and smartphone
Chapter 10: Raspberry Pi WIFI radio controlled rc vehicle – cooling with passive heat sinks
Chapter 11: Raspberry Pi WIFI radio controlled rc vehicle – startup scripts
Chapter 12: Raspberry Pi WIFI radio controlled rc vehicle – cardboard car model
Chapter 13: Raspberry Pi WIFI radio controlled rc vehicle – power consumption
(Visited 2,651 times, 3 visits today)