Optical Calibration Demo and Three Hours Working on a Bug

I think the linear error is what we see from the slope of the graphs. Typical Maslow calibration errors tend to be a more nonlinear shape right? I would expect a linear graph like this if the X-dimension had a calibration pattern that is a little smaller than expected (which is definitely the case when I measure it)

If there was such an issue, would it not (and I don’t know so that’s why I’m asking) show that if when you scan from left to right you see a down slope then when you scan from right to left you would see an up slope?

If its linear, then I would suggest everywhere something gets multipled by 3 * 25.4, it gets multiplied by 3 * 25.4 * xScale. Then the xScale (and yScale) would also be sent as firmware keys to the controller and the same math is done there. You could do fancy compensation of the calibration matrix in GC, but I think we can do it in the controller without much of a hit.

I don’t think so. Assuming we dial in the center point pretty well (as it seems we do in the graph above), I think that a pattern that’s too close together (<3in on center) would result in positive correction values for the left calibration points (square is to the right – closer to the center point than it should be) and negative correction values for the right calibration points (square is to the left – closer to the center point than it should be).

When you have a moment, it’d be interesting to measure your vinyl banner. I wonder how well-spaced your squares are.

I see what you mean… I think you are correct about that. Any scaling will definitely need to be based upon 0,0 being 0,0 and then working out from there… I’ll go look at my pattern…

Cool I’ll go ahead and wire in my scaling fields for my test tonight.

I’m wondering if we could source a common sign sheet in 4 x 8 material , PVC, and place a vinyl cut pattern on it as a calibration target. This would be obtainable from just about any sign shop.

Thank you

I’m dead on vertically but a 1/4-inch long from the left edge of the left-most square to the left edge of the right-most square. My squares appear to be 0.61-inch x 0.61-inch… that’s not a big deal, but the 1/4-inch scale issue is something that needs to be mitigated. I’ll modify settings and the firmware to work with scale factors in the meantime.

Do you need to modify the firmware? Can’t we just adjust the calibration values in GroundControl by the calculated scale offset?

Meaning, via homing we determine that a square is [1, 2] mm from the machine’s expected point for that calibration value – we can add to the correction value based on the scale.

For example, for square at -2,0 (second square to the left of the home square 0,0). If the x offset is determined by the routine as 3 mm (square is closer to home than it should have been), and the x scale is 0.98 (test pattern is smaller than expected), then the correct offset (with scaling) could be calculated with something like this:

[actual offset] = [measured offset (3mm)] + (1- [scale (0.98)]) * [index (-2)] * 3 * 25.4

I’m not very confident in my math, but I think there’s something like this that should work.

Edit: now that I write it out, I think it’d be more intuitive to just input the X and Y spacing (e.g. 3.023in) or something like that. Maybe i’ll make that change next time I’m at a computer. I have my work in progress here if you want to pick up where I left off.

Ok thinking about it a bit more I guess you’d need to know the spacing in the firmware to interpolate perfectly (though it might not make much of a difference in practice). But I think when using curve fitting it’s probably not necesssry right?

Well, if the idea is that when we are telling the machine to move to x0,y0 and we are actually moving to x1, y1 because the pattern is off and we determine the offset at x1, y1 to be x2, y2, we can assume the offset for x,y to be x2-(x1-x0), y2-(y1-y0) for reasonably small x1-x0 and y1-y0? If so, we don’t need to do anything to the firmware.

I like the idea of someone measuring like I did and entering that as a distance and then we just divide by the appropriate number of squares.

That makes sense to me, a few mm on top of 3 inches shouldn’t make a huge difference in interpolation.

That’s definitely easier for the end user! The main downside in my mind is that if you change the dimensions of the area you calibrate on, you’d also have to change the value. Using something like 3.0324in OR 1.0108 scale factor should be constant even if you change the area you’re calibrating on.

Maybe we could have both – when this gets productionized there could be a step to measure the outer squares of the pattern and we could do the math under the hood. But the value we store / save is a scale factor or an ‘average distance between squares’ or something like that.

I tried your method out and I was getting results that didn’t make sense to me and I stopped it. I then changed the calibration to do it the way I suggested originally and I got similar results as your way but I let it run the full board… So, I’ve been mulling why the results don’t make sense but are, nevertheless, correct. Tomorrow (getting late), I will try your way across the full sheet and see if I get reasonably consistent results with my original way. If so, your way will be the way since its a lot simpler to implement. If not, we need to figure out which is the correct way.

And thanks for the addition to save centerx, centery… that was on my todo list.

