View Full Version : [Project] Ally -My First Hexapod Project

02-26-2010, 08:20 PM
Hello everyone!

I have been a lurker on this forum for quite some time (BTW, you guys are incredible) and I have decided to track my progress on my latest project here. I had been posting in my blog, but have come to realize this area (the project shocase) is a far more appropriate place.

I am building a pheonix/micromagic inspired hexapod that will primarily be a testbed for different computer vision and AI concepts I am working on. My goal is to make him as autonomous and aware of his environment as possible. My senior project consisted of a camera on a lynxmotion pan-tilt rig controlled by a phidget advanced servocontroller which tracked peoples faces using OpenCV. This uploaded data to a webserver about what it viewed. So my first goal with Ally is to use the core of that project as the foundation for this one. My parts list as of now:

6 HS 225MG
8 HS 485HB
6 HS 645MG
(all servo choices are subject to change without notice;))
9 Multipurpose Brackets (Servo Erector Set)
1 "C" Bracket
1 1.2G Wireless Surveillance Camera
SSC-32 Servocontroller
BlueSmirf Bluetooth Modem
2.4 GHz Duck Antenna
6.0 Volt 1600mA NiMH Battery
2 9 Volt Recharge-ables
Battery Harness
Lots of 1/8" (3.175mm) Polycarbonate

I have all of my parts together (finally) and have produced a shrine to robotics on my bedroom desk. Needless to say, my girlfriend will not be as thrilled as I am to have this monument to geekdom less than three feet from where we sleep ;)

I went through some major design changes to my chassis after someone pointed out a few flaws to my original design. So I have done a quick and dirty layout in Sketchup of the new chassis. Any comments/criticisms would be most appreciated!

02-28-2010, 02:35 PM
So I have the chassis cut, and am working on the legs. I also have the coxa joint assemblies just about put together. Thinking about mounting the pan-tilt mechanism for the camera on the front of the chassis. However if I do that I loose the higher POV (which could be important). Mounting it on the front would give it a more organic feel, but would also shift its COG pretty drastically, and may unduly tax the front legs servos. I could just give it a pan head, which would minimize this by eliminating a servo and a bracket. I guess I have to weigh the pros/cons of each more carefully and take care not to loose my focus on why I am building this in the first place. So I have held off on cutting the mount for it until I get a little further along.

If anyone is thinking about using polycarbonate or it's derivatives (Lexan, Plexiglass, etc.) you should check out these links below:



They have some good basic information on tools and techniques, especially for finishing cut pieces and how to work through curves. Bless the case-modding community :)

I'll get some pictures up soon. Wrapping up some essays for my college transfer apps (ugh) is eating up a bunch of my time.

03-05-2010, 12:16 PM
Okay guys its been awhile since I updated here. Progress is coming along smoothly (albeit slowly) on the construction. I'm still wrapping up my college apps for transfer and it's eating a lot of my time. So I managed to "sneak" into the Marine Biology workshop here on campus and use the tools. No sneaking about it actually... I'm the programmer for the schools MATE team again this year. So instead of building the ROV, I was working on my hexapod. ;)

So I mounted a grinding stone on the drill press running at 2500RPM and used it to rough out the femurs. It worked surprisingly well on the poly. I didn't have any melting issues, and once I figured out the gist of it I started cruising along nicely. The nice thing about using the tinted polycarbonate is you can see right through it. I had a scale drawing I could hold the piece I was working on to and check out how I was doing.

I'll be back in the workshop tonight and will have more pics up later.

03-05-2010, 01:25 PM
Looking good! Thanks for the pictorial build process :D

03-06-2010, 12:01 PM
Thanks Tyberius! That means a lot coming from you. :D

