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;
32 assert(0 &&
"error resizing unary edge where size != 1");
34 BaseEdge<D, E>::resize(size);
37 template <
int D,
typename E,
typename VertexXiType>
38 bool BaseUnaryEdge<D, E, VertexXiType>::allVerticesFixed()
const 40 return static_cast<const VertexXiType*
> (_vertices[0])->fixed();
43 template <
int D,
typename E,
typename VertexXiType>
44 OptimizableGraph::Vertex* BaseUnaryEdge<D, E, VertexXiType>::createVertex(
int i)
48 return new VertexXiType();
51 template <
int D,
typename E,
typename VertexXiType>
52 void BaseUnaryEdge<D, E, VertexXiType>::constructQuadraticForm()
54 VertexXiType* from=
static_cast<VertexXiType*
>(_vertices[0]);
57 const JacobianXiOplusType& A = jacobianOplusXi();
58 const InformationType& omega = _information;
60 bool istatus = !from->fixed();
63 from->lockQuadraticForm();
65 if (this->robustKernel()) {
66 double error = this->chi2();
68 this->robustKernel()->robustify(error, rho);
69 InformationType weightedOmega = this->robustInformation(rho);
71 from->b().noalias() -= rho[1] * A.transpose() * omega * _error;
72 from->A().noalias() += A.transpose() * weightedOmega * A;
74 from->b().noalias() -= A.transpose() * omega * _error;
75 from->A().noalias() += A.transpose() * omega * A;
78 from->unlockQuadraticForm();
83 template <
int D,
typename E,
typename VertexXiType>
84 void BaseUnaryEdge<D, E, VertexXiType>::linearizeOplus(JacobianWorkspace& jacobianWorkspace)
86 new (&_jacobianOplusXi) JacobianXiOplusType(jacobianWorkspace.workspaceForVertex(0), D, VertexXiType::Dimension);
90 template <
int D,
typename E,
typename VertexXiType>
91 void BaseUnaryEdge<D, E, VertexXiType>::linearizeOplus()
94 VertexXiType* vi =
static_cast<VertexXiType*
>(_vertices[0]);
100 vi->lockQuadraticForm();
103 const double delta = 1e-9;
104 const double scalar = 1.0 / (2*delta);
106 ErrorVector errorBeforeNumeric = _error;
108 double add_vi[VertexXiType::Dimension];
109 std::fill(add_vi, add_vi + VertexXiType::Dimension, 0.0);
111 for (
int d = 0; d < VertexXiType::Dimension; ++d) {
125 _jacobianOplusXi.col(d) = scalar * (error1 - _error);
128 _error = errorBeforeNumeric;
130 vi->unlockQuadraticForm();
134 template <
int D,
typename E,
typename VertexXiType>
135 void BaseUnaryEdge<D, E, VertexXiType>::initialEstimate(
const OptimizableGraph::VertexSet&, OptimizableGraph::Vertex*)
137 std::cerr <<
__PRETTY_FUNCTION__ <<
" is not implemented, please give implementation in your derived class" << std::endl;
#define __PRETTY_FUNCTION__
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D