We definitely should store it as a scale factor… I just want to make it easy for people to determine that scale and eliminate as many places as possible for someone to make a math error.

Yeah no guarantees on my math above. I think it probably has some errors. I’m not very confident in it. We are talking about the correct way to handle scaling right? Just want to make sure we’re talking about the same thing :slight_smile:

You’re welcome! Glad to be able to contribute to this

Totally agree. Before shipping to other users, I envision splitting this out into multiple steps, similar to the current calibration. Measuring the pattern could be one of the steps. For now I think we can just expose the scaling value directly. I think I lean towards storing distance between test markers (3*25.4mm by default).

Did not get the crash this time when saving to eeprom, so whatever you did seems to have worked!

I updated my doc with my calibration values from the run tonight. I did some traditional value changes I had been considering: I set the motor distance to the measured value (instead of the one generated by the ‘pull tight’ routine), I set rotational radius to 139.1, then I ran the calibration again.

My values overall look like they were better calibrated after my changes, which is nice. I still have that gnarly ~1mm amplitude periodicity in my Y axis, so I’m 2 for 2 in replicating that. I’m super curious what would be causing it. I’m pretty sure it’s not in the test pattern. I think I would be able to see 1mm of misalignment.

I also noticed when returning to center after sending the values, that I didn’t end up in the middle of the home square like I used to. Zooming in on the snazzy grid you made, I see that the target is over the blue line, which I think is the curve fit values? The red line (I think the interpolated values) seems to be a ways over. Is this expected with curve fitting? Seems like it should be closer, especially for the home position. How are you switching between curve fit and interpolation for testing?

image

I didn’t get around to implementing the scale function tonight, but I might be able to tomorrow if you don’t beat me to it!

1 Like

The blue lines are the idealized grid, spaced 3 inches apart.

The red lines are the calibration matrix.

The green lines are the curve-fit values.

After you send the cal values and enable the calibration, you would ideally end up on the blue lines (like I see in your picture). This means that the adjustments are working.

Regarding your image, I would have thought the red horizontal red and green lines would have been much closer. Here’s mine:

image

Regarding using interpolation or curve, in Advanced Settings there’s two switches, one enables the use of calibration and the other switches between interpolation and curve. On means use interpolation and Off means use curve. When you connect and you get a stream if information from the controller on the front page, you will see the values .

image

1 (enable calibration) means it’s on
1 (use interp or curve) means it’s using interpolation

I got interesting results with my test last night, the x errors came out smooth and slanted (normalized to the center error):

