> The problem is that when I increase the residual blocks number from 3 to 4, the optimization will be not sensitive to initial value.
As I've mentioned before, there are still at least two local minimas [except the desired one at (x=0,y=0,z=0,w=1)]: (x=1,y=0,z=0,w=0) and (x=0, y=0.484768546026564, z=0.874642473690417, w=0).
You can reach the second one, for example, starting from point (x=0,y=0,z=1,w=0) (for clarity: it is Eigen::Quaterniond(0,0,0,1) )
Is there a specific reason why you want to solve this problem using local optimizer like ceres-solver, instead of utilizing closed-form globally-optimal solution from the Umeyama algorithm (rotation estimation step)?
You can use this globally-optimal solution for a regular (non-robustified) least-squares formulation of your problem as an initialization for robustified least-squares, if it is the ultimate goal.
> or determine how many local minimum points in a specified region?
If you're interested in obtaining all local minima/maxima points -- you can create a system of polynomial equations for first-order optimality conditions (using Lagrange multipliers); and then solve it using multivariate-polynomial system solving method (I suppose that applying conventional approach with observing quotient ring structure in Zp and applying these observations to real case might succeed).
But I will state one more time, that it seems to me that your particular problem has a globally-optimal closed-form solution given by a rotation-estimation part of Umeyama algorithm.