@@ -88,7 +88,7 @@ class VertexCameraBAL : public BaseVertex<9, Eigen::VectorXd>
88
88
89
89
virtual void oplusImpl (const double * update)
90
90
{
91
- Eigen::VectorXd::ConstMapType v (update, 9 );
91
+ Eigen::VectorXd::ConstMapType v (update, VertexCameraBAL::Dimension );
92
92
_estimate += v;
93
93
}
94
94
};
@@ -258,18 +258,24 @@ class EdgeObservationBAL : public BaseBinaryEdge<2, Vector2d, VertexCameraBAL, V
258
258
259
259
const VertexCameraBAL* cam = static_cast <const VertexCameraBAL*>(vertex (0 ));
260
260
const VertexPointBAL* point = static_cast <const VertexPointBAL*>(vertex (1 ));
261
- typedef ceres::internal::AutoDiff<EdgeObservationBAL, double , 9 , 3 > BalAutoDiff;
261
+ typedef ceres::internal::AutoDiff<EdgeObservationBAL, double , VertexCameraBAL::Dimension, VertexPointBAL::Dimension > BalAutoDiff;
262
262
263
- Matrix<double , 2 , 9 , Eigen::RowMajor> dError_dCamera;
264
- Matrix<double , 2 , 3 , Eigen::RowMajor> dError_dPoint;
263
+ Matrix<double , Dimension, VertexCameraBAL::Dimension , Eigen::RowMajor> dError_dCamera;
264
+ Matrix<double , Dimension, VertexPointBAL::Dimension , Eigen::RowMajor> dError_dPoint;
265
265
double *parameters[] = { const_cast <double *>(cam->estimate ().data ()), const_cast <double *>(point->estimate ().data ()) };
266
266
double *jacobians[] = { dError_dCamera.data (), dError_dPoint.data () };
267
- double value[2 ];
268
- BalAutoDiff::Differentiate (*this , parameters, 2 , value, jacobians);
267
+ double value[Dimension ];
268
+ bool diffState = BalAutoDiff::Differentiate (*this , parameters, Dimension , value, jacobians);
269
269
270
270
// copy over the Jacobians (convert row-major -> column-major)
271
- _jacobianOplusXi = dError_dCamera;
272
- _jacobianOplusXj = dError_dPoint;
271
+ if (diffState) {
272
+ _jacobianOplusXi = dError_dCamera;
273
+ _jacobianOplusXj = dError_dPoint;
274
+ } else {
275
+ assert (0 && " Error while differentiating" );
276
+ _jacobianOplusXi.setZero ();
277
+ _jacobianOplusXi.setZero ();
278
+ }
273
279
}
274
280
};
275
281
0 commit comments