## Wally Kinematics

### Wally Kinematics

I'm revisiting the Wally kinematics, and somehow they're no longer making sense to me. If you refer to the Python code and the inverse kinematics PNG file Nicholas posted, I no longer understand how the equations for the "elbow angle" (angles C and D on the drawing) are calculated.

Looking at this now, it seems like the elbow angle should vary between 0 and Pi, but the equations generating this angle with the acos function will only generate values between 0 and Pi/2. Also, the value fed to acos seems to be attempting to calculate a length using a^2 + b^2 = c^2, but there's no square root function.

So am I loosing my math skilz, or does this really not make sense?

I've switched my inverse kinematics to calculating the small angle using acos(leg length / 2x arm length) and then calculating C & D using C = Pi - (2 * small angle), which seems to generate OK results, but I can't test for sure since I've got some other issues going on with the control software (related to not having forward kinematics available).

I've also made some progress on the forward kinematics, but I don't have anything actually working just yet. Holler if you're interested in helping and I'll post what I've got so far.
cdsteinkuehler

Posts: 74
Joined: Tue Nov 26, 2013 1:53 am

### Re: Wally Kinematics

I too have been looking at the Wally kinematics ever since I found out about it.
So far what I have gotten is something along the lines of

C= 2*Asin(Sqrt(X^2+Y^2)/2l)
E= atan(-Y/X)
G-E {depicted on the diagram as (pi-c)/2} = Acos(Sqrt(X^2+Y^2)/2l)

Using the variables of http://forums.reprap.org/file.php?185,file=18866,filename=wally_diagram2.png
Not sure yet if that is simpler than what's being tried or not.
I also have no Idea how to code that at all. I am at best an amateur mathematician.
bloodyshadow13

Posts: 5
Joined: Tue Feb 03, 2015 6:17 pm

### Re: Wally Kinematics code
Code: Select all
`...        left_leg=math.sqrt(x*x+y*y)        right_leg=math.sqrt((L-x)*(L-x)+y*y)        left_elbow=math.acos((left_leg*left_leg-2*l*l)/(-2*l*l))        right_elbow=math.acos((right_leg*right_leg-2*l*l)/(-2*l*l))...`

I don't exactly follow your problem. You can see above that I use sqrt. Additionally, acos will return a number from 0 to pi so that will match reality.

I should also note that the diagrams variable names were named in the order that they are solved for. a and b are needed for c and d. etc.
Nicholas Seward

Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

### Re: Wally Kinematics

The only sqrt is in the calculation of a and b, which appears correct.

I'm confused by the calculation of c and d. Let's talk about c.

By inspection, the angle c can be between 0 and 180 degrees (or 0 to Pi rads). Since c is calculated using the acos function, in order to cover the desired range, the value fed to acos needs to be between 1 (returns c=0) and -1 (returns c=Pi). I do not see how the term (2l^2-a^2) / 2l^2 can ever be negative, since there is no way for a to be longer than 2l.

I switched to directly calculating the small angle [(Pi-c)/2 in your drawing] using acos:

small_angle = acos ( a / 2l )

...then calculating the elbow angle (c) as:

c = Pi - ( 2 * small_angle )

Am I missing something in how you're calculating c and d? I remember being confused by this when I first looked at it, but then I convinced myself it was correct...looking at it again I'm no longer able to figure out how it's supposed to work. :-/
cdsteinkuehler

Posts: 74
Joined: Tue Nov 26, 2013 1:53 am

### Re: Wally Kinematics

To calculate c I use law of cosines. I have all three sides l, l, and a. a_max=2*l

(a_max*a_max-2*l*l)/(-2*l*l)=((2*l)*(2*l)-2*l*l)/(-2*l*l)=(4-2)/(-2)=-1
(a_min*a_min-2*l*l)/(-2*l*l)=(-2*l*l)/(-2*l*l)=(-2)/(-2)=1

Does that help?
Nicholas Seward

Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

### Re: Wally Kinematics

Thanks!
Yes, that helps, and I remember why I was confused previously.

The equation in the drawing is wrong (2l^2 - a^2) but it's fixed in the code (a^2 - 2l^2).

I lost the sheet last year with all the notes on it and forgot about this issue, and I was working from the equations on the drawing.
cdsteinkuehler

Posts: 74
Joined: Tue Nov 26, 2013 1:53 am

### Re: Wally Kinematics

I think the drawing is correct. I just take the negative out of bottom.
Nicholas Seward

Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

### Re: Wally Kinematics

<sigh> Sometimes math and I don't get along. cdsteinkuehler

Posts: 74
Joined: Tue Nov 26, 2013 1:53 am

### Re: Wally Kinematics

I've finally figured out the kinematics math (both Nicholas' and my modified version) has been correct all along. The problem I've been having is due to the handling of acceleration and velocity limits in Machinekit (inherited from LinuxCNC). When Wally is at specific locations it can require extreme speeds or accelerations on the joints (the actual stepper motor drive signals) to achieve very reasonable axis (XYZ or "world" coordinates) limits. This is similar to what happens with a delta printer as one of the arms gets close to horizontal. When this happens, the motion system throws "following errors" since the stepper motors can't keep up with the commanded path.

I have "bandaged" over this problem with an ugly hack for the time being, and I now have Wally properly obeying coordinated XYZ moves (including jogging) using live kinematics! I need to give my Wally a bit more love (some wires broke on our last adventure, and I still don't have him 100% back together), but I'll try to get printing and shoot some video soon!

The real fix for this issue is to take both world limits and joint limits into account. There's existing work that addresses a lot of this problem (known as the "joints-axis" branch since it separates mechanical joints from Cartesian axis), but that's still undergoing integration with Machinekit and likely won't be ready for the MRRF.
cdsteinkuehler

Posts: 74
Joined: Tue Nov 26, 2013 1:53 am

### Re: Wally Kinematics

Can't wait to jog Wally like it is a Cartesian bot.
Nicholas Seward

Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

Next

Return to Wally

### Who is online

Users browsing this forum: No registered users and 1 guest 