Maslow 4 calibration, first principles thinking

Given the difficulty that we are having with the calibration calculations, I think it’s worth trying to go back to first principles and see if anyone can think of a better option. (right now, I’m thinking along the lines of defining the appropriate equations and then trying to use a solver on them)

Note that we are also having problems with keeping the belts tight as we move and things like that. Those are a separate problem. This topic is focused on the calculations that we do after we get measurements.

What we can know:

  • a series of measurements of the slant angle from an unknown location to each of the 4 corner anchors
    • we can explicitly make two anchors the same length and see what happens with the other two, we don’t currently do so, but if it makes the math work out, we can do so
      • If the frame happens to be a perfect rectangle, we can make all 4 belts the same length and find the exact center, but is is unlikely that any frame is perfect in the real world.
  • the height of the anchors (with some error, but since there is a shallow angle from the arm down to the anchor, even at the closest approach, the measurement error should be down in the noise)

We can ask for the user to enter frame dimensions, but those are not going to be exact. They are a starting point and may be useful to throw out calculations that are horribly off.

What we can’t know:

  • where are we on the workpiece (with the possible exception of the center, but only if the frame is perfectly square)
  • because we don’t know where we are on the sheet, we can’t know the angles (both in the x/y plane and in the Z direction)

@bar what is the precision of the belt measurements?

IIRC we get ~44mm per rotation, and in theory we are getting 360/4096 or ~0.09 ± 1 degree accuracy, but you take multiple samples and throw out the first couple, then average the remaining ones, which indicates that there is some expected error.

There is also error from belt stretch, and IIRC you have a fudge factor of 5% as well

This doesn’t affect the calculations, but does limit how accurate we can possibly be.

3 Likes

Current process

reading through the code I was pointed at ( Calibration-Simulation/index.html at main · BarbourSmith/Calibration-Simulation · GitHub ), it appears that currently we make a guess at the anchor coordinates, and then walk through all the measurements and see how well they fit the guess, and for each point nudge the anchor guess positions to reduce the error (several passes, with the nudge getting smaller for each pass)

It does this based on line length, which is belt + a static offset (153mm)
There are some functions to correct for tension and Z offset. The tension and scaling functions only change the top two belts, not the bottom ones, so that is a possible source of error between vertical and horizontal frames (they assume vertical and that the only source of tension is the weight of the sled)

3 Likes

I would ask the user to measure between each of the anchor points, including the diagonal measurements. This doesn’t have to be exact, but it does serve the purpose you identified of helping to identify unreasonable values.

a couple thoughts.

Effect of Anchor height offset

using the pythagorean theorem for the belt lengths we have

