hengli / camodocal

CamOdoCal: Automatic Intrinsic and Extrinsic Calibration of a Rig with Multiple Generic Cameras and Odometry
Other
1.17k stars 391 forks source link

Possible bug in HandEyeCalibration? #19

Closed ahundt closed 9 years ago

ahundt commented 9 years ago

This issue ties back to issue #17 where I'm continuing to have difficulty solving for the transform accurately.

I ran HandEyeCalibration_test.cc, and it appears to show the presence of a bug, unless I am misunderstanding something. As you can see the Z axis expects 0.7 and is finding -0.02, which is a surprisingly large error relative to the random variation between -1.0 and +1.0.

./bin/./HandEyeCalibration_test
Running main() from gtest_main.cc
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from HandEyeCalibration
[ RUN      ] HandEyeCalibration.FullMotion
[       OK ] HandEyeCalibration.FullMotion (11 ms)
[ RUN      ] HandEyeCalibration.PlanarMotion
[       OK ] HandEyeCalibration.PlanarMotion (0 ms)
[ RUN      ] HandEyeCalibration.PlanarMotionWithNoise
# INFO: No unique solution, returned an arbitrary one.
# INFO: Before refinement: H_12 =
 0.919962 -0.310734  0.238986   7.33089
 0.346704  0.929456 -0.126123   9.88994
-0.182936  0.198886  0.962797   18.7327
        0         0         0         1
Ceres Solver Report: Iterations: 12, Initial cost: 1.756146e+05, Final cost: 4.096604e-07, Termination: GRADIENT_TOLERANCE.
# INFO: After refinement: H_12 =
  0.926695  -0.300955   0.225083   0.489981
   0.32348   0.943636 -0.0700894   0.611425
 -0.191302   0.137761   0.971815 -0.0208261
         0          0          0          1
# INFO: H_12_expected =
  0.926699  -0.300952   0.225068        0.5
  0.323506   0.943615 -0.0702454        0.6
 -0.191237   0.137907   0.971807        0.7
         0          0          0          1
[       OK ] HandEyeCalibration.PlanarMotionWithNoise (34 ms)
[----------] 3 tests from HandEyeCalibration (45 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (45 ms total)
[  PASSED  ] 3 tests.

If I increase motionCount in HandEyeCalibration_test.cc to 100 I get a similar result:

./bin/./HandEyeCalibration_test
Running main() from gtest_main.cc
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from HandEyeCalibration
[ RUN      ] HandEyeCalibration.FullMotion
[       OK ] HandEyeCalibration.FullMotion (5 ms)
[ RUN      ] HandEyeCalibration.PlanarMotion
[       OK ] HandEyeCalibration.PlanarMotion (0 ms)
[ RUN      ] HandEyeCalibration.PlanarMotionWithNoise
# INFO: No unique solution, returned an arbitrary one.
# INFO: Before refinement: H_12 =
  0.926525  -0.300674   0.226158   0.503363
  0.323268   0.943739 -0.0696776   0.595669
 -0.192483   0.137668   0.971595    4.31143
         0          0          0          1
Ceres Solver Report: Iterations: 18, Initial cost: 1.156761e-07, Final cost: 1.114745e-11, Termination: FUNCTION_TOLERANCE.
# INFO: After refinement: H_12 =
    0.9267  -0.300952   0.225065   0.499987
  0.323503   0.943617 -0.0702337   0.599988
 -0.191238   0.137895   0.971809  -0.100819
         0          0          0          1
# INFO: H_12_expected =
  0.926699  -0.300952   0.225068        0.5
  0.323506   0.943615 -0.0702454        0.6
 -0.191237   0.137907   0.971807        0.7
         0          0          0          1
[       OK ] HandEyeCalibration.PlanarMotionWithNoise (32 ms)
[----------] 3 tests from HandEyeCalibration (37 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (37 ms total)
[  PASSED  ] 3 tests.
hengli commented 9 years ago

It is actually not a bug. For the planar case, the relative z-translation is not observable. In this case, you should use the CamOdoCalibration class.