Raspberry Pi Controller For Robot Control Review

Raspberry Pi Controller for Robot Control Review

If you are looking for a Raspberry Pi Controller to control your robot then this controller is worth looking at. This article takes a closer look at the controller with details about its compatibility and button mapping.

So I was looking for a Raspberry Pi Controller to control my robot projects. Hence I discovered The Pi Hut Raspberry Pi compatible wireless controller. Initially, I thought of using Bluetooth controllers such as the PS3 and the PS4 controllers. However, using Bluetooth added the additional point of failures such as failed pairing and unplanned disconnects.

The Pit Hut Wireless Raspberry Pi Controller

Raspberry Pi Controller
Raspberry Pi Controller

Overview

The case design and button layout are similar to the PS3 controller style. In addition, the build quality feels good in the hand and the casing is transparent blue. Furthermore, the rear of the controller has a power switch and a battery compartment to fit three AAA batteries.

A USB dongle is supplied with the Raspberry Pi controller to provide a wireless connection. However, only one controller can be paired with the USB dongle. Furthermore, during inactivity, the controller will automatically power down after five minutes. Subsequently, the start button can be pressed to revive the Raspberry Pi Controller.

Wireless Raspberry Pi Compatible Controller Back View
Wireless Raspberry Pi Compatible Controller Back View

Pros

  • You can write Python code to interface with the controller in both Windows 10 and Raspian.
  • Pairing is unnecessary to connect the controller.
  • The USB dongle allows the controller to stay connected, even when there is no power to the controller.
  • Easily replace batteries to keep the controller in continual use.
  • Ideal for indoor use at short range.

Cons

  • Only available in one colour as of writing.
  • Controller thumb-sticks, for analogue output, require very small axis movement for variable control.
  • Analogue feature on the trigger switches is very sensitive. It will take some practice to apply variable pressure on the switches within analogue range.
  • The controller is not rechargeable.
  • Short range use only.
  • Changing analogue state on the trigger switches require device driver reload to reconnect to the controller.

Raspberry Pi Controller Compatibility

Game Controller Properties In Windows 10
Game Controller Properties In Windows 10.

I did not know much about the Raspberry Pi controller from Pi Hut until I started working with it. So First I initially tested the controller in Windows 10, and it was recognised and loaded successfully. Secondly, while still in windows 10, I tested the Raspberry Pi controller with Pygame code example under Python 3. The code example worked, and as a result, I was able to map each controller button to an index number.

Raspbian Pygame Controller Test
Raspbian Pygame Controller Test. Find the code below.

Lastly, the Raspberry Pi controller worked just fine under Raspbian stretch as with Windows. However, what sets windows 10 and Raspbian apart is that inputs Python package did not find the Pi Hut controller under Windows. Yet inputs package worked just fine under Raspian Stretch with python3 inputs test code.

Also, the Raspian Stretch exposes two more axis outputs on the trigger switches which are not visible on Windows. The two trigger switches are pressure sensitive, and output an analogue signal to axis 4 and 5 in Pygame. The trigger switches analogue feature can be disabled by holding the analogue button for around 4 seconds. However, disabling the analogue feature will also change the index of some buttons. The analogue feature appears to be on by default which is indicated by the power LED.

Raspberry Pi Controller Features

  • 2.4GHz wireless with a USB dongle.
  • Sleep function after five minutes of inactivity.
  • Requires three AAA batteries.
  • Four analogue channels from thumbsticks.
  • Two analogue Channels from trigger switches (Linux only).
  • Thirteen Usable buttons.
  • Eight Hat button positions (Pygame).
  • Four Hat buttons (inputs).
  • Windows 10 and Raspian compatible.
  • Pygame and inputs compatible.

Pygame Button Index Map

Pi Hut Game Controller Pygame Button Map
Pi Hut Game Controller Pygame Button Map

Example Python Test Code

import pygame
import time

pygame.init
pygame.joystick.init()

# Get count of joysticks
joystick_count = pygame.joystick.get_count()

# Wait until joystick is connected
while joystick_count < 1:
    print("joystick not connected")
    # Sleep for 1 second
    time.sleep(1)

print(joystick_count)

# For controlling robots we would only be
# connecting 1 joystick controller. So we
# connect to the first available controller.
# So the first joystick will be at index 0.
joystick = pygame.joystick.Joystick(0)
joystick.init()

name = joystick.get_name()
print("Joystick name: {}".format(name) )

axes = joystick.get_numaxes()
print("Number of axes: {}".format(axes) )

for i in range( axes ):
    axis = joystick.get_axis( i )
    print("Axis {} value: {:>6.3f}".format(i, axis) )

buttons = joystick.get_numbuttons()
print("Number of buttons: ", buttons)

for i in range( buttons ):
    button = joystick.get_button( i )
    print("Button {:>2} value: {}".format(i,button) )

hats = joystick.get_numhats()
print("Number of hats: {}".format(hats) )

for i in range( hats ):
    hat = joystick.get_hat( i )
    print("Hat {} value: {}".format(i, str(hat)) )

The above code retrieves controller information. Thus the terminal window you see above shows the output.

Links

  • Pygame documentation and test code for pygame.joystick module – Link.
  • Python library inputs – Link.

Conclusion

For the price of 14 pounds, this is a nice controller. I found it easy to work with because there are no pairing issues you find with Bluetooth. Also while the USB wireless dongle is plugged in, the controller is always connected. Therefore your controller software will always be able to load even when the controller is switched off.

In a follow-up article, I will be looking at how to use the Raspberry Pi controller from Python code.

Related Articles

Robot Control with Raspberry Pi and Python

Robot Control with Raspberry Pi and PythonLink.

Pi Wars 2018 Competition Getting Started

Pi Wars 2018 Competition – Getting Started – Link.

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

US Searches:

US Amazon:

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

On Closing

I hope you find this article useful – Raspberry Pi Controller For Robot Control Review, please like and share.

4 thoughts on “Raspberry Pi Controller For Robot Control Review”

  1. If you’re still on the fence about which robot controller to use, this one is worth a look.

Comments are closed.