Copying measurement and sqrtinfo in FactorBase (multi-threading)
In multi-threading, the solver may call evaluate()
to a factor that has been removed (since the pointer is in the SolverManager
the factor has not been destroyed yet). Whenever getMeasurement()
and/or getSquareRootInformationUpper()
is called, the corresponding feature is not there and an assertion is raised.
The easiest way to solve this is copying the measurement and covariance and store it in FactorBase
attributes.
This would imply:
- Add
FactorBase
atributes:Eigen::VectorXd measurement_
andEigen::MatrixXd measurement_sqrt_information_upper_
(copied from feature in constructor. - Modify
FactorBase::getMeasurement()
andFactorBase::getMeasurementSquareRootInformationUpper
(they can be used or not in theoperator()
). - Remove
FactorBase::getMeasurementCovariance()
not used (or used to take the size of the covariance).
The thing is that in evaluate
(meaning in operator()
in most of the cases), there shouldn't be any call to the feature or any constrained_by node. Is there a way to "force" that to the developers from base class?