I have been a life-long fan of anything around robotics, but I was never able to get close to my dream of building a robot due to money, expensive kits or even knowledge.
But these days these things no longer have to be a blocking issue, there are kits out there that make it possible to build your own robot quite easily. So I set out to create my very own Robot based on readily available materials. My main goal was to hand create something myself without using a pre-scribed kit. A few months ago when I started the project I set out with a few ultimate criteria for the v1 version:
- I can write all the code myself easily in a JVM based language
- It is affordable and easily hackable
- It can run wirelessly without requiring network, usb or power cables but is still controllable (wifi)
- It provides an abstraction layer over complicated robotics principles (motion, sensors, etc.)
- Can take different forms (humanoid, spider, buggy, etc.)
I already had quite some experience with servo’s and remote controlled helicopters but this is just not the same. I needed a Servo that allowed me programmable control without having to hack to much :). These days there are quite some alternatives for this. In the end I settled on the Robotis Dynamixel AX-12A servo which has a serial bus that is controllable via a USB – Serial protocol. I bought it as part of a Robotis Bioloid Premium kit as it has also quite some other nice goodies which could be of use in the future. Ofcourse next to this there are also some other parts needed like a small form factor PC, obviously the Raspberry PI was a primary choice there 🙂
In the end I ended up with this materials list:
- Raspberry PI 2 with Raspbian and JDK8 installed on a 16GB micro-SD card
- Netgear USB Wifi-N stick
- USB2AX Dynamixel usb-serial communication stick
- 5000Mah powerpack to power the Raspberry (power output 2.1A)
- 18x Dynamixel AX-12A servos from a Robotis Bioloid premium kit
- Robotis SMPS2Dynamixel to power the servo’s
- Frame from the Robotis Bioloid premium kit
- 2S LIPO 1200Mah
- LIPO connectors
- DC connector to Lipo cable
Java Dynamixel Library
The first step I had to overcome was how to control the servo’s. The USB2AX stick combined with the Robotis SMPS2Dynamixel could allow me power and control. But there were no working Java libraries for this. Luckily there are quite some examples of the communication protocol. I ended up using a Java Serial driver library to talk via the USB stick to the Servo’s. It was quite some figuring out to the low-level where I had to build specific byte packages and I won’t bore you to much with the detail but the result is a working Java library to control the Dynamixel Servo’s. I have made this library available to people that would be interested on Github: https://github.com/renarj/dynamixel
Now that I could control a servo it was time to create a Robot from the servos. Ultimately the Bioloid Premium kit comes with this very cool humanoid robot design, but this was way too challenging to control. Humanoid Bipedal motion is a very tough subject on its own. I just wanted to first validate my software concepts before diving into this. So I decided to build a spider robot from the Kit which I could learn to walk, stand and sit 🙂
This is the end result of the robot build, strapped with the Raspberry PI, powerpack, LIPO and all wiring done:
The next challenge I had to overcome is now that I can control one servo, can I also control all 18 at the same time? And to make it even more challenging can I get some useful motion out of it 🙂
The solution lay in the software that came with the Bioloid kit, the software itself was pretty useless but they did came with some prescribed motion files for the robots. These motion files described some animations if using 18 servos that I could read and convert into my Java code. So all I had to do was build a converter from these motion files to an in memory structure that I could replay on the Raspberry.
The end result is visible here:
The last piece of the puzzle for this post was the building of a small webservice so I could remotely control the robot. In my job at SDL I have supervised a team where I have architected and build a opensource REST OData framework (https://github.com/sdl/odata). This framework allows you to create very quickly a resource driven REST webservice based on the OData specifications (http://www.odata.org/)
In a few hours I managed to create a OData Webservice in the same Java project to control the robot. Moving the robot is as simple as calling a URL as following:
The code for this WebService is available in the same Github repository as mentioned before: https://github.com/renarj/dynamixel
I have managed to create a Robot spider controller by my Raspberry PI in a relatively short timespan (2 months). There are still tons of things to do like integrate sensors, pi-cam and more.
It is a great fun project, and has inspired me to take things to the next level with a next great follow-up project. I will post a bit more on that in the coming few weeks. Hope you get inspired to do this yourself as well, don’t hesitate to drop me a line with questions on the robot or code.