Showing posts with label Spiderwheels. Show all posts
Showing posts with label Spiderwheels. Show all posts

Friday, February 26, 2010

Spiderwheels: Golden Ratio...

Lately, in the back of my mind, I have felt that there was something visually wrong with my spider. Finally, the reason for wrongness clicked. I didn't incorporate the golden ratio. I've heard about this ratio from several sources lately. The most in depth source I remember was from NOVA: Secrets of the Parthenon. You may be able to still catch it on hulu. Wikipedia also has a pretty good overview of the golden ratio. My understanding is that this ratio has been known for a really long time and can be thought of as the mathematical equivalent for beauty and is around 1 / 1.6. Here is the golden ratio found in the Vitruvian Man:



As you can see, from navel to foot is 1.6 times the distance from navel to head. There are an enormous amount of other examples found in nature and architecture, but I will leave that for Wikipedia. I decided to apply this ratio to my spider in two ways. First, I decided to make the tibia 1.6 times the length of the femur, as shown.



Second, I decided to make the circuit board 1.6 times longer than it is wide. To tie it together I made the width of the board the same length as the tibia. Here are some renders of before and afters. I am in the process of printing the new parts.







For me, incorporating the golden ratio into the design makes it pop. I am interested in how others feel, as well as in whether the golden ratio has influenced robotics design before.

Sunday, February 21, 2010

Spiderwheels: first steps...

I am a perfectionist, which is not always a good thing. I have had the hardware needed to make my long anticipated spider for months. However, I was focused on doing it right the first time. I was focused on designing a pcb and making it on my mill. I finished designing the board weeks ago, but my mill is still not ready.



I decided a simpler proof of concept was well overdue. This weekend I buckled down and drank a lot of Red Bull. I finished printing the parts I needed for the legs, I cut and stripped the wires, and I hooked my sanguino up to a breadboard.



Connecting all 18 servos alone took hours.



Snapping the legs together took longer than expected, too.



But the finished product, though only a proof of concept, gave me chills. I have been awaiting it's completion for many months.



Extending the firmware to support all six legs, as well as writing the walk sequence took several hours. Every time I dig this deep into c++ I end up having to re-conceptualize pointers. The sequence could still use some tweaking, and some of the parts could be more exact, but it moves!!



I am still excited to see the more robust solution I envisioned, but I am still months away from that. In the mean time, since I have STL files from the printed parts, it wasn't much trouble to render an animation of what it should look like after the prototype phase.

Sunday, February 14, 2010

Spiderwheels: the third dimension and circles...

If you've been following this blog you'll know that I did most of the math needed for spider movement several months ago. However, to keep it simple I left out a dimension. Where once I only considered D and H I now need to consider x, y, and z.






This weekend I pulled the equations back out in order to add the third dimension. Thankfully the previous equations could remain unchanged with the realization that:

D = sqrt(x2 + y2).
H = z.

Thus, I could still use these equations:

a1 = 180� - tan-1(D / H) - cos-1( (L12 - L22 + D2 + H2) / (2 * L1 * sqrt(D2 + H2)) ).

a2 = cos-1( (L12 + L22 - D2 - H2) / (2 * L1 * L2) ).

The third and final piece of this puzzle is an equation for the angle a5. Simple trigonometry gives us:

a5 = tan-1(x / y).

I've also been working on building out custom servo / leg libraries for my arduino. In order to prove that the equations for a1, a2, a5 work together fluidly and that my libraries are coming along I ran this expression:


void loop(){ 
  // circle
  for(float i = 0; i<360; i = i +0.9){
    goTo((70+(24*cos((i/180)*PI))), (0+(24*sin((i/180)*PI))), 30);
  }
}
void goTo(float x, float y, float z){
  int i;
  for(i=leg1.findNeededPulses(x, y, z); i>0; i--){
    leg1.pulseToPosition(x, y, z, i);
    delay(10);
  }
}

It simply draws a circle of radius 24mm at a height of 30mm. Here is a video of it in action:

Saturday, December 19, 2009

Spiderwheels: eyes...

I have been putting a lot of thought into how to make the head of my spider and finally settled on a simple proximity sensor from SparkFun with two degrees of freedom. It is always good to start with a proof of concept and so I wired it up to my breadboard sanguino. I basically made it pan until it finds an obstacle and then nod. Here is a video:



Here is the source code:

#include <Servo.h> 
Servo zServo; //rotates about z
Servo xServo; //rotates about x