So I learned a few new things about working with polycarbonate, and I have a few more shop pictures to post. What I learned (the hard way) was that a little heat might be a good thing but too much heat is really bad when grinding it. Normally what I have been doing it grinding a section at a time, give the stone a chance to cool just a bit, and then grinding a different section. When the stone is just a bit warm it seems to grind better. However, when I was working out the curves on the body I ended up letting the stone get a bit too hot... The picture speaks for itself ;) Luckily it was an easy fix (both the stone and the body).

So the lesson learned:
*When using powertools with polycarbonate, have more patience than what is normally required!

Anyway, it turned out fine and you can see the before and after shots below. Now that I'm this far along I will try to get some pictures of the body with some of the hardware mounted in the next couple days.

I also need to start working on converting Phidget AdvancedServoController code into something an SSC-32 can understand. Why reinvent the wheel, when I already have my pan-tilt mechanism coded to track faces with OpenCV, right? I'm hoping that won't be too much of a problem. Programming is my strongpoint. I also have a framework for the IK but I need to actually begin implementing it into code. Now that I'm this far along in the construction, I can work on it more and have some meaningful progress because I will have a platform to test it on (yay!).

Never built a bot entirely on my own before... It has always been as part of a team, and never anything like this. You know what?

....This is ridiculously fun. :)

03-06-2010, 09:35 PM
Putting the grinding on a drill press is a pretty cool idea. Low-tech, but effective.

03-08-2010, 08:19 PM
Thank you! Whatever works, right? ;) I've been busy the past few days and I managed to find a few more interesting ways to use a drill/drillpress, as you will see.

I also managed to cover myself in toothpaste :) Let me explain...

I had all of the femurs and main chassis roughed out, and the edges were, well, rough. So I used a 60 grit sandpaper drum mounted on a handheld to clean them up. After that, a 120 grit. Now this is where the toothpaste comes in. I had read on a case-modding site that toothpaste acts as a great finisher/polisher because it contains mild abrasives. I think to myself, "Why not?" and grab a tube of Crest, a buffing head for the handheld, and go outside. Well, I was a little too liberal in applying it, and managed to cover a 4 x 4 meter area in toothpaste spray, with little 'ol me getting the worst of it. Hence, no pictures of that escapade, as I was way to sticky to touch a camera. The funny thing is that it worked beautifully! The edges are nice and smooth (smoother than when the poly came from the factory, in fact). For anyone thinking about doing this, all you need is VERY little toothpaste ;)

I used a drill to punch a hole in the chassis for the pan-tilt assembly, and then used sandpaper to smooth the edges. Again, it worked supprisingly well, if only a little labor-intensive. I was concerned I would crack the poly working close to the edge like that, but I have found that by taking my time and applying minor amounts of pressure that the poly seems to undergo very little stress.

Now I have the coxa assemblies and the pan-tilt mounted. I still need to get around to making the cutaways for the tibia sections, and drilling holes in the femurs to mount them on the servos. I submit these pictures for approval. How's it looking so far, guys? :D

03-08-2010, 09:48 PM
Nice work so far! You really need a jigsaw or better yet a band saw and a scroll saw. They would save you a ton of time.

03-18-2010, 07:47 PM
Thank you for the compliment, and what I wouldn't have done for a jigsaw! Alas the poor college student dilemma strikes again ;)

It's been awhile since I updated so I shot a quick video update to share with you all. I'm on spring break, so I have a ton of time to work on this



Look for some good build pics here soon as well

03-18-2010, 07:57 PM
What I just realized from posting this video on YouTube is that the word Ally (as in the singular form of Allies) is spelled the same as the name Ally (as in Ally McBeal). That was totally unintentional...Guess I just figured whether Ally is a boy or girl!

03-18-2010, 11:18 PM
Cool work, can't wait to see that thing walking around. It is such a minimalist design. have you thought about adding a bottom plate to hide the batteries? Seams like it would take a bit of the strain off of the hip X servos.

I really admire your work with the plastic you are using. That seams like way more precision cutting and drilling than I could ever hope to accomplish without cracking anything.

Keep us posted


03-20-2010, 08:45 AM
Thanks DB! I really appreciate it. I have been a huge fan of Squidword, Charlie and your from scratch bracket system- it was an inspiration for me in deciding to try and build Ally's chassis myself :)

Part of the minimalist (almost naked) design came from not being sure just how successful I would be working on the polycarbonate. My original thoughts were plexi or aluminum, but they were dropped in favor of poly. The plexi was to flexible and I really didn't think I had the tools to work the aluminum. Poly was a nice compromise between the two in workability and rigidity. I hadn't worked with it much besides a few proof of concept tests, so I wanted to keep it as simple and somewhat elegant as possible.

Now that I am this far along I have been toying with the idea of a bottom plate again. It would be helpful in many ways.

03-20-2010, 03:48 PM
I would suggest the bottom plate as well. Your using Poly as the body and thats going to flex to much with out the bottom plate as you get it up and walking.

03-21-2010, 10:24 PM
You guys have convinced me. I'm beginning to play around with a few designs for a bottom plate now. :)

Some good news: I have the Bluetooth up and running. Mystery solved! I couldn't for the life of me figure out what I was doing wrong. It would make a connection, but the SSC wasn't receiving any of the commands I was sending over the terminal. After taking a break and coming back to work on it, I realized I accidentally was plugging the TX on the SSC going into the TX on the modem, and vice versa with the RX... Oops! I guess that's what happens when you work on something for too many hours straight without a break. ;)

Also, here are some build pics I never got around to posting. One is of my makeshift stand (yes, that is a candle) and the other is how mounted the legs. By the way, should I be updating my first post with all of the pictures and video I have been taking?

03-22-2010, 08:07 AM
To make a bottom plate you could just mirror the top plate and connect it straight through to the standoffs. The servos would need a pivot point. I have used the plastic inserts from shelves (that hold a shelf in a bookshelf) before and they work great. Just attach them to the bottom of the servo with double sided tape.

03-28-2010, 07:50 PM
That is a really good idea! I am hunting around for those pegs now. I'm sure some will turn up. This coming weekend is supposed to be beautiful (like 80 degrees farenheit... Unheard of in Maine in March! :)) so there could be some yard sales I could check out.

I have been terribly busy which is why I haven't posted an update lately. I have also been trying to wrap my head around the kinematics involved in a dynamic gait engine for a hexapod. Let me tell you: instant headache, but I love it. I have worked out a program that (as near as I can tell) calculates target coordinates on an XY plane for each leg given a particular distance through which each leg should travel. Right now it only works for a straight line and has no safety built (in terms of mechanical limitations of each joint, and in terms of each leg to the others). I'm finishing up adding that functionality, as well as coordinate plotting for a curved walk. As soon as I finish this I will post the source code and executable if anyone is interested. Or, I could also post a tutorial on how to find these coordinates... What do you guys think? Would you like to see a tutorial about that? Or my source code?

I am a little confused about one thing in terms of the IK's execution- what I know is that typically dynamic IK solutions are updated so many times a second, and move through a period of cycles. What I have been realizing is that it seems like there is an obscene amount of number crunching to be done. There needs to be a way of optimizing/simplifying the equations so that they are manageable on the fly. I have just started looking a Xan's Pheonix code as well as WGhost9's Axon code... maybe I can figure it out by looking at their amazing work. All the same, if anyone has any insight they want to share I would appreciate it.

I have a block of time tomorrow where I can really hammer out some more on this, and could potentially post something tomorrow night. Let me know what you think.

04-14-2010, 10:41 AM
Ally Teaser Video:


Note: I just uploaded this, so YouTube might still be processing it. If it doesn't work, try back in a few minutes

I'll post some technical details tonight :D

04-15-2010, 11:06 AM
The Update:

What you are seeing in the video is Ally's facial tracking ability. Mathematically it is rather simple, if a bit of a pain to get calibrated just right. What's happening, you might ask?

*Ally snags a frame from the camera's video stream, and converts it to a black and white image for the Haar Classifier.

*Ally finds the face in the image, and draws a bounding rectangle around it. In terms of optimal settings for OpenCV's cvHaarDetectObjects() funtion, I have found that a scale of 1.1, 25 minimum neighbors, and the flag CV_HAAR_FIND_BIGGEST_OBJECT tends to minimize false detections. If you want clarification about what I'm talking about, just ask.

*Ally then calculates the center coordinates of that rectangle, and uses the width of it to estimate her distance away from the face. This works because most faces are roughly the same size.

*Based on the location of the center coordinate of the rectangle from the center of the camera's view (a.k.a. the error), Ally adjusts the pan/tilt mechanism that the camera is on to keep the face centered. Also, based on the width of the bounding rectangle (a.k.a. the distance), Ally adjusts the coxa servo's position to lean forward or backward to try and keep the distance the same.

That is what you are seeing in the video. My next step is to get Ally to walk when either the distance gets to short or to large, or when the face is about to leave her point of view from the right or the left.

The Challenges I'm Facing

The challenges I am running into with this are both mechanical and logical:

Mechanically I am finding that my design of the femur allows too much twisting. This is evident when Ally is up on three legs; the third leg of the tripod tends to bend. My solution is to reinforce the femurs with a "splint" of polycarbonate. This is effectively doubling it's torsion resistance (although don't quote me on that- I'm not a materials expert... I got that information second hand) while adding a minimal amount of weight. Other than that, I am finding the the servos are more than powerful enough, and the poly isn't flexing anywhere else; even under a full payload. It is all so effective that I had Ally doing one legged pushups the other day :)

Logical challenges are with the implementation of the IK for walking. I *think* I have the math put together on this one. Up until this point, I have abandoned two attempts at coding it so far and am about to try my third. My problem is with the implementation of the mathematical formulas into code. Before I try my third attempt, I am posting two word documents (one with my equations, one with a graph labeling all of the angles) to show you all what I am working with. Right now it is purely a geometric and trigonometric approach. In terms of my math background, I have a semester of Calculus under my belt but I am quick to pick up new things. If someone with hexapod IK experience could weigh in on them and tell me what I am doing wrong or what I could be doing better I would greatly appreciate it!

So that is where Ally is at! I hope you like it, and I would really appreciate the community's help with the IK :D

04-15-2010, 02:15 PM
So that is where Ally is at! I hope you like it, and I would really appreciate the community's help with the IK :D

If you repost in a regular doc file (not Word2007 docx) I'd take a look at it -- but I can't get the images to show up in open office for this docx file.


04-15-2010, 04:19 PM
Thanks Inxfergy! I really appreciate it! I have uploaded the same files in .doc and .pdf formats. The conversion from .docx to .doc made them a little less readable, but they are still okay. The .pdf's are perfect renditions of the originals.

I apologize to anyone who had that same issue who tried to look at them for not thinking about that ahead of time.

Pi Robot
04-16-2010, 08:12 AM
I am really impressed with your face tracking! I am also using OpenCV to do face tracking and I generally find that the person has to be facing the camera pretty much head on to be detected. Is this also your experience? Even using the parameters you suggest, a slight tilt of the head or rotation toward one side can cause the Haar detector to fail. Do you see this as well?



Ally Teaser Video:

Note: I just uploaded this, so YouTube might still be processing it. If it doesn't work, try back in a few minutes

I'll post some technical details tonight :D

04-16-2010, 09:17 AM
Most of your equations are more forward kinematics style. To get this turned into a program, you'll have to remember that the angles are the unknowns, and proceed from there.

So, first thing is going to be turn this from a 3D problem into a 2D one, by solving for theta. I would recommend thinking about theta in terms of the tangent function, Xb and Yb. There is a common function called atan2 which is typically used to find theta, given Xb and Yb. So, a single function gets you theta (sweet!).

