# Thread: Let's Discuss Kinematics, Shall We?

1. ## Re: Let's Discuss Kinematics, Shall We?

Hey Tom,

Squidword is controlled using a wibrain. It is an ultra portable PC, and weighs 1.2 pounds with the battery. I suppose I could lighten it up a lot if I shared the battery with the robots.

As for the Kinematics, I wonder...For me, there is a difference between the number of degrees of freedom, and the actual number of degrees of freedom. For squidwords legs, he uses 3 servos per leg, and while that adds up to 3 dof, the ankle and hip/lift servo both just do the opposite of each other. So he really only has 2 actual degrees of freedom per leg?

DB  Reply With Quote

2. ## Re: Let's Discuss Kinematics, Shall We?

I'm thinking that kinematics and what you appear to be doing are generally not classified in the same definition, DB. That could be part of the confusion.  Reply With Quote

3. ## Re: Let's Discuss Kinematics, Shall We?

Ok, I'm struggling to understand how to make a hexapod roll-pitch-yaw while stationary and/or while it's moving.

I got the "roll" part down by modifying the walking code. Let me start by explaining what's known:

Br=Ag*Gr

Br = Local Coordinate
Ag= Successive Rotation Matrix
Gr = Global coordinate

In order for me to make the robot walk and/or roll, I seed Gr=[Gx,Gy,Gz], where if Gy is non-zero, the hexapod will either walk forward or backwards (depending on the +/- sign), if Gy is fixed to 0 and Gx is non-zero, the hexapod will crab walk left or right (depending on the +/- sign). If Gy and Gx are both non-zero, the hexapod will walk at an angle (but the body is still pointed at the same direction).

In order for it to rotate, I seed Gy with some value, but fix the local "X" coordinate by not adding any contribution from the transformation. For instance if Br=[xx,yy,zz] then:

XX gets added to the length of the legs horizontally
YY gets added to the length of the legs vertically (which the length on the Y-axis of the legs are always zero)
ZZ gets added to the height of the legs (which is always the height offset when the legs are at a 90-degree bend)

What I'm struggling to understand is, if the hexapod's body is at rest at [0,0,0] and not moving, and we want the body to roll-pitch-yaw, would this just be [0,0,0] with some angle phi, theta, and psi, where you rotate angle phi about z-axis, rotate theta about the y-axis, and psi about the x-axis?

Doing so would yield a "0" all the way since:

Br=Ag*Gr = [0,0,0] if Gr=[0,0,0]

I don't understand, when I see roll-pitch-yaw demo from such programs as Powerpod, Zenta's PEP, Xanore's Hexapod Code, and Matt Denton's, are the Gr vector (global coordinate) being seeded with some value during each of the successive rotation?

For instance, do I do a:

Gr = [0,1,0] for some arbitrary first rotation
Gr = [1,0,0] for some arbitrary second rotation
Gr = [0,0,1] for some arbitrary third rotation

---

I guess the second big question is how are you all modeling the body (global) and the leg (local) with respect to each other?

My mistake could be that the two "middle" legs of my hexapod has 0-degree offset with respect to the global coordinate, so I'm assuming that for the two middle legs:

Br=Ag*Gr , where the angle offset is always 0, so the when rotating about say, angle phi, it's always just phi with no offset.

---