-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
7 0.57 0.18 0.08 -0.29 -0.53 -0.85 -1.34 -1.77 -1.37 -1.55 -1.91 -2.49 -2.55 -3.26 -3.01 -3.03 -3.2 -3.53 -3.89 -4.43 -4.57 -5.01 -5.1 -5.49 -5.95 -6.13 -6.24 -6.42 -6.55 -6.9 -7.3
6 0.94 0.68 0.36 -0.03 -0.36 -0.56 -0.84 -1.02 -1.68 -1.64 -1.93 -1.94 -2.48 -2.54 -2.9 -2.87 -2.9 -3.2 -3.51 -3.93 -4.2 -4.3 -4.76 -4.89 -5.45 -5.19 -5.64 -5.52 -6.11 -6.26 -6.77
5 1.72 1.12 1.08 0.47 0.33 -0.21 -0.22 -0.55 -0.76 -1.04 -1.6 -1.8 -2.04 -2.05 -1.91 -2.26 -2.28 -2.69 -2.93 -3.24 -3.58 -3.89 -3.93 -4.31 -4.41 -4.36 -4.83 -5.1 -5.59 -5.67 -6.34
4 1.87 1.16 1.34 0.84 0.46 0.25 -0.33 -0.38 -0.62 -0.98 -0.94 -1.49 -1.67 -1.9 -1.67 -2.02 -2.14 -2.27 -2.77 -2.8 -3.23 -3.26 -3.32 -3.6 -4.19 -4.37 -4.55 -4.65 -4.91 -5.41 -5.66
3 2.67 1.96 2.26 1.51 1.09 0.73 0.64 0.04 -0.03 -0.33 -0.43 -1 -0.84 -1.16 -0.95 -1.18 -1.39 -1.53 -1.87 -2.04 -2.29 -2.65 -2.72 -3.14 -3.56 -3.17 -3.51 -4.09 -4.46 -5.11 -5.58
2 2.92 2.32 2.37 1.84 1.15 0.88 0.65 0.32 0.3 0.14 -0.14 -0.52 -0.49 -0.82 -0.85 -1.21 -0.97 -1.62 -1.52 -2.03 -2.05 -2.52 -2.51 -2.93 -3.02 -3.56 -3.31 -4 -4.12 -4.81 -4.55
1 4 3.05 3.14 2.26 2.36 1.94 1.3 1.4 0.97 1.03 0.63 0.03 0.25 -0.08 -0.36 -0.16 -0.44 -0.49 -0.58 -0.6 -1.29 -1.66 -1.64 -2.16 -2.58 -2.24 -2.7 -2.89 -3.03 -3.64 -3.67
0 3.17 3.2 2.82 3.09 2.92 2.3 2.38 1.27 1.23 0.85 0.37 0.29 0.08 0.03 0.01 0 0.1 -0.15 -0.55 -0.58 -0.92 -0.98 -1.12 -1.74 -2.23 -2.21 -2.34 -2.67 -4.25 -4.23 -4.91
-1 3.24 3.65 4.29 4.23 2.82 3.29 3.03 2 2.27 1.36 1.13 0.85 1.16 0.23 0.25 0.66 0.56 0.15 0.15 -0.18 -0.28 -0.29 -0.86 -1.26 -1.82 -1.86 -1.31 -1.62 -2.3 -2.49 -3.17
-2 5.77 4.18 4.4 3.35 3.64 2.85 3.55 2.34 2.68 2.63 2.3 1.46 1.31 1.33 1.33 0.81 0.81 0.64 -0.58 1.08 0.34 0.19 -0.71 -1.02 -0.93 -0.79 -1.26 -1.14 -1.89 -3.47 -4.31
-3 6.72 5.84 4.5 3.52 3.59 3.53 3.51 2.81 4.26 2.31 1.89 2.11 2.05 1.47 1.5 1.11 0.75 1.05 1.18 1.13 0.77 -0.08 -0.03 -0.15 -1.08 -0.08 -0.96 -0.7 -1.89 -1.61 -1.67
-4 7.28 5.85 4.49 4.13 4.15 3.5 3.41 3.89 3.75 2.36 3.31 2.37 2.83 1.25 2.66 2.49 2.61 1.48 1.43 1.8 0.32 1.01 0.95 0.8 -0.73 0.49 -0.59 -1.8 -1.82 -3.19 -1.46
-5 5.32 5.24 6.72 6.61 4.58 4.06 4.1 3.56 3.67 3.69 2.73 3.38 2.42 3.6 2.32 2.93 2.79 1.8 1.71 1.56 1.56 1.99 1.51 0.97 0.74 0.63 0.8 0.56 -1.19 0.08 -0.36
-6 5.22 5.2 6.37 5.26 5.2 5.65 5.36 3.97 3.96 3.92 3.75 3.42 2.51 3.73 2.99 3.71 3.52 3.29 2.41 2.27 2.17 2 1.29 0.57 0.54 0.16 -0.02 0.2 0.16 0.12 -0.47
-7 5.24 8.38 8.42 6.66 5.26 5.74 5.28 4.67 4.68 4.72 5.42 4.25 4.21 3.97 3.42 3.37 3.63 3.54 3.32 2.64 2.74 2.53 2.16 2.09 1.58 1.58 1.6 0.3 1.4 1.4 0.65

and Y is similar but with some periodicity going on…

