Let's Make Robots!

Arduino Quadruped Walking Robot

walks on four legs
walking_gait_theory.zip1.34 MB

UPDATE 24.April 2011: New video! :) I implemented automatic resetting of the legs positions before changing from forward/backward walking to left/right walking. This is to ensure proper leg offsets. Previously I had to press the Z button on the nunchuk to reset, now it happens automatically, so one step closer to becoming autonomous. In this video the gait is the same for walking and turning (trot gait) only the duty factor is higher for turning (beta = 0.75) which means the leg stays on the ground for three quarters of the leg walk cycle time and only one quarter in the air. 

I'm not sure if I'll go with this sort of automatic position resetting (right now all the hips and knees just move to their center positions (because that is a suitable start position for both walking and turning with the trot gait) but I'm thinking it would probably be better to step the legs to center if they are further away from center than some threshold. So if the leg1's hip is at 51%  and knee at 40% let's say it will just move the hip for 1% and knee for 10% down, while if the leg2's hip is at 90% and knee at 100% let's say (that means the leg is extended to the front and is touching the ground) it would probably be better to step to 50% - like so: lift knee to 0% and then move hip to 50% and then put knee down to 50%, so it won't move the body when it starts to move leg2. I don't know maybe it's not such a good idea, I guess I'll see when I try it :)  

I'll probably use the trot gait for faster walking, while the crawl gait is more suited for slower walking (better stability). Very soon I will start with adding sensors and working on the autonomous mode.


UPDATE 23.April 2011: New video that shows robot walking with crawl gait (creeping) and turning with a 2/2 gait (trot gait but with the same duty factor as for the crawl gait (bigger duty factor for turning than in the previous trot example (the one with the wireless nunchuk and forward/backward motion only) for increased stability -> beta = 0.75, this means that 3 quarters of the leg cycle are 'spent' on the floor, while only one quarter in the air, check attached .zip file for more details on the theory)). However I have some problems. First problem is that I have real stability issues. When turning it trips over very easily (especially when going slow or really fast) and it turns much better to the right than to the left (stability wise) and I think this is mainly due to the fact that my legs are all handcut, glued together and screwed on the body so there's a lot of little mistakes that add up :) I think the problem is mainly with one leg being a bit too big and being a bit angled so the length of the leg changes with the hip move... I have to fix that, but I think maybe it's better to make a 3d model with the prototype's dimensions in Sketchup or something and then have it machined somewhere so the legs are really the same. Also I'm thinking of maybe building a new leg design, just to try out how it performs... I was thinking of something like this: http://www.youtube.com/watch?v=NAHo8eEbJCE&feature=related , I see here http://www.youtube.com/watch?v=msaWXY3OuQQ they're all using a very similar design just that it's 3dof. I think they wouldn't look as cool on a quadruped :) but maybe it is a better leg design, I don't know. I will have to throw something together to test someday (when I'll feel like making 4 new legs :)). Also the weight distribution is not ok and I think this amplifies the balance/trip-over issues. Tomorrow I'll buy some 2-battery holders and try to distribute it more evenly along the body's length. The second problem is that (as you'll see in the video) I have to reset the legs positions before I go into turn. That is to ensure the right offsets between legs positions and set the phases of the legs (I decided to split (mentally and in code) the leg walk cycle into 2 phases: step phase (when the leg is in the air) and pull phase (when the leg is on the ground)). This mandatory resetting is not optimal at all, because that means I will have to program the same behaviour in the autonomous mode, which by itself (implementing the auto-position-reset) is not really difficult, just that it's not pretty and natural, organic if you will :) There has to be a more elegant solution, probably mathematically more complex (I hope not too complex for arduino or for me ;)), but I am afraid I will have to rewrite most of the code (which wouldn't be such a tragedy, I don't have that much anyway and still full of bugs :), if only I had a good solution to the problem).  I'm searching for some cool ideas/solutions for this problem, if anybody has any. Is the IK (inverse kinematics) only option here, what do you think? Also I was thinking how it could walk on curved paths, like arc or something, and came to the conclusion I would have to implement the system like in servo controllers (eg. ssc-32), so I could specify the time in which to arrive to the destination, because now I am solely relying on all the legs being identical (as in all having the same servo travel, so all hips have let's say travel of 100 degrees, while knees have travel of 50). So to keep the gait regular and symmetric while turning I would have to adjust the speed for the timing to match up, so if the hips' travel on the left side of the robot let's say (if walking and turning left at the same time) should be shorter than on the right side.

Tomorrow I'll hopefully test, shoot and upload the video of trot gait for walking and turning (but with different duty factors maybe?) and try some other stuff to solve the gait transitioning problem and also check if I can improve the balance and weight distribution.


Hello everyone, I am new to this site (at least as a member), but I've been lurking around for a while looking for some cool ideas and I must say the site is really awesome.
I have to say this is my first robot and it was inspired by KatteJuice's SC-QR-1 robot, big up to him for showing what can be done with some hot glue and 8 cheap servos! I definitely wouldn't try and make a four legged robot as my first robot otherwise, mainly because you always see all those high grade servos and brackets and special controllers and whatnot when looking for hexapods and quadrupeds. Don't get me wrong, I would immediately fork out for dynamixels and aluminium brackets if I had the dough :). I see that when you actually try to build something like this, you find that in the long run you would probably be better off (quality and durability wise), but I learned alot and that's why it's better to start with nothing and build upon experience I think. Also I'm not much of a handyman, never been, so I neither have the tools nor the patience to make anything complicated (or anything where precision is key, like 4 identical legs) and so construction was the most difficult part for me. I am slowly getting into it though.

I started with the leg prototype, very similar to kattejuice's leg design, because I saw how well it works. The first material I used for the legs was plastic from cd casings, because I knew that I wanted at least prove the concept and have some sort of walking gait working without legs having to actually support anything, before I go and make all 4 legs. I searched google for info on walking gaits and robots. I found some book that had a preview chapter on google books, and it was just what I needed. Not too deep, only the basics, just enough to get me started. I can't remember the title, but I made screenshots :), and I can attach the files, if anyone is interested. The first tests went very well, so I made 4 of them and tried to walk, (just for fun, I knew they're too weak). Then I made legs v2, that were more solid, because I bent them 90deg to make them stronger. The plastic was still the same. Not good enough! :) So I went and made legs out of 3mm thick plastic 90 deg angled piece (dimensions: 30 mm x 30mm x 3mm x 1200mm). I chose an angled piece only because with my previous prototypes I had to do quite a lot of heat bending the plastic to make it more rigid, so I decided it's easier, better looking and stronger if I start with a piece of plastic that already has an angle and use it to my advantage.  

Leg (last version)

Also the last version has knee servo horn directly screwed and glued to one of the connecting pieces (upper), instead of transfering the force via the lever (?? not sure if this is clear?) like in the previous prototypes, it gives much less play, the movement is more immediate.


3 cm width wasn't enough to make hip brackets, so I had to improvise and hot glued 2 L pieces together to form a U piece that was 4cm or so high. Not so optimal solution but it works. I'll have to try and find some wider plastic and preferebly U-shaped for the hip brackets.


But I still needed better support for the hip joints (so the legs wouldn't splay that much in the hip), I had to make some sort of pivot shaft at the bottom of the servo. I made a hole in the bottom side of the hip bracket and screwed in a screw through the bottom part of the knee bracket and it worked out nicely. (It looks like it's screwed in, but the hole is big enough so it can rotate freely.)


quadruped robot without cover

For now I am powering everything from 5 NiMh AA rechargables, but I am strongly thinking of going to 2s LiPo battery instead. Mainly because it would probably make for a lighter robot, and also I guess the weight distribution should be better if I choose a low profile flat battery that fits in the body better. Question: Does anybody know of a BEC capable of supplying around 6A give or take (8 x 750mA for hxt900)? Or will I have to have 2-4 of them? Or do I just put some diodes to lower the voltage to 6V for servos? If so, how do I make sure not to overdrain the LiPo then? Any suggestions?

Currently I am using a wii nunchuk (wired and wireless) as an input device, mainly because it's convenient to be able to control the movement or the speed of movement - it's easier to figure out stuff if you can slow down things let's say, and it's also so cool :) Wired nunchuk works like a charm, but sadly the wireless version has some issues. The first problem was figuring out how to sync the controller to the receiver :) I tried holding down sync button on the controller, and the FC button(??) on the receiver. To no avail. Then I remembered I have a Wiimote from a couple years ago (used it for WiimoteWhiteboard with my homemade IR pen and for drumming (sample triggering with Wiinstrument) and for snes arcade emulator control :) ) So I connected it to the wiimote, then bound the wiimote to the computer, and guess what, the controller paired almost instantly, no holding down the sync button necessary, just a touch :) So back to Arduino. I noticed that the LED on the controller was brighter when connected to the wiimote than when I had it connected to 3.3V on Arduino. So I thought maybe the voltage is not high enough. I plugged it in 5V and it was brighter and it worked, but only after I removed all the resistors from the Data and Clock lines. So I figured it out, hooray! But here's another problem. Now that everything works, I see the bloody thing only outputs a series of 9 equal values ?? WTF!? After googling around I see others have the same issue. Great! I thought maybe if I decrease the polling delay (it was 100 ms) I can live with 10 times lower sampling frequency. Well I thought wrong! You can't go faster than 80 ms or so, maybe 50, but then the errors increase as well. So I am stuck with lame sampling frequency that makes controlling anything really laggy and not enjoyable. Also it loses sync every couple of minutes, you can see it at the end of the video. At the time of writing I can't even sync them together again. I will try to fix the issues, but in the worst case scenario I will just use wired nunchuk for developing and programming, while the crude wireless chuck will be used for basic control if anything goes wrong with the autonomous code (non-existing yet :) ).