Do I need to account for the distance between the Global origin "O" and the location of all six local (leg's) origin "o" ? I'm starting to suspect that might be my problem with all this...     Last edited by tom_chang79; 09-08-2009 at 09:40 AM.  Reply With Quote

4. ## Re: Let's Discuss Kinematics, Shall We?

My take, and how IK is currently implemented on Issy:

If [0,0,0] is the center of the bot, then no rotation about any axis changes that point (the center is still exactly where it was, because we rotated about it!). On the other hand, we have points in space where the legs attach to the body, and where the body touches the ground. Because these leg points are a distance (>0) away from the rotation point ([0,0,0]) a rotation matrix will affect the position of those points.

Thus, given a point where the leg meets the body (I'll call this the Coxa point, [xC, yC, zC], C for coxa, for me Z is the vertical axis and thus zC typically = 0), and a set of rotations about the three axis, you can compute the change in position in space of [xC,yC,zC] which I will call [xR,yR,zR] (R for rotated). Both of these are in body coordinates, relative to the body center. We then have the position of the end effector (the foot), which we'll call [xE,yE,zE], also in body coordinates. Further, we have a gait translation that we wish to apply [xG,yG,zG]. Thus we find that the inputs to our 3dof leg solving equation is:

[xE - (xR+xC) + xG, yE - (yR+yC) +yG, zE - zR +zG]

Which is the distance of the end effector to the coxa point where the leg joins the body. (note, we don't need to take into account zC, since zC=0)

One thing I want to note here is that Xan appears to do this differently, and I'm not sure how much (if any) it changes the results. His phoenix code rotates the end effector and then subtracts out the coxa offsets.

-Fergs

[EDIT: I realized I blundered a bit above, I had said that [xR...] was the rotation of [xC...], I meant to say it was the change that occurs when rotating [xC...], not the absolute position. I've fixed the mistake]
Last edited by lnxfergy; 09-08-2009 at 09:14 PM.  Reply With Quote

5. ## Re: Let's Discuss Kinematics, Shall We?

Thanks Fergs, that was a very well written explanation of what is going on. I guess I was missing that link of understanding how the addition is supposed to happen...

I guess my biggest problem was, I've always assumed that the 0,0,0 was at the tips of the legs that doesn't have any offsets (the middle right and middle left)...

I guess I need to always account for the offset of the legs with respect to the center of the body...  Reply With Quote

6. ## Re: Let's Discuss Kinematics, Shall We?

Yep, all coordinates used during body IK calculations need to be in reference to the body itself. When you then do the 3dof leg IK equations, you typically use coordinates that reference from the coxa servo rotate point.

Note that I've corrected an error in my terminology above.

-Fergs  Reply With Quote

7. ## Re: Let's Discuss Kinematics, Shall We?

Thanks for the clarification. I was a bit confused on why we add the position after rotation to the original position of the coxa.

One big question I have. When you say the coordinate of the end effector E, isn't this coordinate in reference to its respective coxa, which is 0 degrees (locally or with respect to the coxa) for ALL legs, for say a hexapod like the Phoenix, BUT the ORIGIN of the effector, coxa, is 60-degrees offset from the origin of the body?

Another question along the same lines:

The equation:

[xE - (xR+xC) + xG, yE - (yR+yC) +yG, zE - zR +zG]

This coordinate is with respect to the body? Don't we need to calculate L = [Lx, Ly, Lz], where L is the coordinate with respect to its LOCAL origin, its respective coxa, in order to crank it through Leg IK that works for all?

Also, does that equation above assume that:

xG = yG = zG = 0

If the body is not gaiting but just rolling, yawing, pitching (or combination of)?

Here's an example, the coxa location of each "group" of legs (clockwise, starting from "1-o'clock" position) with respect to the origin of the body (center of the Phoenix's body) looking at the mechanical drawing are:

[xC, yC, zC]
Group 0 G0 = [1.6875, 3.234, 0]
Group 1 G1 = [2.4805, 0, 0]
Group 2 G2 = [1.6875, -3.234, 0]
Group 3 G3 = [-1.6875, -3.234, 0]
Group 4 G4 = [-2.4805, 0, 0]
Group 5 G5 = [-1.6875, 3.234, 0]

To calculate each of the leg coordinate, do I first do:

Br = Ag*G0

where Ag = successive rotation matrix, G0, G1, G2 and so on for each respective legs
Br is the resultant local coordinate

After I get Br = [xx,yy,zz], do I then do:

[xE - (xx+xC) + xG, yE - (yy+yC) +yG, zE - (zz+zC) +zG]

(note that I've replaced xR with xx, yR with yy, and added and replaced zR with zz)

for each leg?

I guess to sum up the question, what to do with the legs in the four corners (1-o'clock, 11-o'clock, 5-o'clock, 7-o'clock positions) that have an offset of say, 60-degrees? Do I account for the coordinate for the end effector with respect to each coxa, assuming that the starting point is at 0-degree with the coxa?  Reply With Quote

8. ## Re: Let's Discuss Kinematics, Shall We?

Ok, this concept has been marinating in my head for quite some time. The vector summing you shown me Fergs, was conceptually displayed in one of my dreams a few days ago Here's one thing I don't get.

If "change in position in space of [xC,yC,zC] which I will call [xR,yR,zR] (R for rotated)."

Does this mean that:

Suppose we have this general transformation equation again:

Br = Ag * Gr where is your global coordinate, Br is your local, and Ag is your transformation matrix...

Does this mean that:

Br = (xR+xC, yR+yC, zR+zC)

or did you actually mean this:

Br = (xR, yR, zR)

because I tried this:

Er = end effector coordinate from body
Gr = Gait coordinate from body
Br = coordinate of the coxa from body

I tried to do this:

Er - Br + Gr

but it didn't work... I don't understand?

EDIT:
I guess my question is REALLY this:

if R is the change of C (coxa) position then:

Br = Ag * C

then,

R = C - Br

then, wouldn't:

xR+xC = xC - xBr + xC = 2*xC + xBr

???
Last edited by tom_chang79; 09-15-2009 at 01:05 AM.  Reply With Quote

9. ## Re: Let's Discuss Kinematics, Shall We? Originally Posted by lnxfergy My take, and how IK is currently implemented on Issy:

If [0,0,0] is the center of the bot, then no rotation about any axis changes that point (the center is still exactly where it was, because we rotated about it!). On the other hand, we have points in space where the legs attach to the body, and where the body touches the ground. Because these leg points are a distance (>0) away from the rotation point ([0,0,0]) a rotation matrix will affect the position of those points.

Thus, given a point where the leg meets the body (I'll call this the Coxa point, [xC, yC, zC], C for coxa, for me Z is the vertical axis and thus zC typically = 0), and a set of rotations about the three axis, you can compute the change in position in space of [xC,yC,zC] which I will call [xR,yR,zR] (R for rotated). Both of these are in body coordinates, relative to the body center. We then have the position of the end effector (the foot), which we'll call [xE,yE,zE], also in body coordinates. Further, we have a gait translation that we wish to apply [xG,yG,zG]. Thus we find that the inputs to our 3dof leg solving equation is:

[xE - (xR+xC) + xG, yE - (yR+yC) +yG, zE - zR +zG]

Which is the distance of the end effector to the coxa point where the leg joins the body. (note, we don't need to take into account zC, since zC=0)

One thing I want to note here is that Xan appears to do this differently, and I'm not sure how much (if any) it changes the results. His phoenix code rotates the end effector and then subtracts out the coxa offsets.

-Fergs

[EDIT: I realized I blundered a bit above, I had said that [xR...] was the rotation of [xC...], I meant to say it was the change that occurs when rotating [xC...], not the absolute position. I've fixed the mistake]

I am so glad that Andrew stickied this topic. I have little to no idea what the heck I was doing or was thinking and this thread really served as a "log" of my thoughts about a year ago...

I quoted you Fergs because this point finally dawned on me. It was thinking about what the "change" of the end effector after a rotation that got me thinking that the same "change" is the offset that needs to be presented to each of the legs in order to accomplish the body roll/pitch/yaw.

Example 6 on page 39 of Reza's book really affirmed this notion. It was such a simple example that I often overlooked its implication on our beloved hexapods...

If the entire hexapod was in the air, with the legs at "center" position (found by calibration), after some successive body rolls (center of the body of the hexapod, for the Phoenix with Atom Pro 28 _ mini-ABB, near the pair of Tantalum bypass caps), the tips of the legs will be at an offset (again, the legs have never moved, it's still in its "center" position).

If one were to do a vector difference of the original position and the calculated position after the transformation, you'd get the difference:

Gr = Q * Br

Gdifference = Gr - Br

Where Gr is the new global coordinate, Br is the initial position of the end effector (tips of each leg) and Q is the transformation matrix. Gr, Br, and Gdifference are all vectors (X,Y,Z).

You take the Gdifference, and you tell each of the leg (through the XYZ to PWM converter found out by the closed for trig equation).

I need to start coding this... Ah father time, if only you gave me 25 hours in a day instead of 24 hours... I'd still most likely blow it on sleep...   Reply With Quote

10. ## Re: Let's Discuss Kinematics, Shall We?

I may have missed this, but where is a beginning tutorial on this subject? I am confused about how many legs are being used 4,6,8? Originally Posted by tom_chang79 I need to start coding this... Ah father time, if only you gave me 25 hours in a day instead of 24 hours... I'd still most likely blow it on sleep... (silliness)
Who else here is working 25h/8d/53w a year? (/silliness)

Yours,

SA   Reply With Quote