float zPos = 90; //keeps track of position. 90 degrees is resting.
float xPos = 90; //keeps track of position. 90 degrees is resting.

int milisecondsBetween = 20; 
int vMax = 300;

int sensorPin = 0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  zServo.attach(13);  // attaches zServo object to pin 13 
  xServo.attach(12);  // attaches xServo object to pin 12 
  Serial.begin(19200);
}
void loop() {
  goLeft();
  goRight();
}
void goLeft(){
  float z = zPos;
  sensorValue = analogRead(sensorPin); 
  while(sensorValue < vMax && z > 50){
    z -= 10;
    moveTo(xPos, z);
    sensorValue = analogRead(sensorPin); 
  }
  if(sensorValue >= vMax){
    sayHi();
    printV(sensorValue);
  }
}
void goRight(){
  float z = zPos;
  sensorValue = analogRead(sensorPin); 
  while(sensorValue < vMax && z < 130){
    z += 10;
    moveTo(xPos, z);
    sensorValue = analogRead(sensorPin); 
  }
  if(sensorValue >= vMax){
    sayHi();
    printV(sensorValue);
  }
}
void printV(int v){
  Serial.print("v: ");
  Serial.print(v);   
  Serial.print("\r\n");  
}
void sayHi(){
  moveTo(90, zPos);
  moveTo(110, zPos);
  moveTo(90, zPos);
}
void moveTo(float x, float z){
  while(xPos != x|| zPos != z){
    if(xPos > x){
      xPos -= 1;
    }
    else if(xPos < x){
      xPos += 1;
    }
    if(zPos > z){

      zPos -= 1;
    }
    else if(zPos < z){
      zPos += 1;
    }
    zServo.write(zPos);
    xServo.write(xPos);
    delay(milisecondsBetween);
  }
}

Saturday, November 14, 2009

Spiderwheels: How to bootload a breadboard sanguino...

Now that I have a leg constructed it is time for me to focus my attention on the circuit. I have decided to base my circuit design off of the sanguino by Zack Hoeken. I made this decision for three reasons.


  • I want to stay close to the arduino community in order to leverage all the open source work that has been done.

  • There are no surface mount parts in the design, which is good because I want to keep this at the beginner level. It's also good because I want to prototype on a breadboard and SMT doesn't play nice with breadboards.

  • It has enough pins. I need at least 18. I want 27. The sanguino has 32.

I put in orders for all the parts I need for two sanguinos, as well as a USB to TTL cable and a USBtinyISP bootloader last week. I was really lucky that all the orders came in last night.

First, I soldered together my USBtinyISP kit.



Then I followed this tutorial to construct a breadboard sanguino for prototyping.

I was a novice to AVRs and the inner workings of the arduino family of boards as of last night so I was naive enough to think that it may be possible for the bootloader to magically go onto the AVR chip when you load the firmware for the first time. Nope. I got the "avrdude: stk500_getsync(): not in sync: resp=0x00" error.

Though I was naive enough to try it I was smart enough to have already made a USBtiny bootloader. However, how do you plug the USBtiny into the breadboard sanguino?



As you can imagine this was an intimidating problem! Remember, I was a novice. It's not that the information isn't provided. Technically, all you need is the schematic of the USBtinyISP and the schematic of the sanguino to figure it out. Still... I am kind of surprised that the sanguino website doesn't say much about bootloading. I mean... this is an open source project. Furthermore, arduino bootloading tutorials are hard to come by in general. This got me thinking. Why are there no / very few tutorials on bootloading? Is it to encourage people to buy their kits which have already been bootloaded? Is it because bootloading is too technical for the average arduino hobbyist to understand? Is it because no one really cares because they have no desire to design an arduino variant on their own? Maybe it's just that no one took the time. Definitively something to think about. I welcome thoughts on this.

It took me two whole hours to check and double-check my work before I felt comfortable plugging in the USBtinyISP. Here is what you need to do if you want to bootload an ATmega644P on a breadboard with a USBtinyISP.

USBtinyISP ICSP (1) goes to (b16)

USBtinyISP ICSP (2) goes to (b19)

USBtinyISP ICSP (3) goes to (b17)

USBtinyISP ICSP (4) goes to (b15)

USBtinyISP ICSP (5) goes to (b18)

USBtinyISP ICSP (6) goes to (b20)