As for the programming part goes, I wrote some classes so I can reuse stuff easily. So for example I have a Hip and Knee classes (I will extract them to Joint class, because they're basically the same, only the naming is different (eg. knee.up() vs. hip.forth()), which together make a Leg object. Four legs then form a Quadruped class that has functions like forward(), backwards() etc., so you can have very simple loop function like { if (speed > 0) quad.forward(speed); })  I'm not sure how I will implement smooth transitioning between gaits, e.g. I want to have a trotting gait (I think it's called that way) for forward/back motion let's say, but have wave gait (crawl/creeping) for turning maybe... They have different leg timings and positions and when controlled with a nunchuk you have to be able to convert from one to another at any point in time. Definitely I will have to rewrite some code to make it better (it's very buggy and crude), because at the moment I have nothing that would recalibrate legs at specific points (if this is even the way it's done??) in time or position so they eventually go out of optimal timing, even more so if I change directions of walking and walk very fast). If anyone has experience in programming walking gaits and has any valuable knowledge to share on how to go about programming such thing, I would be very grateful!

When I'm done with implemeting the walking, turning etc. I will add some sensors to it  (oh yeah and a piezo speaker for sound fx! I have one ready waiting to be mounted) and make it (more) autonomous. I'm thinking a PIR sensor for starters, only because I already have one, and have never used one. Probably I will use it as a motion detector, to put a robot to "sleep" when there's no activity in the room.

Built with:
8x hextronik hxt900 (9g) servos (actually 7, one was replaced by tower pro sg90, because the gears broke, I think it was my fault :) ),
Arduino Uno,
selfmade arduino servo breakout shield,
wii wireless nunchuk (Sweex brand),
5x 1.2V rechargable AA batteries,
1 project box,
homemade servo brackets (3mm plastic),
couple of screws, nails and some hot glue

