27 template <
int D,
typename E,
typename VertexXiType>
28 void BaseUnaryEdge<D, E, VertexXiType>::resize(
size_t size)
31 std::cerr <<
"WARNING, attempting to resize unary edge " << BaseEdge<D, E>::id() <<
" to " << size << std::endl;
33 BaseEdge<D, E>::resize(size);
36 template <
int D,
typename E,
typename VertexXiType>
37 bool BaseUnaryEdge<D, E, VertexXiType>::allVerticesFixed()
const 39 return static_cast<const VertexXiType*
> (_vertices[0])->fixed();
42 template <
int D,
typename E,
typename VertexXiType>
43 void BaseUnaryEdge<D, E, VertexXiType>::constructQuadraticForm()
45 VertexXiType* from=
static_cast<VertexXiType*
>(_vertices[0]);
48 const JacobianXiOplusType& A = jacobianOplusXi();
49 const InformationType& omega = _information;
51 bool istatus = !from->fixed();
54 from->lockQuadraticForm();
56 if (this->robustKernel()) {
57 double error = this->chi2();
59 this->robustKernel()->robustify(error, rho);
60 InformationType weightedOmega = this->robustInformation(rho);
62 from->b().noalias() -= rho[1] * A.transpose() * omega * _error;
63 from->A().noalias() += A.transpose() * weightedOmega * A;
65 from->b().noalias() -= A.transpose() * omega * _error;
66 from->A().noalias() += A.transpose() * omega * A;
69 from->unlockQuadraticForm();
74 template <
int D,
typename E,
typename VertexXiType>
75 void BaseUnaryEdge<D, E, VertexXiType>::linearizeOplus(JacobianWorkspace& jacobianWorkspace)
77 new (&_jacobianOplusXi) JacobianXiOplusType(jacobianWorkspace.workspaceForVertex(0), D, VertexXiType::Dimension);
81 template <
int D,
typename E,
typename VertexXiType>
82 void BaseUnaryEdge<D, E, VertexXiType>::linearizeOplus()
85 VertexXiType* vi =
static_cast<VertexXiType*
>(_vertices[0]);
91 vi->lockQuadraticForm();
94 const double delta = 1e-9;
95 const double scalar = 1.0 / (2*delta);
97 ErrorVector errorBeforeNumeric = _error;
99 double add_vi[VertexXiType::Dimension];
100 std::fill(add_vi, add_vi + VertexXiType::Dimension, 0.0);
102 for (
int d = 0;
d < VertexXiType::Dimension; ++
d) {
116 _jacobianOplusXi.col(d) = scalar * (error1 - _error);
119 _error = errorBeforeNumeric;
121 vi->unlockQuadraticForm();
125 template <
int D,
typename E,
typename VertexXiType>
126 void BaseUnaryEdge<D, E, VertexXiType>::initialEstimate(
const OptimizableGraph::VertexSet&, OptimizableGraph::Vertex*)
128 std::cerr <<
__PRETTY_FUNCTION__ <<
" is not implemented, please give implementation in your derived class" << std::endl;
#define __PRETTY_FUNCTION__