Monday, 30 April 2012

Eyes and a Head

I now have cameras working and a robot that can move around. A week or 2 ago I built a prototype sensor platform, but now it's time for the real deal. Well, another prototype for the real deal. Actually another 2 prototypes for the real deal. But my latest prototype rocks! It's time to take those 2 LinkSprite cameras and mount them on their own axis, on top of a head with a proper neck.

After much pondering, I decided one of the keys to cuteness is the eyes, and crucially that they can each swivel on their own axis just like human eyes do. That doesn't mean they'll move independently (which would be creepy), but they need to rotate just like eye balls do. So looking left means each eye turns left on it's own axis. Human eyes can actually look up/down/left/right, but that would be really tricky, so I've decided to focus on just horizontal movement.

I start off by making a very simple prototype with absolutely no planning whatsoever. The cameras need to be mounted on something, so I build 2 small square frames out of balsa wood. As always, I can't find any suitable bolts with which to attach the cameras, so I improvise, and paper clips become my preffered means of attachment. They work ridiculously well, and I gain a new found respect for the wonder of paper clips.

Early prototype eye frame with cameras rotating around an axle made of a bendy metal rod

Next up, I glue a small bit of wood to the back of each camera mounting and drill a vertical hole through which I stick a bent piece of metal somebody left on my desk (when I sent an email round asking for bendy pieces of metal).

Rear view of prototype, with paper clip lever mechanism to make eyes rotate in unison 

Now building on my new love of paper clips, I straighten 2 out and attach them so they stick out of the back of the wooden mounts and can act as levers. When the levers are pushed left/right, they cause the wood to rotate, which in turn causes the cameras (aka eyes) to turn left and right. As one final step I use another paper clip to join the 2 horizontally (the yellow clip above). Now when this horizontal bar is pushed left or right, both eyes will rotate in unison!

The mechanism is wobbly, but it proves a point. This was still Saturday night and I'd done a hard days debugging of camera code, so I decide to end it there and ponder how to build a proper frame over a good nights sleep...

Ok, through the magic of writing it's now Sunday and I have a good idea of how this mechanism actually needs to work. The wooden camera mounts are good, but the pivots need to be directly above and below the cameras rather than behind them. First things first, I load up visio and properly design the camera mount with measurements and everything:

This new design will be much more robust, as the cameras are held on from above and below. They'll still be attached to the same wooden mounts, but I will attach these to a frame with some small metal axles. To turn the eyes I'll use a lever mechanism driven by a mini servo (taken from John's ex-radio-controlled-helicopter) which will be glued to the same frame.

So, armed with a design, I cut up some bits of wood to build the initial frame:

Eye frame cut and axles attached to the camera mounts, ready for fitting together

You can see it taking shape above. The small 'axles' are simply pieces of an aluminium rod someone gave me earlier, chopped up with my Dremmel (causing a lot of sparks). It's not too interesting but I'm proud of my metal cutting, so here's a photo of the chopped up axles:

My beautifully cut aluminium axles (plus my lovely Dremmel)

Right. I have my frame and I have my axles. Time to glue the axles to the camera mounts, create a couple of holes in the frame, add some washers and check things rotate as expected.

Eye frame put together with servo mounted in the middle

As you can see here, everything fits together just right (thanks to actually designing it in advance), and I glue the servo in between the 2 cameras. A subtle but crucial point is that the servo lever is positioned so that it's pivot is at the same depth as the pivots for the 2 cameras. This keeps things simple, as I'll get a 1-to-1 relationship between servo rotation and camera rotation.

Next up, I canibalize some more of John's old helicopter, which is full of handy levers that are strong and have adjustable lengths. I attach small pieces of wood to the back of the camera mounts, drill tiny holes in them and glue 2 of the shortest levers so they stick out the back. Next, I extend the servo lever using another paper clip, bent to fit rigidly through the holes on the servo lever.

Helicopter levers and paper clips to make rear mechanism that turns the eyes

All I need now is to take a couple more of the levers from the helicopter and attach them horizontally so they meet in the middle and join the extended servo lever (aka paper clip). That's the basic mechanism built - if I twist the servo lever left or right, it forces the horizontal lever left or right. This in turn pulls the levers attached to the mounts, which then rotate on their axles. The frame isn't actually held together by anything yet, but aside from that I have a working eye frame.

Next up, I effectively just build a box around the working eye frame, which turns it into a more robust and properly held together head. This is a pretty crucial point, as it'll be hard to dismantle if I get things wrong so before going ahead, I retest both cameras and the servo. All seem to be good so I build the head and wire it up to my Arduino Uno and write a simple program to get the eyes looking around:

Now for a neck. I learnt from my earlier experiments with the sensor platform that it's entirely possible to build a 2 axis system using 2 servos. However the servos need to be as low as possible, ideally both below the sensors (so they don't obscure anything). With this in mind I decide to go for the simplest possible design, and pretty much attach 2 servos to each other with a single piece of wood.

Servo attached to wood, with second servo disk embedded in wood and way too much epoxy resin! 

You can see here 1 servo glued to some wood with epoxy resin, and another servo disk embedded in the wood and glued in with rather too much resin. All I need to do is attach the servo disk to the second servo, and I have a 2 axis neck.

Finally, I take a large, flat piece of wood and cut out the shape of a servo disk to attach the upper servo. This flat piece of wood is then bolted onto the bottom of the head as you can see below:

Fully constructed neck and head

The bottom servo makes the head look up/down, while the upper servo turns it left/right. On top of that is the head itself with the eye frame and it's mini servo to turn the eyes left and right.

Some more epoxy and an Aluminium A-frame later, I have the neck attached to the front of MmBot:

Neck and head attached to MmBot

I was admittedly winging it a little bit at this point, but everything's gone fairly well so far. The only minor hindrance was that the bolts to attach the A frame needed to go through one of the aluminium reinforcements on the inside of the robot. Dave doesn't mind a bit of drilling in the background though, so I get out the old Black-And-Decker and attach a metal drill bit. In not too much time it's all bolted together and is pretty solid.

Just one more step... time for some testing! I connect all the servos to the prototyping board inside MmBot and run a simple test program to set the servos to random positions. Here it is in action:

And there you have it! A full blown 2 axis neck, controlling a head with independently mounted eyes. Let no man look at MmBot now and say she isn't cute!

What a great day :) Next up I'll get the cameras wired into the Arduino and start sending signals via blue tooth to/from the pc. Shouldn't be long before MmBot is combining  fully articulated joints with cameras and face detection to make eye contact with real people!


1 comment:

  1. Ive been thinking along this line bur realized that if a system of cameras used for range finding like human eyes use (one eye points directly at the target and the second converges to the same point.) and also the eyes behind some sort of protective cover, the lense must be directed from a point behind the lens not at a point behind the camera.