Cost to build: Around 100 € (for now)

I'm sorry for the low quality video, it was recorded on a phone, then compressed when emailed to myself and compressed again on youtube. I have a bunch of the older ones (first prototypes, the wired control etc.), I can upload some more if you want. I will upload some photos of details as well.
Sorry for the long essay without head and tail. I hope somebody got through all that mess. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Yes, What I would do is have variables which will hold the current amount of movement for a particular leg-joint.

What I mean here is, Let's say your servos center with 150 and travel between 75 and 225 (typical but not always true for all servos). One way to turn would be to load your servo movement variables (high and low) with different start and end numbers.

You want to turn right.

Left legs must swing further than Right legs, so we first set up / assign some  sample variables:

; right_hip_max = b0

; right_hip_min = b1

; left_hip_max = b2

; left_hip_min = b3

there will be a lot more of these to cover all the joints on all the legs, but you can also use the same variables for both legs on one side.  To keep it simple, I used the variable letter/number labels rather than names in the following



let b0 = 225

let b1 = 75

let b2 = 225

let b3 = 75

goto WalkForwardRoutine



let b0 = 185

let b1 = 115

let b2 = 225

let b3 = 75

goto WalkForwardRoutine


I think you can see from this example, that the same walk-forward routine can be used, but the limits of movement will change according to what routine calls it.  The calling routine sets the movement limits; the movement subroutine (WalkForwardRoutine in this case) executes the movement according to those limits, sending those numbers to those joints. You can see that this will result in a curved path if called by the MediumRightTurn routine, and a straight path if called by the StraightForwardWalk routine.


