I've got an annoying problem.
My KUKA robots have a method for measuring external Bases by taking 4 points in space. You move the robot to each of these points, and provide the robot with the XYZ position of each point in the new Base.
The intention was to provide a way to touch-measure a Base frame in situations where it wasn't physically possible to reach the Origin, or points exactly on the X axis or XY plane.
So, if you have four points in space that you can tough the robot's TCP to, and you know the XYZ coordinates of each of those points in the Base you're trying to measure, the robot can calculate the transform from robot base to the external base frame. If I had the CAD data for all the weld points on a car, for example, and touched my robot's weld gun TCP to 4 of those points, and provided the XYZ of each point in the car coordinate system, the robot could reverse-calculate the XYZABC of the origin of the Car coordinate system relative to the robot.
Now, this is great, except for a few things: There's no way to teach and play back those points -- you have to move the robot to each point, then type in the "car" coordinate XYZ value of that point before moving on to the next. If you make a mistake, you have to do the whole process over again. And if you want to repeat the same measurement to check your work, you're stuck hand-jogging the robot to the previous points (assuming you wrote them down the first time). It's really annoying.
What I want to do is record those 4 points in both Robot coordinates and "Car" coordinates (or airplane, or boat, or pallet, or whatever external Base I'm using), and then perform the best-fit calculation offline, in Excel or MatLab or Python or something. But I don't know what the general algorithm is for doing this calculation.
I've gone Googling for "best fit" algorithms, but everything I find is either 2D, or related to building meshes from point clouds, or fitting planes/spheres to point clouds, or something else that's not relevant to what I'm trying to do. Probably I'm just not finding the correct search terms.
So... is there a basic "canned" algorithm for doing this kind of thing? Or, better yet, a tutorial of some kind that explains how to go about creating your own? I'm not too concerned with calculation efficiency (I can wait 5min for the thing to process, if need be) or with extreme precision (though I wouldn't turn it down).