Update 09-06-2013 I'm considering this project finished.Well maybe I reprogram it one day :p
Made a new video showing Bajdupod 996R doing some fitness outside in the sun :) It show some of the "moves" that I have preprogrammed. In the last bit of the video you can see me moving one leg. I can move each leg individually with my remote control. Took me a lot time to code everything and test it out. My code is over 1000 lines long and one big mess. Maybe I'll clean it up one day and try to improve it.
I've written some more code to let the hexapod walk autonomously. But it's a bit difficult to make a video of it. I still haven't received a new Lipo. The current Lipo lasts less then 7 minutes :p It can now track an IR light source using the WiiCamera or do some obstacle avoidance using the ultrasonic sensors.
This project was a very good programming lesson to learn how to multiple things with one mico controller. Controlling 21 servos, doing some wireless communication, controlling 18 leds and reading some sensors needs a lot of code :) One year ago I did not think I would be able to program a beast like this. But you can accomplish lots with dedication and hard work!
New video showing of the blue leds that I've added :)
My hexapod is now fitted with 21 servos, 18 leds (16 are controlled by 2 shift registers), 2 ultrasonic sensors and a Wiicam :p Now I need to code this beast. It can already walk pretty smooth. All the sensors are connected and work. At the moment I just take the readings and sent them to my remote control. Need to learn it some tricks now :)
During the many test sessions my big Lipo has gone poof :( Now waiting for a new one plus a decent charger. Thankfully I have some spare lipos. But they don't last very long, this is one power hungry beast :p
New video uploaded, let my hexapod loose outside :)
Finally designed a new chassis and had it laser cut by a local company. I had 3 plates made. Between the bottom and the middle plate the battery, UBECs and power servo PCB are fitted. Between the middle and bottom plate the Seeeduino Mega and my Bajduino Mega 3A sit. I chose to use 2 micro controllers just for fun. I have dozens of ATmega's so I might as well use them :) My Bajduino Mega 3A has an ATmega1284P micro controller. It has 2 serial ports which is very handy. One for the serial monitor and one to communicate with the Seeeduino Mega. The Bajduino only does the wireless communication at the moment, the PCB has a header for the nRF24L01 module. I have not fitted the top plate of the chassis yet.
To replace the chassis I had to take the hexapod apart. I put it back together and replaced all the plastic servo horns with metal ones. I then had to check all the servos again to see if they all line up. In the video you can see that it's not walking very straight. So I need to do some adjusting... I also mounted the legs on small bearings that sit inside the bottom acryl plate.
My code seems to run ok. It still has a bug that I can't seem to fix. When I switch between the walking mode and the "move the body" mode strange things happen :p Think I'll rewrite that function so it uses the same timer as my walking function. Still I'm happy with the progress so far :)
Added another video showing my last state of code. I've changed the way I move the servos. All my code is now based on timers. I have added speed control and "bodyshifting". I can select a mode on my remote with a button. So I can choose between walking or moving the body.
Now I have to tackle some mechanical problems. The legs need a lot more grip and I need to design a new bigger chassis. I have received my metal servo horns. Once I have the new chassis plates I'll replace all the horns. It's quite a big job, 72 screws :p
Uploaded third video. Snowed in today so had to stay at home and play with my hexapod. I have changed my massive moveServos function so it moves the servos in little steps. I can now control the speed of the servos. I do use a for loop and the delay function. I've added a second micro controller (ATmega328) with a wireless nRF24L01 module. All my bots have been controlled by these modules so it didn't take me long to program the communication. The ATmega328 receives a struct from my remote control via the wireless modules. The ATmega328 then sends these values via software serial to the Arduino Mega which receives these values over hardware serial. Sounds complex but it's actually very straight forward. In the video you can now see that you can make a hexapod with cheap Chinese servos that can walk smoothly :) Not as smooth as a lynxmotion of course but that has more to do with my code. And it cost me a lot less.
Added the second video, this time of Bajdupod 996R taking its first steps :) After blowing up a couple of expensive 8A UBECs I think I have found a solution to powering the 18 servos. I am now using 3 8A UBECs, each UBEC powers 2 legs / 6 servos. To give you an idea about how current this black monster needs, I had a 10A fuse between the Lipo and the 3 UBECs. It blew up when I tried out the real walking test. So I've replaced it with a 20A fuse.
I have written a basic walking gait to move the hexapod forward, backward, left and right. I'm using inverse kinematics to calculate the servo angles. The code still needs a lot of improvement, I want it to move a lot smoother. For this I'll need to move the servos in little steps. Writing that code for 18 servos is not so easy, certainly as I refuse to use the delay function. That's to easy :) I had a bit of trouble finding out how much I could move the legs and keep the hexapod stable. In the beginning I was moving the legs to far for/backward and that caused the hexapod to fall on it's ass :p Takes quite a bit of time figuring everything out...
- Replace all the servo horns with metal horns (are on the way from China)
- Replace the original base plates with self designed laser cut acryl plates, the chassis I use now is to small, I'll make it a little bigger so I can fit my Lipo and UBECs inside the chassis
- Replace current servo PCB with new version (is on the way from China)
- Replace Arduino Mega2560 with a Seeeduino Mega2560 (Seeeduino version is smaller)
- Write some fancier code so the hexapod moves a lot smoother and I can control the speed of the servos (this will be very hard)
- Fit a second micro controller with a nRF24L01 module so I can remote control it.
- Add a shit load of LEDs and let it dance, Gangnam style :D
Added first video :) I've done some more testing. I've written a sketch were I move all 6 legs (18 servos) at the same time. Lifting 3 legs up and 3 legs down using inverse kinematics. I powered 3 legs from my lab power supply and the other 3 from an 8A UBEC. I'm afraid the servos will draw close to 20A when walking. So I've now ordered 3 more 8A UBECs. I will use 1 8A UBEC to power 2 legs, so 3 8A UBECs in total. I hope that will do it.
I have spent the last weeks trying to figure out how inverse kinematics work. After a big struggle and a lot of head scratching I can now move every leg using inverse kinematics. That means that in my code I can do this: moveLeg1(X,Y,Z). The X,Y,Z is the position of the tip of the leg :) The code will then calculate the angle of each servo and move the leg to the X,Y,Z position. I borrowed a lot of code from this website: http://www.engineer-this.com/IK.shtml Converting the IK angles to servo angles was actually easier then I thought. Using a protractor I compared the calculated IK angles with my servo angles. I still have to do some fine tuning. But the biggest hurdle has been taken :)
Of course I wanted to show of my successful coding and quickly wrote a simple sketch to move all 6 legs at the same time. So I could make a video. Bad luck struck of course and one of my UBEC's has given up. I was powering the 18 servos with 2 8A UBEC's. Each UBEC powers 3 legs. Now I'll be honest when I first tested the UBEC's I short circuited them. They have been working fine till today... Grrr. I then decided to use my lab power supply. I set it at 6V and moved all the legs, the servos were drawing almost 10A. And the servos are under no / a very small load. So I will redesign my power supply circuit. Suggestions are welcome. Current solutions are a 5A UBEC for each leg? I have also seen some 10A 12 to 5V automotive regulators on Ebay, maybe 2 of those will be strong enough? I'm going to put the hexapod away for a bit now till I have found a decent solution. I'm definately not giving up, it will walk :p But I have bought a lot of other toys the last months, I'll play with them for a while :)
I've started building my second hexapod. This time I'm using a Chinese hexapod kit. I bought the kit on Ebay for 90$. It included the parts in the photo below:
I bought 30 Towardpro MG996R servos some time ago on Ebay. They are pretty cheap and have +10kg/cm of torque. I hope they are strong enough :)
I used a lot of M3 nuts and bolts to put everything together. I did some thinking about how I was going to power 18 servos. I decided a big strong lipo and some UBECs were a good solution. I bought 2 8A UBECs. I soldered a fuse and switch to some connectors so I could hook up the lipo to the UBECs. I designed a small PCB (and had it made by Seeedstudio) to distribute the power from the UBECs to the 18 servos. Each UBEC powers 3 legs / 9 servos of the robot. The Mega 2560 is powered by a separate 2S Lipo.
I've now mounted an Arduino Mega 2560 on the robot and hooked it up to my servo power board. I might change the Mega for one of my self designed boards and use a Torobot 32 channel servo controller that I have lying around.
At the moment I have only set up the 18 servos, checking if they work and adjusting the centre position. Takes some time with 18 servos. I hope to write a sketch using inverse kinematics for it. But that will probably take some time.
Another issue I have is that the chassis is a bit on the small side. I might design a bigger base plate for it and have it made from Acryl. So I can attach some more electronics.