slope_distance^2 = Z_offset^2 + diagonal_distance^2
or diagonal_distance = sqrt ( slope_distance^2 - Z_offset^2)
(this is in the current calibration as 'project belts onto workpiece surface)

At the corner of the workpiece with a 8x10 frame, a 10mm error in the Z offset translates into a 1mm error in the diagonal_distance
about a foot further in, this is reduced to a .4mm error
In the center, this is reduced to .25mm error
at the far corner, this is reduced to .14mm error

so I think it will make a difference (a few mm of position) if you are calibrating on just the floor (concrete anchors) vs on a 3/4 wasteboard + 3/4 workpiece (~40mm of difference in Z height)

Finding center

We should be able to find the center (by what I think is a reasonable definition of center) by making opposite belts equal length. This cannot be done in a single step, we don’t have enough information about where we start. But if we adjust one pair, then the other, we move closer to the center. Repeat a few times and we should end up very close to the center. I’m not sure how many cycles we would need to get to if we start out in a very odd position, but since the ‘extend belts’ step should be getting us fairly close to start with (as the belts start out the same length before they are attached to the anchors) we should be able to retract opposite corners at the same speed to quickly get to the center

At this point we can call the position of the sled 0,0 and know two circles that each have two anchors on them, one the radius of the top left belt +offset (for the tl/br anchors, call this D1) and once the radius of the top right bel + offset (for the tr/bl anchors, call this D2)

This gives us formulas for the anchor locations of:
tl.x = -1 *sqrt(D1^2 - tl.y^2) or tl.y = sqrt(D1^2 - tl.x^2) (note tl.x is negative)
br.x = sqrt(D1^2 - br.y^2) or br.y = -1 *sqrt(D1^2 - br.x^2) (note br.y is negative)

bl.x = -1 * sqrt(D2^2 - bl.y^2) or bl.y = -1 *sqrt(D2^2 - bl.x^2) (note both bl.x and bl.y are negative)
tr.x = sqrt(D2^2 - tr.y^2) or tr.y = sqrt(D2^2 - tr.x^2)

(4 formulas, 8 unknowns)

If we knew the anchors formed a rectangle, we could also say
tl.x = - br.x
tl.y = - br.y
bl.x = - tr.x
bl.y = - tr.y
but we normally can’t

Next step, move up/right along a line perpendicular to the line from tl/br anchors

If we then feed out some slack to tl and br slowly for a short distance (to a new length D3), while tightening tr (to a new length D4) and feeding out bl at the same speed we tighten tr (to a new length D5) we can keep tl and br the same length (for a perfect ‘standard frame’ feeding out ~2.5mm would let the other two belts move ~100mm if I’m doing the math right)

This gives us some new formulas for the anchor locations of:
D4 = D2 - sqrt(x.1^2 + y.1^2) (edit) NOT TRUE, the ‘center point’ may not be on the diagonals between corners
D5 = D2 + sqrt(x.1^2 + y.1^2) (edit) NOT TRUE, the ‘center point’ may not be on the diagonals between corners
tl.x + x.1) = -1 * sqrt(D3^2 - (tl.y-y.1)^2)
br.x - x.1 = sqrt(D3^2 - (-br.y + y.1)^2)
tr.x - x.1 = sqrt(D4^2 - (tr.y - y.1)^2)
bl.x + x.1 = -1 * sqrt(D5^2 - (-bl.y + y.1)^2)

(adding 6 more formulas, but only 2 more unknowns) edit 4 formulas with 2 more unknowns

also, we know that the line 0,0 → x1,y1 is a right angle to the diagonal between the tl and br anchors.

next step move up/left from center along a line perpendicular to the line from tr/bl anchors

similarly, you could go back to the center and hold the tr and bl belts the same (D6, slightly longer than D2) and move to the top left (D7 to top left, D8 to bottom right) to get two more points that you know are on a line perpendicular to the tr/bb diagonal
(note x.2 is negative)
D7 = D1 - sqrt(x.2^2 + y.2^2) (edit) NOT TRUE, the ‘center point’ may not be on the diagonals between corners
D8 = D1 + sqrt(x.2^2 + y.2^2) (edit) NOT TRUE, the ‘center point’ may not be on the diagonals between corners
tl.x + x.2 = -1 * sqrt(D6^2 - (tl.y - y.2)^2)
br.x - x.2 = sqrt(D6^2 - (-br.y +y.2)^2)
tr.x - x.2 = sqrt(D7^2 - (tr.y - y.2)^2)
bl.x + x.2 = -1 * sqrt(D8^2 - (-bl.y + y.2)^2)

I think that gives enough formulas with few enough unknowns to be solvable
the further the two points are from the center, the better.

Besides the formulas above, we also have now plotted out two triangles that we know the lengths of all 3 sides (D1 - D7, D1, D6)

I don’t know if it is worth it to go back to the center and do a similar movement to the bottom quadrants. If the frame is a rectangle, it clearly isn’t, but I’m not sure when the frame is an irregular trapezoid. Establishing two more triangles may be what’s needed to get the angles/positions of the other two anchors.

But it’s now 2am, so I’m not going to try and plot out sample measurements and try to plug them into a solver tonight (especially since I would have to learn how to run the solver as part of it)

Can someone else with a more up-to-date math background check that I haven’t made any stupid mistakes.

note, edited to fix some of the formulas.

I drafted up a very skewed frame in onshape at Onshape



be aware that the numbers shown are distance, so check the sign for direction

now that it’s almost 3:30 I really am quitting for the night rather than trying to plug in numbers and see if they come out (that would require that I either solve the equasions myself or learn a formula solver, too much for this hour of the morning) :slight_smile:

1 Like


note that this approach does not make the workpiece centered on the available cutting area (note the worksheet was rotated in this image to be parallel to the bottom rather than parallel to the x axis of the drawing)

1 Like


