I still don’t know why it happens but I spent three hours trying to figure out why the controller kept losing usb connection when I put a serial.println statement in a particular spot in a function. I can load up tons of serial.println statements before one certain calculation, but if I put it after that calculation, usb disconnects. I gave up and decided it must be some kind of race condition unique to microcontrollers. Maybe someone smarter than me can give me a clue.
Anyway, I went back to work on optical calibration yesterday and today and have made a whole lot of progress. I would be much further along if I was a good enough programmer that I didn’t have to spend 90% of my time correcting idents, missing colons, missing semicolons, stupid copy-paste typos… sigh.
Using a turned block of wood from @marm, a usb endoscope, and three relatively cheap ARCH E sized blueprint of 1/2-inch squares spaced 3-inches apart, I’ve managed to “calibrate” my center 0,0 position so that it’s truly the middle of the board. That’s a huge step and the next step, actually having calibration points offset the target coordinates, is really, really close (I needed the three ARCH E sheets to cover the whole board). I’ve spent the last 12 hours getting to this point, so it’s time for a break.
I’ve posted a youtube video of ground control running through the process. Basically, it determines the distance from the center of the image to the center of the center square. It then moves up and to the left and then scans left to right each square and calculating their offsets from center (9 squares, basically a 3x3 matrix at this time). Ideally, when it scans the center square again, you’d get the same result, but nothing is perfect in life. Finally, it sends all 31x15 offsets to the controller (only 9 of them have values). At this point, I’m only using the center value to make an adjustment. The controller adjusts the positions of the motors based upon how far off the center square was. In essence, it will raise/lower or shift left/right the motor coordinates used by triangularInverse so 0,0 is 0,0 (or at least pretty close to it). That was step 1.