Now, assuming you have followed the tutorials on how to get your computer to recognize the USBtinyISP and you have successfully installed the arduino app + sanguine files, the next step is to plug in your USBtinyISP. Then open up your Arduino application, select board > sanguino, select burn bootloader > USBtinyISP and wait 5 to 10 minutes. I didn't think it would take that long but I resisted the urge to unplug it and try again. It worked the very first time with patience.

I just burnt a bootloader on a fresh chip! Now I can plug in the USB to TTL cable like this:



and burn some firmware. I successfully uploaded the blink program to the ATmega644P chip before writing this.

I hope this is of use to someone.

Saturday, November 7, 2009

Spiderwheels: snap...

Now that I have decided to use the smaller servos I have been redesigning my spider leg parts to accommodate the smaller servos. I recently had a burst of creativity. I realized that I can design these parts to snap together, instead of requiring fasteners. Here is an image and a video of the the snap together design.




CNC parts printed on a RepStrap from gavilan on Vimeo.

Saturday, October 31, 2009

Spiderwheels: smaller servos...

Wow, it feels like forever since I've blogged. I learned how to design circuit boards a few weeks ago. It is a lot easier than I thought it would be. While I was waiting for some new bits to come in the mail I started working on my Spiderwheels project again. I've been experiencing issues with my netbook since I got it and just recently found out what was wrong with it. It looks like the graphics card is overheating under normal use and cannot run for more than 20 minutes. I was really upset at first. I'm over it now. EBay is not always the best option.

Considering the netbook I got for this project is non-functional I have decided to look into building a smaller robot without the burden of the 2 lb netbook. This idea hit me when I stumbled across these servos. They weigh 9 grams and cost $3.50. Compared to what I was spending for the larger 55 gram HiTec servos, +/- $30, these are a steal. I went ahead and ordered a few to do some benchmarking. So far I am very impressed. I want to construct a leg and get a feel for accuracy before ordering more. With these prices this project may well produce a six legged walker from the start.

Here they are side by side:



Here is a close up of the 9 gram servo:





Sunday, October 11, 2009

Spiderwheels: I have so much to learn...

I realize this is my first robotics project and I should stick to wire nuts and breadboards but I want to learn as much as I can from this project. Frustratingly enough, this means I must take several steps back and pursue PCB fabrication. I built a mill and am getting close to being able to mill boards. The next step is learning how to design them. This is a very overwhelming subject for me and it is hard to know where to start. I have decided to go with Eagle as my layout editor mainly because the RepRap team uses it and this is all I have to go on when it comes to board fabrication. So, I guess the first step is to follow some tutorials. I have chosen this tutorial because it will also serve as an introduction to the FT232RL chip, which is used in the Arduino. Time to learn.

Saturday, August 22, 2009

Spiderwheels: motion...

Here is a video of a proof of concept I put together.


movement experiment of spider leg... from gavilan on Vimeo.


The materials are minimalistic and only for this experiment. You can clearly see that the leg is cycling through (D = 2, H = 3), then (D = 8, H = 3), then (D = 8, H = 4), then (D = 2, H = 4), then back. With two legs mounted on the front of my robot, this would be enough to propel it forward 6 inches per touch down.

Here is the source code:



#define servo2Pin 2
#define servo3Pin 3

int i;

void setup(){
  pinMode(servo2Pin, OUTPUT);
  pinMode(servo3Pin, OUTPUT);

  Serial.begin(9600);
}

float l1 = 4.5;
float l2 = 6;
float d,H;
void loop(){
  H = 3;
  for(d=2;d<8;d=d+0.2){
    for(i=0;i<1;i++){
      goToAngle(servo3Pin, hipAngle(d, H, l1, l2));
      goToAngle(servo2Pin, kneeAngle(d, H, l1, l2));
      delay(20);
    }
  }
  H = 4;
  for(d=8;d>2;d=d-0.2){
    for(i=0;i<1;i++){
      goToAngle(servo3Pin, hipAngle(d, H, l1, l2));
      goToAngle(servo2Pin, kneeAngle(d, H, l1, l2));
      delay(20);
    }
  }
}

int kneeAngle(float d, float H, float l1, float l2){
  return ((acos((l1*l1 + l2*l2 - d*d - H*H)/(2*l1*l2))*180)/PI);
}

int hipAngle(float d, float H, float l1, int l2){
  return 180 - (atan(d/H) + acos((l1*l1 - l2*l2 + d*d + H*H)/(2*l1*sqrt(d*d + H*H))))*180/PI;
}

void goToAngle(int pinNumber, int angle){
  if(angle <= 180 && angle >= 0){
    sendPulse(pinNumber, (600+(angle*9.72)));
  }
}

