Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 template <int D, typename E, typename VertexXiType>
00018 void BaseUnaryEdge<D, E, VertexXiType>::constructQuadraticForm()
00019 {
00020 VertexXiType* from=static_cast<VertexXiType*>(_vertices[0]);
00021
00022
00023 const JacobianXiOplusType& A = jacobianOplusXi();
00024 const InformationType& omega = _information;
00025
00026 bool istatus = !from->fixed();
00027 if (istatus) {
00028 #ifdef G2O_OPENMP
00029 from->lockQuadraticForm();
00030 #endif
00031 from->b().noalias() -= A.transpose() * omega * _error;
00032 from->A().noalias() += A.transpose() * omega * A;
00033 #ifdef G2O_OPENMP
00034 from->unlockQuadraticForm();
00035 #endif
00036 }
00037 }
00038
00039 template <int D, typename E, typename VertexXiType>
00040 void BaseUnaryEdge<D, E, VertexXiType>::linearizeOplus()
00041 {
00042
00043 VertexXiType* vi = static_cast<VertexXiType*>(_vertices[0]);
00044
00045 if (vi->fixed())
00046 return;
00047
00048 #ifdef G2O_OPENMP
00049 vi->lockQuadraticForm();
00050 #endif
00051
00052 const double delta = 1e-9;
00053 const double scalar = 1.0 / (2*delta);
00054 ErrorVector error1;
00055 ErrorVector errorBeforeNumeric = _error;
00056
00057 double add_vi[VertexXiType::Dimension];
00058 std::fill(add_vi, add_vi + VertexXiType::Dimension, 0.0);
00059
00060 for (int d = 0; d < VertexXiType::Dimension; ++d) {
00061 vi->push();
00062 add_vi[d] = delta;
00063 vi->oplus(add_vi);
00064 computeError();
00065 error1 = _error;
00066 vi->pop();
00067 vi->push();
00068 add_vi[d] = -delta;
00069 vi->oplus(add_vi);
00070 computeError();
00071 vi->pop();
00072 add_vi[d] = 0.0;
00073
00074 _jacobianOplusXi.col(d) = scalar * (error1 - _error);
00075 }
00076
00077 _error = errorBeforeNumeric;
00078 #ifdef G2O_OPENMP
00079 vi->unlockQuadraticForm();
00080 #endif
00081 }
00082
00083 template <int D, typename E, typename VertexXiType>
00084 void BaseUnaryEdge<D, E, VertexXiType>::initialEstimate(const OptimizableGraph::VertexSet&, OptimizableGraph::Vertex*)
00085 {
00086 std::cerr << __PRETTY_FUNCTION__ << " is not implemented, please give implementation in your derived class" << std::endl;
00087 }