Introduction: PiTanq - Robot-tank With Raspberry Pi and Python to Learn AI

About: robots fan

Pitanq is a robot-tank with a camera powered by Raspberry Pi. Its purpose is to help learn an artificial intelligence of self-driving. AI on the tank is backed up by OpenCV and Tensoflow built especially for Raspbian Jessie.

Based on sturdy aluminum chassis PiTanq is good for outdoor usage.

There is an open source python web-service exposing REST interface to control the robot.

An Android application also provided.

There are some more additional things: pan-and-tilt camera stand (also controlled by phone) and ultrasonic sensor.

Disclaimer. This is not a full guide, just an outline. The full guide is on GitHub.

Step 1: List of Materials

Raspberry Pi


Power Converter

Motor Controller

PWM Controller

2x18650 Batteries


Pan-and-tilt stand

Disclaimer. The mentioned list is not completed. There is a lot of small stuff, like wires, screws, acrylic plates. You can get more info or buy the whole package at PiTanq website

Step 2: Build Tank Chassis

Step 3: Attach Electricals to a Plate

Step 4: Attach Camera and Distance Meter to Board

Step 5: Attach Camera Board to Stand and Stand to Chassis

Step 6: Attach Battery Holder to Chassis

Step 7: Attach Electrical Plate to Chassis and Wire Everything

Step 8: Setup Software

  1. Install Raspbian Jessie
  2. Install OpenCV
  3. Install Tensorflow
  4. Install MJPG-Streamer
  5. Get control service code from GitHub

This code is written on python and provides REST interface to control the tank.

As examples of AI usage there are:

- cat finder with Haar cascades from OpenCV

- object detector with OpenCV-DNN

- image classifier with Tensorflow

The REST interface is:

  • GET /ping
  • GET /version
  • GET /name
  • GET /dist
  • POST /fwd/on
  • POST /fwd/off
  • POST /back/on
  • POST /back/off
  • POST /left/on
  • POST /left/off
  • POST /right/on
  • POST /right/off
  • POST /photo/make
  • GET /photo/:phid
  • GET /photo/list
  • POST /cam/up
  • POST /cam/down
  • POST /cam/right
  • POST /cam/left
  • POST /detect/haar/:phid
  • POST /detect/dnn/:phid
  • POST /classify/tf/:phid

Step 9: Setup Connection

There is a headless way to set up Wi-Fi connection for Raspberry Pi.

Insert the microSD card with Raspbian into a computer.

Create a text file wpa_supplicant.conf with content:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1 country=US

network={ ssid="your-wifi-network" psk="your-wifi-password" key_mgmt=WPA-PSK }

Also it would be recommended to create an empty file named "ssh". It will allow remote access to RPI (do not forget to change the default password).

Step 10: Get Android App

Install the Android app from Google Play

With the app it is possible to drive the tank, move the camera, watch live video, take photos, detect objects on the photos.