Now that you have theta, you have two links and two joints left to place (and they are in the same plane), which are your red leg lines:

You would typically then find OB using OB^2 = (L1^2 + L2^2)^(1/2). OB, L1, and L2 form a plane, which all our calculations are now on.
Now, we notice that the same atan2 function could be used to find alpha (based on Zb and the length of the horizontal projection of OB).
You can then solve for (alpha + delta), because you have all three sides of your triangle -- and then subtract the alpha value you just determined to find delta.
And now, you have a function to describe phi in your sheet (as acos of a really nasty set of numbers).

At that point, you have your values for your servos!


04-16-2010, 12:21 PM
I am really impressed with your face tracking! I am also using OpenCV to do face tracking and I generally find that the person has to be facing the camera pretty much head on to be detected. Is this also your experience? Even using the parameters you suggest, a slight tilt of the head or rotation toward one side can cause the Haar detector to fail. Do you see this as well?



Thank you! :D I have noticed this problem. The parameters I suggested are specifically targeted to reduce false detections and return the largest face in the image, but won't do anything about this. The problem has to do with the Haar classifier you load. OpenCV provides a few default XML files to choose from, each one very good at what it is supposed to find (as we have found out). The problem is they will ONLY find what they are meant to find. In my case (and I'm guessing yours too), I'm loading frontal_face_alt.xml or frontal_face_alt2.xml.

This problem can be solved to a certain extent by training your own classifier. This means hunting down a set of training images. There are many facial recognition databases out there which are available. What I have found is that most of the quality databases are available through universities, and that you need to get in direct contact with the professors to have access to them. Fortunately, Yale has one freely available of over 5000 images which I have downloaded. It includes partial profiles (up to 40 degrees of center) and many different lighting conditions. Training your own classifier with this set may help to alleviate the "profile problem." The database, called "Yale B" can be found here:


...and an example of the images in that database is here:


Some things to keep in mind about this:
*There are other databases out there which might work better.
*Training a classifier might take days, even on newer machines, if the database is large enough.
*The more you try and have your classifier multi-task, the worse it may be at any one thing. The saying "Jack of all trades, and master of none" applies here. You may increase your false detection rate by trying to have it recognize too much.

I hope that helps!

================================================== ========================


Thank you very much for taking the time to look at my equations, and for your explanation! That makes a lot of sense :D I am going to attempt to implement this into code, and will post it as soon as I am done. It's kind-of funny- I sat down trying for IK and ended up with FK. I had to laugh at myself when you pointed that out!

I'm a rookie when it comes to trying to articulate something like this. I really appreciate your help!

04-17-2010, 01:04 AM
Again, I have to thank you Inxfergy :)

Given your perspective I was able to narrow down that big mess I had into comparatively few lines of code for my walking engine today. Once I get it cleaned up I'll post my results!

Pi Robot
04-17-2010, 09:29 AM
Thanks Parallax! That makes perfect sense. And thanks for the links to the Yale faces database. Yes, I am using the frontal_face_alt.xml file with the OpenCV Haar classifier. It sounds like one strategy might be to train several classifiers, one for each basic type of face orientation. Another option would be an artificial neural net (OpenCV's ANN_MLP class) or principle components (OpenCV's EigenObjectRecognizer class). So many options, so little time!


07-15-2010, 09:54 PM
Hey all! So It's been a *long* time since I updated this thread... Been wicked busy finishing up school, participating in the MATE competition and so on and so forth. I got rejected as a transfer to Carnegie Mellon University (my dream school...*sigh*), but was accepted as at Worcester Polytechnic Institute(yes! :-) ). I'm double majoring in computer science and robotics engineering there.

So I will finally be able to take classes specific to robotics- I don't know if you have any idea how much that excites me!

Anyway, I did manage to get Ally walking about, and I have videos. I'll get those posted later tonight when I have a decent internet connection. However I have quickly realized that there are several design flaws in her chassis and hardware. These are:

