Building a robot sparring partner

Gareth Fuller
9 min readDec 26, 2021

After finding an awesome project online (the RTX-1 sparring robot) I decided to, for fun have a go at building something similar myself. The disclaimer I should add at this point is mine is in no way as good as the one you can buy off the shelf.

I first took a look at my punchbag the Century Bob and noticed there were two spaces for bolts on the back. As if begging me to attach something to them. So I went about making a frame of how I imagined the final frame might look. I wanted to make sure I could still use he punchbag without kicking the frame etc. So I made frame out of some cheap plastic pipes did some training with it, and all was good it moved about a bunch but I did not hit it at least.

Prototyping the frame

The Body (v1)

For the first version I knew I wanted to use swimming noodles for the arms of the robot and kinda knew how big the frame should be. But I needed a heap of things to get started:

  • Nuts, bolts and washers. For this I went with some M4 (4mm diameter) screws of two lengths. Short ones for when there is one bar and long ones for when I need to connect the bars together
  • A bunch of bars to build the frame. But for this not just any bars I found some nice bars with holes in all the way down called Tetrix the smallest holes are 3mm but I knew I could get a 4mm one in there if need be.
  • Brackets to hold the frame together
  • Plastic ends for the noodles to connect to the servo mounts
  • The servo mounts, so when the motor moves they swipe the arm up / down or left / right for hooks.
  • Servos (the motors). This was really hard as there was a bunch of math for working out the strength you would need. But given my arms were going to wobble like crazy I wanted fairly strong ones. And looking at the servos it seemed like the stronger they got the slower they were. So I opted for the middle ground of 25kg servos.
  • Two big ass bolts to come out of the punchbag so I can take the robot part of him on and off if I like by removing the bolts.

After I had all this I could work on the frame that looked like this:

v1 frame

The Muscles (v1)

Now I had the frame I needed to get it wired up to something I could control to move these beautiful arms. For this I needed again to search in the rainforest for some things. I needed:

  • Voltage converters to turn one voltage into another. I needed 7.4 for the servos and 5 for the pi. So at this point my thinking was, I will go from he plug power (9v) down to 7.4, then power all the motors. then come of this line of power and convert again down to 5 for the pi. And as there are 3 voltage converters in the pack if I blow one I should still be good.
  • Barrel jack connectors for the power in from a plug.
  • A bunch of wires so I could make some nice long wires to the box. I did not want to connect the box to the back of the punchbag as she wobbled like crazy and was worried of damaging the box. It also just makes things much simpler to not worry too much about shock damage.

I already had:

  • Raspberry pi4
  • Breadboard
  • Box to put it all in
  • 9v power supply plug with a male barrel jack connector
  • Soldering iron. So I could solder the wires (live and ground) to the barrel jack that would go to our first converter
  • Multimeter to work out the voltage (as the servos need more than what goes to the raspberry pi)

From the diagram the orange wires are the signals from the Raspberry pi to the motors “servos” to tell them when to move. Red is for live wires and black for ground. The Ground from the pi to the ground on the board is super important without it there will be smoke / fire 🙈. So there should be one ground in and one ground out. To and from the pi like the diagram.

The Brains

Then I made a little app to make the arms move look so:

Little app to move the arms

And this is how the whole thing worked in theory:

The problems …

With this version there were many problems:

  • The pi would cut out as there was not enough power and the servos would drain the current.
  • The arms moved too slow.
  • The whole thing wobbled too much when I really used it and the momentum of the bag moving made it even harder for these little motors to move the arms.
v1, not working quite as I expected

So I got to thinking about a new version, and decided to:

  • Get bigger motors
  • Fix the arms to the body somehow and not have this frame bolted on.
  • Fix the power issues.

The Body (v2)

For the second body I decided to model and 3d print what I needed, it would “hopefully” look something like this when done:

So I got to work printing from my pantry 😆

After it was all printed, I got some nice straps to hold each side together and it came out looking like so:

After printing the parts

And these were the new motors I used:

