Pi Wars 4.0 Update – Raspberry Pi Robotics Challenge

Pi Wars 4.0 Update - Raspberry Pi Robotics Challenge

With less than ten weeks to go for The Pi Wars 4.0 competition day, there is still much to do. I imagine it’s going to be panic time for many of the competitors. I’m still a reserve competitor, but I have already seen indications of entrants dropping out, so there is still hope for me yet. The Raspberry Pi robot vehicle software is the most challenging task to complete in my entry effort, and I believe this will be the same for many other teams as well.

Current Pi Wars 4.0 Readiness

Apart from wireless control, there is still work to do for the autonomous challenges. It appears I need slower RPM DC motors for more responsive and precision control. Depending on the surface type and battery level, the 50:1 micro DC motors I have fitted can stall at lower motor speeds. The risk of motor stalling will be an issue, especially in autonomous control.

So, 200RPM DC motors are on the way to replace the 50:1; which are about 420 RPM no load. This lower RPM will, therefore, allow better fine tuning for autonomous control with OpenCV. However, for the Pi Wars Straight Line Speed challenge, I can always swap for the 50:1 micro gear motors.

Controller for Pi Wars

Raspberry Pi Controller
Raspberry Pi Compatible Controller

Pi Wars 4.0 require wireless robot control in challenges such as Pi Noon, The Obstacle Course, The Duck Shoot and Slightly Deranged Golf. So the wireless controller I’m currently using is a wireless game controller from The Pi Hut Store. While using the inputs package, I can write Python code to get input from the controller without any difficulty. I am also able to run the controller routines efficiently from a separate program thread, thus allowing me to avoid the code execution blocking method of the inputs Python library.

However, while using the game controller, I am finding that the analogue thumbsticks are over sensitive. This sensitivity is perhaps due to the short effective travel distance of the thumbsticks. That means up to half the full travel distance of the thumbsticks is a dead area, no data output. This sensitivity can be a problem in the heat of the competition.

With the time I have left before the competition starts, swapping wireless controllers at this stage might be too time expensive. Therefore, I have ordered a set of slower RPM DC motors that might provide better control for some challenges. Hopefully, the new DC gear Motors will reduce the slingshot effect when applying power quickly.

  • Multithreading Raspberry Pi Game Controller in PythonLink.


Most of my Pi Wars 4.0 development time is, by far, going into the software development. I’m new to Python, so I had to get up to speed quickly, regularly dipping into references. I’m making good use of classes to help make the Python code solutions more manageable.

  • Game Controller Class – Outputs controller activity that you can query as often as necessary without blocking.
  • Differential Motor Driver Class – Calculates PWM for DC motors from controller input. This python class also takes values for autonomous robot drive control.
  • Motor Driver Class – This Python class takes the output from the differential motor driver class to drive the GPIO Pins for external DC motor driver.
  • Object Tracking Class – This OpenCV class is part of a collection of Python classes that organises colour profiles for tracking in each image frame capture. Properties are set to define parameters to help capture an area of interest.

The above Python classes are still a work in progress, but they will be released to the public eventually.

OpenCV for Pi Wars

Pi Wars 2018 - Bluetin Mini Robot
Pi Wars 2018 – Bluetin Mini Robot

With some camera lens trickery, it is likely I’ll be using Camera Vision and OpenCV in all the Pi Wars 4.0 autonomous challenges. The Minimal Maze Challenge still has some testing to go through yet. The camera adaptor still needs work. However, I’m confident to be competitive in the Somewhere Over the Rainbow and Straight-Line Speed Test challenges.

Autonomously turning the vehicle on the spot requires high torque dc motors to maintain a stable speed. Spinning the robot vehicle on the spot too fast will likely cause the OpenCV application to miss object detection. I hope the new 200 RPM dc motors will provide a right balance between speed and control; Which will be especially crucial for the challenge: Somewhere Over The Rainbow.

  • Pi Camera Video Capture with OpenCV and Python MultithreadingLink.
  • Object Detection and Tracking with OpenCV and PythonLink.
  • Install OpenCV onto Raspberry Pi from Shell ScriptLink.

Pi Wars Robot Platform and Attachments

X Shot Reflex 6 Toy Dart Gun
X Shot Reflex 6 Toy Dart Gun

The current Pi Wars robot design is made to fit inside an A5 sheet of paper, which will provide useful manoeuvrability on the tighter courses. Also, the A5 size fits on the 3D printer build platform I use to build the robot.

I will also be 3D printing the attachments for various challenges. I originally planned to hack a Nerf dart gun toy for The Duck Shoot challenge. But I think it will be a more exciting challenge to build one from scratch with some unique features. I’ll be looking for a design that is visually appealing and can put on a show in its operation.

The micro DC gear motors appear ideal for Pi Wars with various electrical and torques specifications available. I’m using the medium duty 6-Volt type that is a good fit for the TB6612FNG DC motor driver. Wheels of different sizes are also available for these motors, and the ones I have are 60mm in diameter.

  • GPIO PWM For Raspberry Pi H-Bridge DC Motor ControlLink.
  • Micro Servo 9g – Raspberry Pi Servo Motor Python Code TestLink.

Until Next Time

You will find many Posts related to the Raspberry Pi and The Pi Wars Competition on this site. Plus more will follow including more about the DC motor driver I have setup on my robot entry.

External Sites

  • Pi WarsLink.
  • Pi Wars USALink.
  • New – Pi Wars ScotlandLink.

Buying Featured Items

The purchase price is going to vary greatly depending on how quickly you want the items. Therefore shop around checking out Amazon, Ebay, Adafruit and local electronic stores.

The Pi Hut

  • Raspberry Pi Compatible Wireless Gamepad / Controller – Link

UK Searches:

UK Amazon:

  • Raspberry Pi – Search.
  • MicroSD Card – Search.
  • Raspberry Pi Compatible Wi-Fi Dongle – Search.
  • Raspberry Pi Camera – Search.

US Searches:

US Amazon:

  • Raspberry Pi – Search.
  • MicroSD Card – Search.
  • Raspberry Pi Compatible Wi-Fi Dongle – Search.
  • Raspberry Pi Camera – Search.

On Closing

I hope you find this article useful – Pi Wars 4.0 Update – Robotics Challenge Competition, please like and share.