How to Build a Raspberry Pi Robot
In this post, I go over building and programming any kind of robot you want from scratch using the Raspberry pi 3B and the Adafruit 16 Channel Servo Hat.
Out of all my raspberry pi projects, I felt like this was the most important one as it can encompass everything I’ve ever learned technologically.
I didn’t want a slow, low detailed, educational, friendly robot for toddlers. (I’m picky like that)
I needed a machine that was
2: high grade,
3: able to take a beating
4: modular, so it it can be customized or upgraded from time to time.
Setting up the pi for Bionics
The very first thing I was gonna do, was configure the Raspberry pi to use servos, the motors that make up the moving parts of a robot.
And The best way I know how to do that is with the Adafruit 16 Channel Servo hat. Once I was set up, I was ready to Rock n’ Roll!
I started browsing through thingiverse, a library of user created 3d models and Inventions. You can find most things here: statues, servo powered locks and light switches,3d printed costumes etc. And an intense selection of robots! How thingiverse works is you look for something, download the file And then 3d print it at home and even customize them to fit your needs. This way you don’t have to learn 3dmodeling Yourself if you don’t have the time or simply aren’t interested.
The brainchild of a badass duo based in China, This gorgeous bot has hands, ankles and does everything I’d want a personal robot to do.. I’ll take it!
It would use all 16 servo channels on the servohat and has space inside the chest to place the pi.
However there are a few things to consider:
1-It was built for Arduino which is a different size and spec from the raspberry.
2-It was designed for servos that are even smaller than the 9gs I’m accustomed to using (which I find out the hard way).
3-Buying the kit means spending around 360$ :/ (yea right)
So I’d have to work out modifications to the frame in order to Taylor it for the Raspberry pi. Thankfully, the guys at A.i.Frame have released the design itself to the public!
Making it totally possible to build and customize the design as I saw fit and with my Robo3d r1 plus 3d printer up and running, I now had pretty much my very own mini factory right in my room.
Finding the right size for 9g Servos was the most time consuming part of putting this thing together.
Ai.frame’s personal brand of servos are smaller than 9gs and are more expensive and are ordered overseas so you know they take longer to ship.I refused.
After 3 very disheartening attempts and like a pound of wasted material I worked out the ratio and found the magic number of 1.03 times bigger to fit in regular tower pro 9g servos.
Though the hands for some weird ass reason need some special attention to get the thumb servo fitted.
For screws, as luck would have it, these Hilitchi m2 hex screws fit the new size of the bot hellishly perfect.
Once you have all your pieces, this video helps you put it all together.
So far, it stands “OK”. Won’t be doing jumping jacks anytime soon at least not until I’ve solidified the construction.
As for the look, I wanted like an American gladiator, NASCAR, monster truck kinda feel to it.
Still had the problem of the computer itself not fitting inside so i printed out a raspberry pi servo case off of thingiverse
And fit it on as a backpack. Which will probably mess up the balance later but I’ll deal with that down the road.
printed out the rest of the type b armor out of aluminum pla to get that dull, industrial metal look.
The shoulders fit a bit funny with the servos but it’s not a big a deal. Bit of a ways off from perfect but so far, this things coming out badass!
It’s important to keep the servos attached but not tightly screwed in at this point to make it easier to adjust final positions during calibration. But it’s almost there. 😉
So far this machine is everything I could want now it’s time to calibrate the servos and craft my servo codes to control our specific machine easily and efficiently.
My basic robot repo is up for anyone using a similar set up to customize and scrutinize.
And once I was finally satisfied, tightened up those screws and I was ready for some real testing.
My favorite part is watching this thing come to life while designing manouvers one by one which is straight forward If not tedious.
Say you want your bot to wave goodbye, you would program each servo Individually then put them into a sequence, a function and call it good bye. Keep at it and test along the way before you Kno it, your bot will have many things It can do that are now stored and can be used with the push of a button.
Spent some time getting a fighting stance and a jab going and this is what came out:
Programming like this is a great opportunity to get to know the physical capabilities and limitations of your selected bot intimately Which can better guide you in how you program it so that the Servos work in harmony with the body you have built. It stands fine and it’s pretty damn responsive. Hell yes!
Now that we have a bitchin’ robot to program, we just have to tweak the construction a bit more and see how far we can get!
In my case I added more screws in key areas as to eliminate shaking parts and make sure every part of our machine is exactly where it should be at all times.
As well as add “spines” to organize the servo wires a bit. One for each limb. Its actually a resized cable protector daisy chain upgrade for my 3d printer.
Now we’re set to try and get this thing walking.
Learning to Walk
Needless to say my walk program could use some polishing to better work with the design of the bot itself. but this little test helps me at least understand the locomotion of my machine. It’s a decent first try 🙂
It’s about time to start cutting chords, so to speak. Meaning you’re not going to want your robot plugged into your t.v. or plugged into anything for that matter. Portable batteries, on/off switches. The things you’d expect ANY high functioning robot to have built into it.
I spent so much time on it that I built this handy little post on Upgrading the Raspberry Pi to house these accessories that I actively apply to any given project that I’ve discovered so far.
Mobile Phone Control
Ok! The last thing you would need is a reliable monitor.
Sure you can carry a laptop everywhere you go and plug in ssh But that’s hardly convenient (or cool for that matter). You can get a pi screen but that would add to your bots weight And the goal is to control it from a distance right?
So I found RealVNC..Realvnc is an app that let’s you control other computers desktops With your mobile phone convenient and most importantly, free. The app can be used with Android or iPhone to connect easily To your raspberry pi’s desktop granting you wireless control Over your bot without carrying more computers or gear.
Definitely a must for completing the idea of a fully wireless Raspberry Pi robot.
And with that, you have enough knowledge to continue on fine tuning your basic bot and evolve it to your personal vision 🙂 you can add sensors, voice commands, a.i., computer vision etc. So keep at it and stay tuned for updates.
!!!!!!Update: Robot Vision!!!!!!
Targeting and tracking!!
I added a USB cam and some Opencv to give this thing an “eye” on its left arm for a pretty simple yet very efficient targeting system.
Opencv is an open source python library which grants your raspberry pi with the gift of sight via webcam or pi cam. Imagine your robot being able to recognize you or to respond to a fire that it notices..the possibilities are near endless. Targeting systems are a favorite of mine. 🙂
for a full rundown on installing openCV on the Raspberry Pi (which can be tricky), and upgrading your bot with computer vision, check out my computer vision post.
!!!!!!Update: Gesture Control!!!!!!
Upgrade your bot to understand Movement!!
I recently got around to applying gesture control to my bot to have it mimic my movements using the Myo Armband:
The Myo Armband is a bracelet that can read and record your muscle signals to program your Movements to be recognized by your gizmos.
Think about reel steel or Pacific rim styled robot control or flying drones and driving rovers by waving your hand. Or even perhaps a bionic prosthetic hand for somebody who doesn’t have one! Can you imagine?
Anything I have worked out so far can be found and learned from in my post on Gesture control. So give it a look if you want to apply this kind of tech to your Raspberry Pi and see what you come up with.
!!!!!Update: perfect Body!!!!
Finally! All the wires and electronic components are neatly inside..
After messing with the 3d files long enough, i found the golden ratio(1.035) which about perfects this bots body.
Ready for mass production 😉
with the SunFounder PCA9685 16 Channel 12 Bit PWM Servo Driver for Arduino and Raspberry Pi which is an excellent(no soldering required) alternative to adafruits servohat.
AND found my screws of choice for the most solid configuration yet. Killer.. You only need 2 kinds of m2s: Hilitchi m2 hex and female to female m2 spacers for a solid, no shake, EASIER to build robot.
I’ll be releasing the thingiverse files pretty soon.
And yes the armors been recently perfected too!
That’s all folks!
Stay tuned for more updates and please, like, comment and share!