void sendPulse(int pinNumber, int pulseWidth){
  digitalWrite(pinNumber, HIGH);
  delayMicroseconds(pulseWidth);
  digitalWrite(pinNumber, LOW);
}


Fun stuff! 50 or so lines can do quite a bit!

Spiderwheels: algebra, geometry, and trigonometry...

I've been wanting to build a spider robot for a log time. I remember looking around the internet years ago to see if other people have done this. One project really stands out in my mind.



You can read all about the how on Zenta's blog.

The fluid movements of Zenta's six legged robot has inspired me to really put some thought into the mathematics behind the movement of a spider before I get too far with design and coding. After a few days of diagrams, equations, and some proofs of concept I have come up with some trigonometric functions that describe a subset of the movement of a spider. Now, let's dive in.

Consider the following:




Yes. That is correct. Spiders have legs. Now, consider the following:




A picture says a thousand words. What I am trying to convey with this one is that the joints that make up the leg of a spider have ranges of motion. At one given point in time the position of this leg can be described by two angles, i.e. the hip and knee, angles. These angles are key because they are "servo speak".

Now, wouldn't be good fun if we could describe the position of the leg in terms D and H in the following diagram?




Considering I will be building these legs I will know L1 and L2. So, given L1, L2, D, and H, how do we find a1 and a2.

The first step is to find k. According to Pythagoras, a2 + b2 = c2.




So...

k2 = D2 + H2
k = sqrt(D2 + H2).

Once we have k we can use the Law Of Cosines to find a2.

k2 = L12 + L22 - (2 * L1 * L2 * cos(a2))
cos(a2) = (L12 + L22 - D2 - H2) / (2 * L1 * L2)
a2 = cos-1( (L12 + L22 - D2 - H2) / (2 * L1 * L2) ).

Similarly, we can find a4.

a4 = cos-1( (L12 - L22 + D2 + H2) / (2 * L1 * sqrt(D2 + H2)) ).

We also know that

tan(a3) = D / H
a3 = tan-1(D / H).

Finally, we can solve for a1.

a1 = 180� - a3 - a4
a1 = 180� - tan-1(D / H) - cos-1( (L12 - L22 + D2 + H2) / (2 * L1 * sqrt(D2 + H2)) ).

In my next blog entry I will show a video of some proof of concept work, as well as share the source code that makes it all happen.

Sunday, August 16, 2009

Spiderwheels: a step in the right direction...

If you've read some of my other blogs you will know that I have been attempting to get into robotics since I graduated college in 2008. This journey lead me to create my own 3d printer with help from the RepRap team. Though I am still working to improve the quality and speed of my prints I have passed the point where it requires intellectual work. I must move on. With what I currently know about robotics (which isn't a whole lot) I've put together an idea for my first robot. This project should sharpen my abilities in writing c / c++ applications under Linux. It should give me an introduction into streaming image processing, skin detection, face detection, and potentially face recognition. It will also be a good project for getting experience using micro-controllers, and servos. Finally, and I'm not 100% sure on this, it may be a good platform for starting an open-source project.

Now that I've laid out all of these very lofty goals let me step back and describe the project that I have envisioned and where it came from.

Every interesting robot has the following characteristics:

  • sensors

  • a brain

  • interaction

In terms of hardware this implies processing power, motors, camera... among other things. I've spent quite some time thinking through the best platform for my first robot when I stumbled across the following:



Above is a picture of an MSI Wind U100-420US Netbook. The amazing thing about a Wind is it weighs 2 lbs and can be purchased off the shelf for under $300. I was fortunate enough to find one on ebay for under $200. Built into this machine is a 1+ hr power supply, 1.6Ghrz processor, 1.3Mpix webcam, mic, speakers, wifi, and a 10 inch screen. Thus, this machine alone can supply a large amount of portable computing power, vision, hearing, speaking, wireless communication, and visual expression. The only gaping hole between this machine and an interesting robot is interaction. This is where my new friend the adruino microcontroller comes in.



This micro-controller is opensource and inexpensive. It is also really easy to program. I know of it because it is the brain for the Reprap. Micro-controllers, among other things, can tell servo motors what to do. A few lines of C, and a bunch of these



and you can have pretty cool interaction. My end goal is to build a six legged spider with these parts, but the servos alone cost $30 a piece. Considering three are needed per leg your are looking at a bit of saving up. I am going to start with only two legs and some wheels.