Now as to your question about the legs being caught in mid-movement, there are a couple different ways you could handle it.

1) you can only return to the calling program after the legs have all completed their movement, -however this won't always work for all gaits.

2) I recommended storing variables that keep track of where each leg joint is in its movement. I've been working a lot with the picaxe 28x2 (new style) and I know that it allows 256 variables (0 through 255), but those above 55 have to be stored with a "poke" command and retreived with a "peek" command.

256 variables should be plenty, but if they are not enough to store all the different bytes of data you may need, there are other options. There is scratchpad memory, or there is also the option of using something like i²c memories (for up to 512K bytes of add-on memory).

Knowing where each leg is, when you enter a different movement subroutine,will easily get you where you want to be with a minimum of superfluous movements.  If one leg is raised, the subroutine can go to the closest position in its own gait to that position and go from there. Just move that leg to where it needs to be to match the closest position.  It is sort of like when we are running and have to either swerve or jump to avoid a pile of doggie doodoo that suddenly appeared in our path.  There may be some wasted motion, but it can be minimized if you already know where all four legs are at a certain time.

Hope that explains it well enough.

Dan M.


If I understand you correctly you are proposing exactly the same solution I have right now so I guess no way around repositioning the legs before changing the gait style. I still think that the option of specifying the time in which to arrive at the destination position for each leg is the right way to go, so this is the next improvement I will try to add. 

Thanks for all the effort!

sd21 servo controller hmmm...  where can I get it and is it programable with picaxe basic?

im thinking about a 4 leg robot but want to use a picaxe that can control at least 12 servos do you know of a chip maybe 40x1 but is there a board that works with the 40x1? 

You should try the SD21 servo controller. You can control up to 21 servos and also you may use the picaxe 18m2 chip inside of it for your other needs. I have one and I must say it is a blessing: easy as hell to control + adjustable speed. What more could a man ask for? :D

That seems like a perfect place for me to post a little poem I wrote recently.  I called it The Roboticist's Delusion.


The Roboticist's Delusion
       By Dan Mickle
The roboticist's delusion
That he could build a fusion
Of a girl and an extrusion
At last brought him effusion
As it led to this conclusion:
While her body showed confusion
Her bright eyes brought the allusion
Of an angel in seclusion.

Hope all enjoyed it.  It was a spur-of-the-moment thing, but I think it is acceptable.

Hahaha Dan, It's awesome! :)

Roboticist and a poet... I love it! :)

Thank you.

I think I wrote my first poem when I was about 10 or 11 years old, About 2 dozen lines long, it was a poem to my mother on Mother's Day. I remember she said she didn't like the mushy ones that you typically see on greeting cards, so I wrote her a funny one. While I spent over forty years in technology, (mostly electronics) and have a degree in quantum physics, since I retired I have been trying my hand at writing novels.  (Science fiction with real science behind it.) Now if I could only sell them  -ha ha

I have only written a handful of poems.

Dan M.

what would happen if the right legs went foward and the right went back would it turn nicely? or what?

Yeah that's how you turn, but with the timing you see in the first video where there are only two legs supporting the body, it would just trip over... especially with my current weight distribution, where I have one big heavy 6-battery-holder of batteries in the middle of the body. Current gait is good enough for fast walking, but not well suited for turning. If I change the gait to crawl gait (always 3 legs on the ground), it would definitely work.