-Chassis Flex: The one sheet of poly I used for her main chassis allows for too much flex. I have tried reinforcing the major flex points, which helped alleviate the problem to a certain extent, but it still is noticeable when she walks; especially in a tripod gate

-Unbalanced Payload: Her weight distributing is "all-kinds-of-funky" (according to my friend). This contributes to the flex problem mentioned above. Also, her battery is a tight fit underneath the chassis- especially when she gets to walking.

-Mechanical Restraints: Her legs are spaced at uneven (though bilaterally symmetrical) points along her chassis. this means that each leg has a radically different range of motion from the others.

-R/F Interference: I discovered this one by accident. I took Ally to one of my school's labs to show her off, and could barely get a signal from her wireless security camera. It took a minute to track down the problem, but we narrowed it down to the vast amount of cell-phones, laptops, and a wireless access node inside the lab all transmitting at once (this is what you get when you pack a room full of geeks I suppose). This might be a one time fluke and there may be no way around it, but I figured it was important enough to list here.

So here is my to-do list:
-Redesign her chassis
-Find a smaller battery pack
-Investigate options for a new wireless camera system

For rebuilding the chassis I haven't given up on polycarbonate entirely just yet. I may try two pieces of poly: an upper "deck" and lower "deck." For the supports/struts between the two decks I have been playing around with the idea of using balsa wood for its strength to weight ratio. I will also explore the option of aluminum, although I am still lacking a decent shop to work it in.

Right now, I am using a 6 volt NiMH 1600 mAH battery pack to supply power to her servos (this one here: http://www.lynxmotion.com/Product.aspx?productID=331&CategoryID=48). This is turning out to be far bulkier than I would like. Any suggestions for a better option? :-)

For the wireless camera I am looking into something like a WiFi enabled webcam... the wireless security camera I have right now is nice because of its size. I may not need to replace it, but if there is a comparable option out there that doesn't require the use of a video capture cable I will consider it.

I guess that's it for my update! I'll have those videos up later. I also promised a while back to post source code at some point- I need to clean it up and comment it better before I do that- right now it's such a mess that it's embarrassing! :-P

07-16-2010, 07:59 PM
Here is the long promised and eagerly awaited video of Ally's first steps. I have made some significant improvements since this video was shot, but you can clearly see here the problems I highlighted in my last post. Once I address some of those problems (such as redesigning her chassis) I will shoot an updated video of her refined IK engine as well as put her through some of her paces. She just isn't ready for that yet!

Here is the video:


Note: This video is meant to be humorous!

07-17-2010, 03:23 PM
Looks like you only have one deck. Make a second, lower deck and that should improve the chassis strength and give you a place for electronics or batteries as well as lowering your center of gravity. You should also shorten the standoffs on your electronics. As for the battery, I would suggest a LiPo. They are smaller and lighter for the same amount of power. Only downside is you will most likely have to do some voltage regulation. The only way you will get a lighter NiMH pack is if you cut down on cells (and battery life).
For a WiFi camera the mech wars guys are using the Trendnet 110w for its small size, weight, and cost. That may be an option for you, otherwise i have never had good luck with those wireless security cameras like you have.

07-17-2010, 04:30 PM
I appreciate your advice! I'm definitely going with a second deck for the chassis, for all of the reasons you stated. I was originally going for a minimalist design, but I have come to realize given the materials I am using that one deck is not a feasible solution. The high standoffs were a temporary setup while I finalized the placement of all of my electrical components.

The wireless security camera was something I had access to at my initial build time. It allowed me to cut costs- but its beginning to show its limitations. I am going to look into the Trendnet as an alternative; I have a little more of a budget nowadays!

Also, the LiPo will be a much better alternative to my current battery setup.

I'll get some new build pics up in the next couple days with the changes I have made... I guess it will be Ally v2.0! :D