Building a Raspberry PI Humanoid Robot in Java: part 1

In one of my previous blog posts I dove into the territory of robotics, the first big projects was building the robo-spider:

As you might have also seen we have a Nao robot, however there is something about the magic of creating your own humanoid robot. Although it is hard to come close to what you can do with a Nao, I want to try to master the basics on building my own Humanoid Robot.


Perhaps it is good to write down what I have set out to achieve with my Humanoid robot:

  1. Have basic sensors for distance and axis detection
  2. Run wirelessly without requiring wired network, usb or power cables but is still controllable (wifi)
  3. Get the Robot walking and have other working movements
  4. Combine Sensors and movements, walk with obstacle avoidance
  5. Allow interaction and collaboration between the Nao and my Raspberry PI robot
  6. Have dynamic walking capability

In this post I want to address the points 1 and 2, by creating a small portable sensor solution on top of a raspberry pi powered by a set of Lipo batteries. In a later post I will put this all together and hopefully manage to address the point number 3 and further by having the robot work together with the Nao robot.


So where do we get started, I have a Robotis Bioloid kit that comes some interesting sensors, being 3 distance sensors and a Gyro sensor. In the previous spider robot I used a Raspberry PI 2 with a USB powerpack. That was relatively easy solution as a spider robot provides a stable flat platform on the top to build onto.

Raspberry PI

Getting a proper stable platform is a lot more challenging on a Humanoid due to the center of gravity. In case of a Humanoid robot you either put the electronics in its chest, or on its back. But it is very important to keep the center of gravity and not sway the top either forward or backward to much, anything you do needs to be compensated by your servo’s then. The solution I had for the spider robot was simply not suitable anymore for this reason, the battery powering the PI2 was to heavy and also the PI2 was too big.

Bill of materials

So this means I needed something lighter and smaller, so luckily my girlfriend managed to get me a Raspberry PI Zero for christmass :D. This should solve the bulkyness of the PI at least.

For powering the robot I also need a lighter solution, here I went for an Adafruit powerboost that allows me to run the PI Zero with a single cell LIPO battery of 2500Mah which is very compact and flat.

Next to this I needed an Analog Digital Converter that allows me to read the sensors that came with the Robotis kit.

So the total list becomes as following for powering the sensors and PI:
* Raspberry PI Zero + 16GB micro-SD card
* Micro-usb hub + Wifi Dongle
* AdaFruit Powerboost 1000 Basic
* AdaFruit 1 Cell LIPO 2500Mah
* AdaFruit 1115S 16Bit 4 Channel Analog Digital Converter
* Small breadboard for putting it together

We will run the following sensors with this setup from the Robotis kit:
* Sharp Distance sensor GP2Y0A21YK (10 – 80 CM)
* X & Y Axis Gyro sensor

Next to this I also use these Servo’s and hardware to power them:
* USB2AX Dynamixel usb-serial communication stick
* 18x Dynamixel AX-12A servos from a Robotis Bioloid premium kit
* Robotis SMPS2Dynamixel to power the servo’s (allows to connect a Lipo 3S power pack)
* 2S LIPO 1200Mah for powering the Servo’s

Wiring it up

So how does that look all wired together, well it is relatively simple. I had to solder the connectors onto AdaFruit components and the GPIO connector onto the PI Zero.

After this the solutions look like below in the picture for just the Raspberry Pi Zero and the sensor parts:

And this is how it looks on the back of the robot with the servo’s and all:

Reading Sensor data

Now that the hardware was sorted, the next challenge was reading out the sensor data. Well luckily this is relatively easy with thanks to the chose Analog Digital Converter chip (ADS1115 from AdaFruit) that i have chosen. There is simply an example for the ADS1115 chip available in the PI4J project here:

So with this piece of code, it is a simple matter of running it, and this is what I got on my first run:

(MyAnalogInput-A0) : VOLTS=2.33 | PERCENT=57% | RAW=18677.0
(MyAnalogInput-A0) : VOLTS=1.43 | PERCENT=34.8% | RAW=11413.0
(MyAnalogInput-A0) : VOLTS=1.04 | PERCENT=25.4% | RAW=8321.0
(MyAnalogInput-A0) : VOLTS=0.87 | PERCENT=21.3% | RAW=6981.0
(MyAnalogInput-A0) : VOLTS=0.77 | PERCENT=18.8% | RAW=6171.0
(MyAnalogInput-A0) : VOLTS=0.68 | PERCENT=16.5% | RAW=5413.0
(MyAnalogInput-A0) : VOLTS=0.56 | PERCENT=13.7% | RAW=4498.0
(MyAnalogInput-A0) : VOLTS=0.44 | PERCENT=10.8% | RAW=3546.0
(MyAnalogInput-A0) : VOLTS=0.42 | PERCENT=10.3% | RAW=3391.0
(MyAnalogInput-A0) : VOLTS=0.37 | PERCENT=8.9% | RAW=2930.0
(MyAnalogInput-A0) : VOLTS=0.18 | PERCENT=4.3% | RAW=1419.0
(MyAnalogInput-A0) : VOLTS=0.02 | PERCENT=0.5% | RAW=175.0

This is the distance sensor, where 2.33 Volt is a distance of roughly 10CM and 0.02Volt represents a distance of 80CM or further. In the future this should be perfect for object collision detection.

Wrap up

In this first post of a few parts I managed to created the basics of my mobile robot. In the next post I will work on the Walking of the Robot which is quite a challenge as you can imagine. If you want to see a sneak peek into this you can already see a Youtube video of this here:


3 thoughts on “Building a Raspberry PI Humanoid Robot in Java: part 1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s