-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
7 -4.43 -3.49 -3.4 -2.33 -1.65 -0.92 -1 -0.22 -0.91 0.51 1.85 0.96 2.47 3.34 2.35 3.65 3.12 4.14 4.07 5.14 4.4 5.6 4.96 5.66 6.2 6.01 6.49 6.41 6.03 6.78 7.03
6 -5.06 -4.26 -3.91 -3.39 -2.75 -2.04 -0.93 -1.87 -0.96 -1.01 -0.2 -0.29 0.99 0.96 1.62 1.51 2.43 2.78 2.79 3.32 3.59 3.67 4.95 4.41 4.9 4.69 5.23 5.22 5.54 5.92 6.56
5 -3.89 -3.39 -3.37 -2.98 -2.46 -2.32 -1.67 -1.13 -1.74 -0.65 -0.87 0.16 0.71 1.28 0.71 1.64 1.56 1.84 2.05 2.74 2.9 3.71 3.76 3.79 4.35 4.25 5.25 5.22 5.98 5.88 7
4 -4.59 -3.86 -4 -3.8 -3.41 -2.48 -2.85 -2.22 -0.96 -1.54 -0.84 -0.32 -0.81 0.1 -0.1 0.64 0.57 1.36 1.84 1.88 2.34 2.29 3.15 3.46 3.46 4.49 4.52 5.2 5.2 5.64 6.38
3 -3.61 -3.61 -3.66 -2.98 -2.63 -2.13 -1.64 -1.73 -1.02 -1.4 -0.73 -0.63 -0.19 0.41 0.12 0.83 0.35 1.32 0.76 1.64 1.69 2.57 2.67 3.34 3.91 3.92 4.73 5.06 5.91 5.99 6.98
2 -4.63 -3.93 -3.89 -3.72 -3.4 -2.55 -2.61 -2.01 -1.99 -1.05 -1.73 -0.85 -0.69 -0.51 0.03 0.08 -0.03 0.69 0.72 1.2 1.14 1.94 1.9 2.7 2.82 3.81 3.95 4.99 5.05 6.13 6.38
1 -3.52 -3.76 -3.7 -3.38 -2.25 -2.35 -2.18 -2.05 -1.69 -1.72 -1.34 -1.24 -1.17 -0.72 -0.48 -0.22 0.33 -0.18 0.72 0.65 1.4 1.93 2.05 2.89 3.49 3.74 4.57 4.21 4.91 5.32 5.33
0 -4.53 -4.42 -4.07 -3.3 -2.97 -2.44 -2.43 -1.76 -1.75 -1.99 -1.33 -1.35 -1.19 -0.24 -0.22 0 0.07 0.3 0.93 0.91 0.65 1.81 2.05 1.89 3.72 3.67 4.6 5.08 6.58 6.55 7.22
-1 -4.47 -3.69 -2.96 -3.03 -2.87 -2.75 -2.19 -2.19 -1.61 -1.57 -1.57 -1.42 -1.09 -1.03 -0.81 -1.09 0.1 -0.42 -0.42 0.05 1.48 1.46 2.32 2.84 2.72 4.13 4.46 4.27 5.17 5.4 6.24
-2 -2.9 -3.98 -2.96 -2.98 -3.41 -3.03 -2.25 -1.77 -1.81 -1.63 -1.5 -1.27 -1.64 -1.53 -1.44 -0.26 -0.26 -0.13 0.22 0.58 1.32 1.43 1.66 2.27 2.55 3.76 3.76 4.39 5.12 7.02 6.84
-3 -3.32 -3.41 -3.9 -3.03 -2.75 -2.59 -1.68 -1.88 -1.71 -1.78 -1.69 -0.87 -1 -1.38 -0.41 -0.62 -0.44 -0.45 -0.26 0.66 1.24 1.43 1.47 2.69 3.33 3.09 4.63 4.26 5.94 5.28 5.33
-4 -2.79 -2.89 -3.77 -2.71 -2.45 -2.54 -2.61 -2 -1.88 -1.88 -1.61 -1.37 -1.24 -0.95 -1.02 -0.59 -0.58 -0.03 -0.03 0.47 0.94 0.84 2.04 1.85 3 2.99 4.78 5.79 5.78 6.29 6.44
-5 -3.87 -3.83 -2.22 -2.34 -2.15 -2.25 -2.27 -1.75 -1.34 -1.35 -0.94 -1.21 -0.96 -1.15 -0.78 -0.52 -0.56 -0.27 0.08 0.22 0.3 1.1 1.65 2.45 2.4 3.1 3.69 4.26 6.07 5.5 6.46
-6 -3.42 -3.46 -2.94 -2.96 -1.98 -2.04 -1.71 -0.93 -0.87 -1.4 -1.17 -0.22 -1.85 -0.87 -0.46 0 0.02 0.16 0.05 0.85 0.73 1.99 2.33 3.54 3.54 4.33 4.78 5.91 5.98 5.7 6.5
-7 -3.42 -1.62 -1.61 -1.73 -2.17 -1.44 -2.17 -1.53 -1.5 -1.46 -1.2 0.09 0.09 -0.71 -0.34 -0.37 -0.64 0.53 0.17 -0.07 0.28 0.87 1.5 2 2.87 2.83 4.72 5.97 5.31 5.31 6.83

Is it possible as you save the values of x and y for each square to also save the chain length value sent to the motors left and right values? Just wondering if that would be a good checkpoint to see if they are smooth or have those oscillations in them.

2 Likes

Yeah, we could do a motor read and log that as well

1 Like

I discovered my left motor controller chip was missing its heatsink. It’s now reattached and ziptied to the board.

2 Likes