This was working really well. But I had to keep the arms attached all the time. So I thought I would print some screwable sockets to make it so I could remove the arms when I want to put the robot away. They came out like so:

There was one major issue with them however. They would snap all the time! the arms were too thin that attached to the motors. I was printing with PLA and tried ABS filament but had the same issues. In the end I kept the metal brackets and screwed them to the new screw sockets. It came out looking like this:

Next I needed to solve the power issue, for this the solution was simple. Have two power supplies, one for the pi and one for the servos. The new wiring looked a little like this:

Notice the voltage for the servos is now 8.4 as the new servos need more juice.

This is how it was now finally working how I imagined all along:

All that was left to do was print a nice case to hold the electronics and give it a paint job:

Wrapping up

It was really fun to make, but in reality I spent way too long tinkering with it. I still have things I want to add like curved arms for the hooks and maybe even a crash helmet with a camera to really train it to hit me.

Still it was a great project and I can now play with both the bot and code to keep improving it further.

Speaking of the app

Be warned what I am about to talk about is a little technical so feel free to ignore the rest as I won’t spend time explaining things.

The main architecture

The code can be found here, the code is organised in a lerna repo. There are three applications:

  • React Native app for the front which sends and receives events to the robot
  • Node js app for the robot (code on the pi) using Jhonny-five to send and receive events, manage the workout and combat and send signals to the servos
  • Infrastructure application using Pulumi to manage the AWS infrastructure in code

How the robot talks to the react native app

In the infrastructure package we manage all of the things needed for SNS and SQS to work from the NodeJS robot to the React app. Pulumi not only comes with what is known as a “stack output” to get a hook into resources that were created in your cloud provider. But it comes with a secret management and configuration system for “stacks”. The intention of these is to allow you to spin up your entire architecture for say a dev environment or even integration testing. A cool side effect of that is we can access the secrets using the cli that comes with Pulumi.

What this means is that we can get all the output from the infrastructure that we need to use to configure both the other apps.

For example we need to know the secret access key and access key id when setting up a sqs client like so:

What is cool is we have a script in the app that will generate an .env file based on the output of deploying the infrastructure. Pulumi can manage all of our secrets for us and we can keep everything in source control.

Have a look at the code to work out exactly what is going on, I am just going to give a broad overview.

Structure of the events

I wanted to keep the events as flexible as possible, so there are only a few “set in stone” messages. Things like start, stop, hit with arm1 I know won’t change over time so I made those hard set.

There is another message which is the payload for the workout and that has a shape like this:

  • difficulty
  • duration
  • arms enabled
  • pause duration

The user of the app can then disable arms if they like, make the arms move faster. Have longer breaks between combos and set the duration for the entire workout. I wanted to keep it flexible as it really is a config for a workout so I just send over some JSON in the workout start event from the app to the robot.

Logic of the robot

The robot is fairly simple right now. It gets a message to start the workout using the config. Then starts a little “workout manager”. This manager will do the following during a workout:

  • Pick a combination from an array of combinations I created at random (based on the arms enabled).
  • Extend and pull back the arms. managing the speed of the arms and timeouts for knowing when things are done. All this is based on the difficulty.
  • Pick the next combo and start it. Only after the pause duration from the config so the user gets a nice pause if they want one.
  • Stop the workout when the workout duration is over.

The React app

There are just two screens, one for setting up the workout and one for manually moving the arms. It is super basic as it is just me using it.

The front end react application receives events from the robot on the status of the robot. It can show if the robot is idle, in a workout and so on.

screens from the app

Whats in the future?

I would like to add a crash helmet to bob with a go pro on top and try to do some facial recognition. Then I can calculate which arm to try hit the face at based on the position. And maybe even try to do some machine learning to make it smarter over time.

Another idea I am floating is the ability for people to remote stream the camera output and control the arms. Maybe via two mobile phones motion sensors or something crazy. For a fully remote but human sparring experience.

I guess as I now have a cool base line the sky is the limit with this little “robo bob”

--

--