QuantuMope / handeye-4dof

Handeye calibration for 4DOF manipulators using dual quaternions.
MIT License
22 stars 7 forks source link

Inaccurate Z position and poor refined calibration result #8

Open Tom-Forsyth opened 2 months ago

Tom-Forsyth commented 2 months ago

Hi! Thank you for implementing this - this has been super helpful so far!

I'm having an issue with some inaccurate results and the nonlinear refinement stage.

I have several cameras attached to a large tool on a custom SCARA arm. You can think of the tool as a 1.0 m long and 0.3 m tall rectangle, in the XY plane. There are cameras on each corner, making the expected translation of each transform roughly +/- (0.5, 0.15, 0.0) m. The cameras face straight down onto the plane of the robot (XY).

I am converging great in X, having some slight issues in Y (most likely due to some mechanical repeatability problems), but I have a very large amount of error in Z. IE, my expected Z position is roughly 0.0, but I am getting 0.5, sometimes even greater than 1.0 m - both negative and positive!

Additionally, the non linear refinement stage seems to produce a very wrong result, although it seems to converge to roughly (0.3, 0.8, 0.0). In fact, the Z is always exactly 0.0. I am wondering if this is any indication of what's going on with my Z issue.

I have collected data across multiple different runs, but these same issues keep showing up. I take around 50 images per camera each run, so data quantity is not the issue. I also an ensuring to sample throughout the entire workspace. I have previously had issues when I was not being careful about fully exploring the workspace - the tips in #5 were very helpful! I was also encountering the screw axis issue, it seems to show up when crossing over a certain angle range about the Z axis.

I am looking for some insight into what may be causing these issues, and some ideas of things to look for and try. Also, are there any good metrics or numbers inside the solver to look for to indicate convergence or divergence, as a whole or in any certain direction.

Thanks in advance for any advice you can provide!

Tom-Forsyth commented 2 months ago

One more observation that might be helpful:

If I have a set of 50 images, using only 10, 20, etc produces an extremely similar (~0.001 m) X and Y translation result as the full 50. However, this drastically changes the Z result, and can result in both negative and positive Z values of large amounts (0.5 - 1.0 m).

In all cases, my singular values seem to be low (< 0.03), so it appears I am exploring the workspace correctly even with low amounts of data.

The Z travel is roughly 0.5 m total. This is a limitation of the length of the axis on my robot. Could this be the issue?

QuantuMope commented 2 months ago

Hi @Tom-Forsyth ,

The differences in z values is actually to be expected. Unfortunately, calibrating in 6DOF with only 4DOF samples is an ill-posed problem. In the paper that this code is based on, you can see that this calibration method will produce results for all dimensions except the z-axis. This explains why different sets of images used by you produce different z results (as they are all garbage values anyways). For the nonlinear refinement step, since the z-axis value is unusable anyways, I believe I may have hard-coded it to be 0.

In other words, after calibrating the 5 attainable dofs using this method, you must then somehow measure the z-axis distance yourself. This will complete the calibration for your 4dof manipulator. I encourage you to take a look at the linked manuscript and read over the section "_Determination of the Real tz" as it goes over some proposed solutions for determining the z-axis post calibration.

Thank you for your question though. I believe I can do a better job at explaining this caveat in the README and will add an explanation.

Let me know if you have any other questions.

Tom-Forsyth commented 2 months ago

@QuantuMope Thanks for the fast reply! This makes a ton of sense, we can't expect a good 6-DOF solution from 4-DOF data. So in that case, I feel that I'm actually getting pretty accurate results now! I'll take a look through the paper for the explanation and Z calibration information, thanks for pointing me to that.

One more question I have is that the nonlinear refinement will still change X and Y quite a bit, away from the expected nominal. Is there anything I should look into as to why that would be? I'm wondering if this is an indication of bad data, or maybe some outliers.

Like I mentioned before, I am having some mechanical issues with repeatability, so I am wondering if this could cause a few samples to cause large error.

Thanks!

QuantuMope commented 2 months ago

That is a possibility. Since the nonlinear refinement tries to minimize the cumulative error of all poses when transform chaining with the calibrated results, outliers and especially nonrepeatability would definitely skew results.

At the same time, it is also possible that the nonlinear refinement code has an error in it... as I coded it many years ago, it's hard to say. Perhaps I can take a look at it again sometime this week when I have some free time.

In the meantime, I suggest forgoing that part if you are getting acceptable results form the calibration itself.

Hope this helps.

Tom-Forsyth commented 2 months ago

I see, I need to poke through my data a bit more and try to manually remove some outliers.

Thanks again, this was all super helpful!

QuantuMope commented 2 months ago

Of course. I will keep this comment open until I take a look at the nonlinear refinement. ^_^