Coding of the control system for a model tank with Raspberry Pi. The project is divide into 4 sections:
- Keyboard Controlled RPi tank with Remote Desktop Connection into the Raspberry Pi.
- Keyboard Controlled RPi tank with Network Sockets.
- RPi Tank video streaming via Network Sockets and http.
- Line following RPi tank using OpenCV.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you'll need in terms of Software and Hardware and how to install them:
- 1. Raspberry Pi (Model 3 onwards recommended)
- 2. MotoZero PCB
- 3. Power Supply (5V Power Bank)
- 4. Pi Camera Module V2
The list of libraries that are required are stated below:
1. GPIOZERO Library - A simple interface to GPIO devices with Raspberry Pi.
pip install gpiozero
2. Pynput Library - Keyboard event handling Library for Tank's controls.
pip install pynput
3. Pi Camera - This package provides a pure Python interface to the Raspberry Pi camera module for Python 2.7 (or above) or Python 3.2 (or above).
pip install picamera
4. OpenCV - Unofficial pre-built OpenCV packages for Python.
pip install opencv-python
And repeat
until finished
End with an example of getting some data out of the system or using it for a little demo
The final setup of the RPi tank looks something like β¬
Sample Tracks for RPi Tank β¬
Follow the script execution cycle below:
1. Sprint 1 - Raspberry Pi and Tank/
- β β
cursesRobot.py
: Remote Desktop Connect to the Pi and run the script on the Pi terminal as
β β β β β β β β curses module only runs on terminal window. This establishes
β β β β β β β βkeyboard RPi Tank controls.
2. Sprint 2 - RPi controlled tank via Sockets/
- β β
pynputRobotClient.py
: Socket client program that runs on the RPi. - β β
pynputRobotClient.py
: Socket server program that runs on the Local Machine ready for keyboard inputs.
3. Sprint 3 - PiCamera and OpenCV/
- β β
robotCameraClient.py
: Socket client program that runs on the RPi for live video streaming. - β β
robotCameraServer.py
: Socket server program that runs on the Local Machine Playing streamed video. - β β httpCamera/
β β β βhttpCamer.py
: Run the script to create the http server on the Pi. Now on the Local Machine
ββ ββ β β β β β βsearch for Pi's IP and the video stream will be available on the webpage.
4. Sprint 4 - Line following RPi Tank/
- β β
lineRobotClient.py
: Socket client program for line Following RPi tank. - β β
lineRobotServer.py
: Socket server program for line Following RPi tank.
- Raspbian - OS for Raspberry Pi
- Python - Primary Programming Language.
- PyCharm - The IDE used for Develpment and the Recommended.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone whose code was used
- Inspiration
- etc