## Triangle machine calibration constraints diagram

Wednesday, June 3rd, 2015 at 12:33 pm

This diagram is for reference, made using the 2D constraint editor in OnShape and then annotated with gimp, which I really cannot get along with.

Origin at O with y-axis along Y being the side of the table, because we want to solve this by fixing the job to be machined in the fixed coordinate frame and pretend that the machine and tool are swinging all around it.

The blue lines represent the triangular main frame (with three approximately known lengths of about 745mm), the green lines the arm (with two lengths and an angle). This carries the cutter at point P and its triangle pivots at the movable point A1 due to changes in the length of J1 representing the linear position of the ballscrew.

The entire blue triangular frame pivots around the fixed point A0 due to changes in the length of J0. The absolute offsets on J0 and J1 from their connection to the common vertex are also unknown, which means we have a total of 2+3+3+1=9 dimensions which we can vary in our calculation to calibrate. (That last dimension is the length of the fixed edge between O and A0.)

Given these numbers, the conversion code that is inserted into the controller LinuxCNC is here.

```def abanglefromtriangleabc(a, b, c):
return acos((a*a + b*b - c*c)/(2*a*b))

a = 743.5035783400  # sides of mainframe triangle
b = 754.8024952389
c = 745.4991150306

d = 697.7062405262  # length of O->A0
e = 695.5193939239  # length A0->"arm"
f = 583.6487506837  # length A0->P
ah = 0.0764480526      # angle in arm
tblx = 525.4558306022  # offset in j0
armx = 396.1544040232  # offset in j1

ab = abanglefromtriangleabc(a, b, c)
ac = abanglefromtriangleabc(a, c, b)

def convertJ0J1toXY(j0, j1):
tbl = j0 + tblx
arm = j1 + armx

aTBL = abanglefromtriangleabc(b, d, tbl)
aARM = abanglefromtriangleabc(c, e, arm)

avec = ab - aTBL;
pvec = avec + ac - aARM + ah

return (0 - a*sin(avec) + f*sin(pvec),
d - a*cos(avec) + f*cos(pvec))
```

The game we’ve been playing for the last few weeks is to probe a perfectly circular disk mounted on the table with a known diameter, read out a series of joint values J0 and J1 from about 60 different positions, write a function that uses the 9 unknowns to project these measurements into cartesian space relative to O and the axis Y and provide a value of how close we are to having the right circle, and then use scipy.optimize.minimize to pick the values which minimizes this geometric constraint.

Unfortunately, this doesn’t seem to constrain it well enough, for we are getting good fitting solutions where the lengths of the main frame triangle are far from 745mm.

So that’s where we are at this week. I think we’re going to sod the calibration for a little while and just machine some stuff anyway, even if it isn’t perfectly right.