02-20-2017 11:23 PM - edited 02-20-2017 11:24 PM
OK, this dataset has a bit more curvature. Good!
If you look at the raw data (zoom into the x y or z trace) there are some small discontinuities (due to e.g. vibration, stiktion, or similar). They show up in my "distances" graph as jumps and there is no way for a circle to follow the data.
If I do the sphere fit, the difference between actual radius and best fit radius has a standard deviation of only 2 mils, well within your 5 mil accuracy (max. deviation is 12 and -6 mils). (Of course you would need to calculate the error propagation from x,y,z, to r, etc. :))
I think it works fine.
02-21-2017 08:32 AM
Yes, the vibration is expected as the movement is driven by a bipolar stepper motor in full step mode. We are now using a low cost MCH-5 Motion Checker for development but for the real calibration we will use microstepping.
I understand the reason why it is not possible to fit a circle on the raw data but ultimately the center must be on the best fit plane. In the first picture the (x0,y0,z0) point seem to be centered but in the second one we see that it is not in the same plane.
Would it be reasonable to assert that the projection of (x0,y0,z0) onto the best fit plane could generate a result within the range of sensor resolution? (I will try it when I have time, I'm actually busy on another project)
Ben64
02-21-2017 02:58 PM
Why not treat the best fit plane as a constraint on the sphere fit?
Fitting on a sphere.vi reduces to the solution of a single linear system. The best fit plane equation can be viewed as an equality constraint, and is implemented as an additional row in the linear system solve inside Fitting on a Sphere with Constraint.vi
I re-implemented the Fitting on a Sphere.vi to be a little clearer (using linear algebra to clarify the diagram a bit), and to incorporate the plane constraint. Note the use of a weight. By adding the extra row the linear system is now over-determined, so the weight can be adjusted to emphasize the constraint as needed. A weight of 1 seems to work well for this problem. I didn't notice significant constraint violation until the weight was reduced to ~1E-5 or so.
-Jim
02-21-2017 03:24 PM
Yes, projection of all data to the best fit plane will guarantee that the center is in that plane. I guess your data shows slight assymmetry around that plane, causing the center to move out of the plane.
I think it would also be easy to implement a nonlinear fit that uses the plane constraints.
(Sorry, posting by phone. Cannot look at the code above)
02-21-2017 05:47 PM
02-21-2017 07:37 PM
Hi Ben
Are you going to use this Optitrack system with sensors on people? Are you only ever going to be tracking one marker? The reason I ask is that this sort of fitting is a well-trodden path, and depending on the "joint", it isn't always a centre point you want. Sometimes it is an axis. How many degrees of freedom do you have? I thought I would offer an article reference that uses SVD to determine the movement of one body relative to another.
02-22-2017 08:29 AM
02-22-2017 12:53 PM
02-23-2017 02:42 PM
Just for reference, here's a (very!!!) old discussion (with links) that talks about the algorithm used when fitting on a sphere.
02-23-2017 02:48 PM
@altenbach wrote:
Just for reference, here's a (very!!!) old discussion (with links) that talks about the algorithm used when fitting on a sphere.
Thanks for the link.
Ben