21 Dec 2011

"Stalker" -- Quadruped Robot Project


Quadruped Robot Project -- The Stalker

Inspired by the fighting unit "Stalker" in Starcraft.

Project has been re-created and being maintained on this page:



What I need:

1. Arduino Mega
2. 12 - 14 Servos
3. Wii Nunchuck controller
4. IR sensor or Ultra sonic sensor
5. a few styrene sheet (skeleton)
6. 4xAA batteries

Plan:

1. design the skeleton of the robot, build with styrene plastic sheet.
2. Build a single leg with 3 servos, and write a class for single-leg motion.
3. figure out a way to control the leg (probably using buttons) without reprogramming it every time.
4. Assembly the whole thing.

-------------

5. learn how to use a Wii Nunchuck.
6. use it on the Stalker.

-------------

7. learn how to use wireless module, and use it on Wii Nunchuck controller. (probably need a extra Arduino to be the transmitter)
8. use it on the Stalker.

-------------

9. IR/ Ultra-Sonic automation



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

1. Design of the Skeleton


Body



Legs


Hips











Single leg Test:




===================================================
24/12/2011

And here we have all the legs and the base:








Now everything is ready, but the 'brain' of the stalker to arrive from China.
I will use UNO for testing and write some code in order to save time.

This one demonstrate the simplest thing it can do, "breathing":



This uses sine wave multiplying factors:




realise the increase of the leg angles has to be proportional to the hip position. (first order derivative?)
To calculate the angles that the servo needs to turn, we can do calculation shown below, and it's got a fancy name "inverse kinematics" (that's only the basic of the theory, need to dig deeper when developing the gaits)





Code template so far:


void setup(){

     calculate parameters;
     attach servos;

}

void loop(){

     calculate position;
     update position;
     delay;

}


===================================================
26/12/2011

So the stalker are currently being controlled by UNO, only the legs and hips servos are used (8 in total). 

It works with the "Breathing" coding. But it has a very very obvious disadvantage: The servos are not powerful enough (as they are only $3 each). Well, that's a great lesson to learn. Also, the plastic legs and base isn't strong enough as it kind of bends and shakes a bit when it's moving. One thing I can do is to weld some more plastic pieces to back it up.

However, occasionally when I send out varying PWM signals (trying to change the positions), the legs just folder up, and stopped moving.

When I disconnected at least 4 servos, and re-uploading the code, everything seems to be normal again. I am wondering if that's something to do with the timers. Let's have a look at how to control multiple servos with timers: 

Maybe I should write my own servo lib to make them more effiicient, and workable.

Also, to move servo position, i should probably compute all the values (positions) and store in an array, and drive the servos from data.

Some tips about updating the positions of servo: don't use delay as it is a block execution, but milli(), to keep track of past time, so loop can still continue and do other stuff.



===================================================
27/12/2011


This is the updated code template:

parameters declaration;


void setup(){

     calculate parameters;
     calculate positions and store in array;
     attach servos;

}

void loop(){

     int curTime = millis()

     if (curTime >= servoTime + servoDelay){
          servoTime = curTime;
          update positions from array;
     }

     if (curTime >= otherTime + otherDelay){

          do other things;
          ...
     
     }

}



26/12/2011

So the stalker are currently being controlled by UNO, only the legs and hips servos are used (8 in total). 

It works with the "Breathing" coding. But it has a very very obvious disadvantage: The servos are not powerful enough. Well, that's a great lesson to learn. Also, the plastic legs and base isn't strong enough as it kind of bends and shakes a bit when it's moving. One thing I can do is to weld some more plastic pieces to back it up.

However, occasionally when I send out varying PWM signals (trying to change the positions), the legs just folder up, and stopped moving.

When I disconnected at least 4 servos, and re-uploading the code, everything seems to be normal again. I am wondering if that's something to do with the timers. Let's have a look at how to control multiple servos with timers: 

Maybe I should write my own servo lib to make them more effiicient, and workable.

Also, to move servo position, i should probably compute all the values (positions) and store in an array, and drive the servos from data.

Some tips about updating the positions of servo: don't use delay as it is a block execution, but milli(), to keep track of past time, so loop can still continue and do other stuff.



parameters declaration;


void setup(){

     calculate parameters;
     calculate positions and store in array;
     attach servos;

}

void loop(){

     int curTime = millis()

     if (curTime >= servoTime + servoDelay){
          servoTime = curTime;
          update position from array;
     }

     if (curTime >= otherTime + otherDelay){

          do other things;
          ...
     
     }

}


So, realized that the servo is definitely  not strong enough. To do a gait smoothly, I will have to let the robot balance on only 3 legs. I have been thinking to get some more powerful servos, but they seem to be so expensive. If I was going to get some better ones, I will definitely need some with torque of 7kg/cm or above, but that would cost me £15 each at least!!! oh my gosh.

As it's turn out to be a cash burning project, I will first try to reduce the moment (physics) by reducing the distance of the force from the mass center, see if that would help balancing the body better. If not, I will get some new servos, and at the meantime look around for aluminum legs and body. ; )

done a bit of servo research:

Hitec HS-5645 MG (£30)

Dimensions (mm): 20.0 x 41.0 x 38.0
Weight (grams): 60.0
Speed (sec): 0.23
Torque (Kg.cm): 10.30
Ball Raced: Yes

TowerPro Servo MG-995 (£10)

Size: 40.6mm x 19.8mm x 37.8mm
Weight: 62g
Operating Speed: 0.13sec/60degree (6.0V) 0.17sec/60degree (4.8V)
Stall torque:15.0kg/cm (6.0V) 13.kg/cm (4.8V)

(But not a very good, accurate servo, in most cases, it overshoots, and not centering properly.

see reviews for details:
http://www.rcgroups.com/forums/showthread.php?t=442171
also this
http://www.rcuniverse.com/forum/m_8500712/anchors_8500712/mpage_1/key_/anchor/tm.htm#8500712

Hitec - HS-645MG (£23)

BearingSpeed (4.8V/6.0V):0.24 / 0.20Torque oz./in. (4.8V/6.0V):107 / 133
Torque kg./cm. (4.8V/6.0V):8.0 / 10.0
Size in Inches:1.59 x 0.77 x 1.48S
ize in Millimeters:40.39 x 19.56 x 37.59
Weight ounces:1.94Weight grams:55

These three seem to be the reasonable ones. MG995 has good torque compared to the price, but with the reviews on the Internet, as what people say "I would rather spend some more money on realiability now than saving a few quits, which will pay off in the long run".

So I will probably go for the HS 645MG... asked one of the buyers on eBay, see if I can get a deal if I order a dozen.


===================================================
30/12/2011

So this is what i did to try to reduce the force on the servos when it's standing:
1. shortened the legs, enhance strength of the legs.
2. re-built body and brings legs closer to the center.
3. made body with double layer plastic (was only single)







I think it actually looks better personally, and the robot can do more moves without falling down and twitching as often. But still, the servos are just too weak and can't do the walking. It's so frustrating and I have decided to only focus on the coding and look for new servos and parts (possibly aluminium rather than plastic).

This video is probably the last one I will upload showing the 9g Servos.... .v.



====================================================
31/12/2011

Update: decided to delay the purchase of new servos and the quadruped robot. will use 12 9g servos to build a hexapod first, and write a VB program to control arduino from the PC through serial port.

I will write a new post about the lastest work soon.