Error in evaluating the ResidualBlock

2,445 views
Skip to first unread message

taiping

unread,
Jun 2, 2017, 11:22:50 PM6/2/17
to Ceres Solver
Hi,
I use linear solver SPARSE_NORMAL_CHOLESKY to solve graph pose slam problem. It works fine when residuals are small. However, when loop closure occurs, I get errors.

From A to A`, it works fine. Since A and A` is the same location, the loop closure occurs and I get errors.

the solution is to use EigenSparse instead of SuiteSparse for a bug in SuiteSparse.
I tried linear solver DENSE_NORMAL_CHOLESKY and DENSE_QR based on EigenSparse. It is very slow, and I also get same errors.

I hope I make it clearly.

The error I've been getting is shown below:
W0603 10:40:14.056905 8994 residual_block.cc:131]

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation.

Residual Block size: 7 parameter blocks x 3 residuals

For each parameter block, the value of the parameters are printed in the first column
and the value of the jacobian under the corresponding residual. If a ParameterBlock was
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry
of the Jacobian/residual array was requested but was not written to by user code, it is
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating
to Inf or NaN is also an error.

Residuals: 0 0 0

Parameter Block 0, size: 1

-48.3575 | -nan -nan -nan

Parameter Block 1, size: 1

-428.744 | -nan -nan -nan

Parameter Block 2, size: 1

1.11116 | -nan -nan -nan

Parameter Block 3, size: 1

-28.9954 | -nan -nan -nan

Parameter Block 4, size: 1

-250.725 | -nan -nan -nan

Parameter Block 5, size: 1

1.27572 | -nan -nan -nan

Parameter Block 6, size: 1

-65.0826 | -nan -nan -nan


E0603 10:40:14.057034 8994 trust_region_minimizer.cc:113] Terminating: Residual and Jacobian evaluation failed.

Best,
Taiping

Sameer Agarwal

unread,
Jun 3, 2017, 1:22:40 AM6/3/17
to Ceres Solver
Taiping,
This indicates something is wrong with your computation of the Jacobian. It has nothing to do with the sparse linear algebra library. You should check the cost function and how it is computing the Jacobian.
Sameer



--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/e8860fd9-2bcd-4e44-830b-fe741296d129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eugen Funk

unread,
Nov 4, 2017, 7:48:31 PM11/4/17
to Ceres Solver
Dear Sameer,
I am having similar issue when using AutoDiffCostFunction.
The problem mainly arises when I set the initial values to the exact solution. Thus, the residuum is 0 and the jacobians are alle nan.
Is there a way to debug the reason for this? Is the trust region too small?

Best
Eugen

Sameer Agarwal

unread,
Nov 6, 2017, 12:06:18 AM11/6/17
to ceres-...@googlegroups.com
Eugen,
Have a look at the stderr, there is detailed logging information that is recorded when a Jacobian computation produces nans. 
Sameer

William Rucklidge

unread,
Nov 8, 2017, 5:19:01 PM11/8/17
to ceres-...@googlegroups.com
One thing to look at: does your residual include a square root (or other fractional power)? If it does, you may run into trouble when the residual is zero, or very close to it, as the derivative of the square root function is infinite at zero, which can quite easily lead to NaNs in the Jacobian. This can be a problem for analytical derivatives, of course, but when you're writing those out it's easier to see that you just wrote something like
  jacobians[i][j] = ... 1/(2*sqrt(value)) ...
and take steps to avoid those infinities.

-wjr


To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUBmtdTMjrh-%3De8h-F4aaw2jF3BDu-pWPZ2jiqcOd5Yzcg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages