Remote Controlled Robot

Recently, my ThunderBorg Kickstarter reward from PiBorg arrived, and not much later, DFRobot offered to sponsor a Devastator Tank Mobile Platform platform. The perfect opportunity to build a mean-looking, remote controlled robot!

Let’s take a closer look at the build.

Robot Platform

The robot platform for this project was kindly sponsored by DFRobot. It is the Devastator Tank Mobile Platform with metal gear DC motors.

The platform comes as a kit. All parts are neatly organised in labeled bags, which makes following the assembly instructions incredibly easy. Assembly took me about one hour, without the electronics.

This slideshow requires JavaScript.

The aluminium frame is sturdy, however, there was a bit too much slack on the tracks. I removed one link per track, which resolved the tension problem. The links are held together using pins, which can be pushed out using a small pointy tool.

Here are some pros and cons of the kit, based on my personal experience:

+ easy to build / clear instructions
+ sturdy, yet lightweight
+ plenty of mounting points
+ great torque

no tools included
not very fast

Motor Controller

The motor controller for this build is the ThunderBorg, by PiBorg. I backed the project on Kickstarter, and recently, my reward showed up 🙂

The ThunderBorg is a Raspberry Pi compatible, dual output motor controller capable of handling up to 5A per output. It supports a power input voltage between 7V and 35V, has an onboard RGB LED, battery voltage monitor and a 5V regulator used to power the Pi via its GPIO header.

This slideshow requires JavaScript.

There are some mounting holes at the back of the frame, with spacing matching that of the ThunderBorg and Pi Zero. Using the nylon spacers provided with the ThunderBorg, both are easily mounted.

Because of the supported input voltage range of the ThunderBorg, I decided to use a 10.8V cordless drill battery. It’s small enough to fit inside the frame and delivers plenty of power.

As for the software, the installation of the ThunderBorg code is a breeze, requiring only a single command to be executed after having set up the Pi with the latest Raspbian:

pi@devastator:~ $bash <(curl

Plenty of code examples are provided, allowing you to get started immediately.

pi@devastator:~/thunderborg $ ls -l tb*.py
-rwxr-xr-x 1 pi pi 2225 Apr 3 14:54
-rwxr-xr-x 1 pi pi 4782 Apr 3 14:54
-rwxr-xr-x 1 pi pi 6933 Jul 2 12:36
-rwxr-xr-x 1 pi pi 3578 Apr 3 14:54
-rwxr-xr-x 1 pi pi 2018 Apr 3 14:54
-rwxr-xr-x 1 pi pi 1373 Apr 3 14:54
-rwxr-xr-x 1 pi pi 2292 Apr 3 14:54
-rwxr-xr-x 1 pi pi 2060 Apr 3 14:54
-rwxr-xr-x 1 pi pi 3544 Apr 3 14:54
-rwxr-xr-x 1 pi pi 2905 Apr 3 14:54

Wireless Gamepad

All that is left to do is to ensure we can control the robot. To do this, I’ve chosen to use a cheap BlueTooth gamepad, the 8Bitdo Zero.

This slideshow requires JavaScript.

The PiBorg website has a great tutorial on getting a BT PlayStation 3 controller to work, which can be applied in this case as well.

Here’s my summary of the commands:

pi@devastator:~ $ sudo apt-get -y install libusb-dev joystick python-pygame

pi@devastator:~ $ sudo bluetoothctl
[bluetooth]# discoverable on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on

Once scanning is enabled, and the controller is on, it should be detected and its MAC address displayed. That MAC can then be used to pair the controller to the Pi.

[bluetooth]# pair E4:17:D8:19:17:08
[bluetooth]# trust E4:17:D8:19:17:08
[bluetooth]# connect E4:17:D8:19:17:08

The controller should now be able to automatically pair with the Pi, even when rebooted.

Finally, to test the controller is properly detected, the “jstest” command can be used. Pressing buttons should trigger changes in the output on screen, giving you the ID of the buttons or axes.

pi@devastator:~ $ jstest /dev/input/js0

Driver version is 2.1.0.
Joystick (8Bitdo Zero GamePad) has 8 axes (X, Y, Z, Rz, Gas, Brake, Hat0X, Hat0Y)
and 16 buttons (BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?, ?, ?).
Testing ... (interrupt to exit)
Axes: 0: 0 1: 0 2: 0 3: 0 4:-32767 5:-32767 6: 0 7: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off 13:off 14:off 15:off


With all components connected, installed and tested, it’s time to combine them with code.

The code is a slightly modified version of the tbJoystick PiBorg demo:

  • modified voltages specific to my motors and battery
  • remapped some controls to match my controller
  • added shutdown button, making it possible to perform clean shutdown of the robot
  • added turbo button, giving the robot a brief power boost

The resulting code capable of controlling the robot via the little gamepad:

Why stop there, though? The frame has so many mounting points, you could expand the code to add sensors, a camera, LEDs, etc …  It’s up to you!

The final step is to start the script at boot by adding a cron job:

pi@devastator:~ $ sudo crontab -e

# m h dom mon dow command
@reboot sudo /home/pi/thunderborg/ &

All done! Time to have fun with the robot! 🙂

© Frederick Vandenbosch, 2014-2021. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.