I did the other two quadrents, keeping the equal belts at the same length (p1 and p3 both anchored by tl/br, p2 and p4 anchored by bl/tr)

1 Like

I read an article on GPS a couple weeks ago, and since then I cant get rid of the idea that we’re looking at a pretty similar problem here. Of course, the main twist is that we don’t know the anchor locations whereas the satellite positions in GPS are very precisely known.

However, we’re still looking at an “intersection of spheres” problem. Perhaps it’s worth looking at the equations used in that algorithm.

One thing we do know for sure is that our current position is “inside” the frame (i.e any solution that would give positions above the two top anchors can be safely discarded.

@dlang I really like your idea for finding center, and I think only moving one belt at a time and seeing the effects on the others feels more “right” to me than trying to move to specific coordinates from only a guess.

Also regarding belt slack, could we use the same principle as when we extend the belts manually to detect tension on the belt and only pay out the length that’s needed, as needed?

2 Likes

Thinking about it some more: perhaps one way to simplify the math would be to set the length of the BL belt to something known (let’s say 1 meter). This way we know we’re on a 1m sphere somewhere around the BL anchor. We can then take measurements for all other belts, which gives us there more spheres, centered somewhere on the surface of the first one.

Then we move that BL belt to a new, known dimension (let’s say 1.5m), and repeat. We now have three new spheres, centered on the surface of a 1.5m sphere which itself is centered on the BL anchor.

Repeat again with a new dimension for the BL belt and I think at this point we have enough information to compute the location of all anchors.

I’ve sketched it up here: Onshape (only 2 steps); I’ll try and make a JS demo later.

EDIT: I say the BL anchor because that’s what we defined as the origin so it makes the math easy, but it could very well be another anchor. I think if we go with another anchor, we should still considering it the origin during calibration; we could do a coordinate transform to put the BL at the origin at the end of calibration.

Emile Cantin wrote:

One thing we do know for sure is that our current position is “inside” the frame (i.e any solution that would give positions above the two top anchors can be safely discarded.

yes, the fact that we may have multiple solutions to the problem may mean we
need to be able to throw one out, but I need to have someone check my math and
plug in the numbers for my incredibly skewed frame example to see if we have
enough data points to make it work yet.

@dlang I really like your idea for finding center, and I think only moving one belt at a time and seeing the effects on the others feels more “right” to me than trying to move to specific coordinates from only a guess.

it turns out that equal belts on opposite sides is not the center, but I think
it’s a good starting point.

Also regarding belt slack, could we use the same principle as when we extend the belts manually to detect tension on the belt and only pay out the length that’s needed, as needed?

we are using that algorithm now, the problem is that the weight of the belt can
be enough tension to trigger feeding out more.

David Lang

Emile Cantin wrote:

Thinking about it some more: perhaps one way to simplify the math would be to set the length of the BL belt to something known (let’s say 1 meter). This way we know we’re on a 1m sphere somewhere around the BL anchor. We can then take measurements for all other belts, which gives us there more spheres, centered somewhere on the surface of the first one.

how is a known 1m sphere any better than any other known distance? in my skewed
frame example, the distance from the bl to the sled is known, exactly 2764.183mm

what makes 1000mm or 1500mm on that one belt any better?

I’ve sketched it up here:
Onshape
(only 2 steps); I’ll try and make a JS demo later.

EDIT: I say the BL anchor because that’s what we defined as the origin so it makes the math easy, but it could very well be another anchor. I think if we go with another anchor, we should still considering it the origin during calibration; we could do a coordinate transform to put the BL at the origin at the end of calibration.

I agree that transforming the coordinate system is a step for later. In my
example, I set 0,0 as the point where opposite belts are equal, with the
expectation that everything can be adjusted from there.

David Lang

It’s not any better than any other value. My point is to vary only one belt at a time and observe the effect on the other ones. This makes it so the sled position is a series of concentric circles (or spheres) around the origin.

Even better would probably be to keep one other belt fixed (perhaps the BR belt), so we can know that all measurements are on a circle (or sphere) centered on that other point.

Basically, I’m looking at your equations and I’m noticing a conspicuous lack of sin / cos given that we’re dealing with circles here :wink:

1 Like

Emile Cantin wrote:

Basically, I’m looking at your equations and I’m noticing a conspicuous lack of sin / cos given that we’re dealing with circles here :wink:

for sin/cos to work you need to know the angles, we don’t have any angle
information.

instead I’m working from a^2+b^2=c^2 since we do have lengths.

once we have enough lengths, we can compute angles, but I don’t know if we need
to.

With my approach, Once we do the 4 points around the ‘center’ we now have
isosolies triangles pointing at each anchor point (but without angle information
about how the two sets of triangles are oriented to each other)

I thought about making belts to adjacent anchors the same length and measuring
the other two, but I don’t think we need to do that (or if it would help wihtout
knowing the third side or an angle)

David LAng

Yeah, I haven’t fully written the equations yet, my hypothesis is that the angles will cancel out once you’ve fully solved the equation system. I might be wrong, though, and perhaps staying in the coordinate domain (with pythagore) is best.

1 Like

@WFD any chance that you could apply your excel solver magic to these formulas

I haven’t been following this very closely. What problem are you trying to solve here?

I read through it and it seems you are trying to do the same thing the Maslow already does when it solves the sets of calibration points for frame locations.

As I understand the code, the current calibration takes the guess of where the
anchors are, draws lines from there to a sled location, then decides which
anchor is most out of location and nudges that anchor to a new location for the
next round of guessing

what I’m trying to do is instead work from the center out, find a place where
each pair of belts is the same length, then move from that location in a more
deterministic way where one pair of belts is still kept at the same length (but
slightly longer than the ‘both pairs the same’ center). This should be able to
be done with very little slack required

I’m hoping that by having direct calculations of where the anchors are from the
‘center’ rather than iterating angles and anchor positions to reduce errors, we
can get more accurate positioning from fewer data points, with the only guessing
being how much belt needs to be fed out initially to hook to the anchors.

David Lang

looking at the formulas for tr (where tr.x and tr.y are both positive) we have

tr.x = sqrt(D2^2 - tr.y^2) or tr.y = sqrt(D2^2 - tr.x^2)
tr.x - x.1 = sqrt(D4^2 - (tr.y - y.1)^2) or tr.x = sqrt(D4^2 - (tr.y - y.1)^2) + x.1
tr.x - x.2 = sqrt(D7^2 - (tr.y - y.2)^2) or tr.x = sqrt(D7^2 - (tr.y - y.2)^2) + x.2 (note x.2 is negative)

we can substitute in tr.y = sqrt(D2^2 - tr.x^2) to the other two formulas, which gives us:
tr.x = sqrt(D4^2 - ( sqrt(D2^2 - tr.x^2) - y.1)^2) + x.1
tr.x = sqrt(D7^2 - ( sqrt(D2^2 - tr.x^2) - y.2)^2) + x.2
two formulas, five unknowns, adding additional data points each add one more formula and three more unknowns
working on the other corners gives the same things (although x.* and y.* are reused in the calculation for each corner)

I feel that I’m missing something here.

If the frame was a square (a 12’ square handles a 8x10 workpiece) then the points would line up on the diagonals and are 45 degree right triangles, so we could use:
2*(D4 - D2)/sqrt(2) = x.1 = y.1
2*(D7 - D1)/sqrt(2) = -x.2 = y.2
which substituted in becomes
tr.x = sqrt(D4^2 - ( sqrt(D2^2 - tr.x^2) - y.1)^2) + x.1
tr.x = sqrt(D7^2 - ( sqrt(D2^2 - tr.x^2) - y.2)^2) + x.2

tr.x = sqrt(D4^2 - ( sqrt(D2^2 - tr.x^2) - 2*(D4 - D2)/sqrt(2))^2) + 2*(D4 - D2)/sqrt(2)
tr.x = sqrt(D7^2 - ( sqrt(D2^2 - tr.x^2) - 2*(D7 - D1)/sqrt(2))^2) - 2*(D7 - D1)/sqrt(2)

tr.x^1 = D4^2 - (sqrt(D2^2 - tr.x^2) - 2*(D4 - D2)/sqrt(2))^2 + 2*(D4 - D2)^2 + 2*(D4 - D2)/sqrt(2) * sqrt(D4^2 - ( sqrt(D2^2 - tr.x^2) - 2*(D4 - D2)/sqrt(2))^2)
at this point I’ve made some mistake, the math does not work out. After starting at it for a couple of hours I’ll try again later

On a whim (I’m sure I’m not the first) I asked Gemini about the problem. I don’t know if this helps or is even accurate, but I found it to be interesting anyway. It helped me to think about what the problem is also as it took a few iterations of prompts to define the problem fully (and I’m sure I missed something too)

Prompt

2 dimensional geometry: please solve this problem and show all work. I have 4 fixed points, bottom left, top left, top right, bottom right (L, M, N, O) that I know approximately what their coordinates are. I know there is a line from each of these 4 points to a single meeting point (Q), and I know the lengths of each of the lines LQ, MQ, NQ, and OQ. I also know L is fixed at x=0, y=0 and O is on y=0, but I don’t know x exactly. Q is always within the quadrilateral of L M N O. I can select LQ, MQ, NQ, or OQ and change its length, moving the coordinates of Q and changing the lengths of the other lines, which can then be measured accurately. I can repeat this movement process more than once. How can I solve for the coordinates of M, N, and O?

Response

Here’s how you can solve for the coordinates of M, N, and O:

1. Choose a Line to Adjust:

Since you can adjust the length of any of the lines (LQ, MQ, NQ, or OQ), let’s pick one strategically. We know L is fixed at (0,0) and O is on the y-axis (x-coordinate unknown). Here are two options:

  • Option A: Adjust OQ: This approach is simpler if O is closer to L than the other points. By increasing or decreasing the length of OQ, you can move Q along the y-axis.
  • Option B: Adjust MQ: This approach is better if M is further away from L compared to N. By changing MQ, you can potentially isolate M’s y-coordinate.

2. Measure After Adjustment:

  • After adjusting the chosen line length (e.g., OQ), measure the new lengths of all four lines (LQ’, MQ’, NQ’, and OQ’).

3. Use Ratio and Similar Triangles:

Since you know the original lengths (LQ, MQ, NQ, OQ) and the new lengths (LQ’, MQ’, NQ’, OQ’), you can establish ratios between them.

Here’s the key concept: Even though we don’t know the absolute coordinates, the ratios between side lengths in the triangles formed by the points (L, M, Q) and (L, O, Q) will remain constant regardless of Q’s position.

  • Option A (Adjusting OQ):
    • In triangles LOQ and LOQ’ (formed before and after adjusting OQ), the ratio LO/OQ will be constant (let’s call it k).
    • Since L is (0,0) and O is on the y-axis (x = 0), LO is simply the y-coordinate of O (both before and after adjustment).
    • You can set up an equation using the ratio k and the original and new OQ lengths: LO/OQ = k = LO’/OQ’
  • Option B (Adjusting MQ):
    • In triangles LMQ and LMQ’ (formed before and after adjusting MQ), the ratio LM/MQ will be constant (let’s call it j).
    • If M is further away from L than N, changing MQ might isolate M’s y-coordinate (LM’ can be significant compared to LQ’ and NO’).
    • Set up an equation using the ratio j and the original and new MQ lengths: LM/MQ = j = LM’/MQ’

4. Solve for the Unknown Coordinate:

  • In Option A, you have an equation with LO (unknown y-coordinate of O) and the original and new OQ lengths. You can potentially solve for LO (and hence O’s y-coordinate).
  • In Option B, you have an equation with LM (part of what you want to solve for) and the original and new MQ lengths. You might need additional information (another equation) to solve for LM uniquely.

5. Repeat and Combine Information (Optional):

  • Repeat steps 1-4 by adjusting a different line (e.g., if Option A didn’t isolate O’s y-coordinate, try adjusting MQ).
  • By combining the information from different adjustments (equations), you might be able to solve for a single coordinate (e.g., O’s y-coordinate) and use it to derive the others.

Note:

  • This method relies on strategic selection of the line to adjust and the possibility of isolating a coordinate based on the triangle properties.
  • In some cases, depending on the relative positions of the points, you might need to perform adjustments and combine information from multiple lines to solve for all three coordinates (M, N, and O).

By applying these steps and analyzing the resulting equations, you can leverage the known ratios and relationships within the triangles to solve for the unknown coordinates of M, N, and O.

2 Likes

good ideas in general, but it keeps refering to the ability to isolate one axis,
which shows a misunderstanding of the problem. to move strictly in the y
direction requires shortening MQ and NQ at the same time

David Lang

2 Likes