Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "vertigo/g2o/edge_se3Switchable.h"
00012 #include "vertigo/g2o/vertex_switchLinear.h"
00013 #include "g2o/types/slam3d/vertex_se3.h"
00014 #include "g2o/types/slam3d/isometry3d_gradients.h"
00015
00016
00017 using namespace std;
00018 using namespace Eigen;
00019
00020
00021
00022 EdgeSE3Switchable::EdgeSE3Switchable() : g2o::BaseMultiEdge<6, Eigen::Isometry3d>()
00023 {
00024 resize(3);
00025 _jacobianOplus[0].resize(6,6);
00026 _jacobianOplus[1].resize(6,6);
00027 _jacobianOplus[2].resize(6,1);
00028
00029 }
00030
00031 bool EdgeSE3Switchable::read(std::istream& is)
00032 {
00033 g2o::Vector7d meas;
00034 for (int i=0; i<7; i++)
00035 is >> meas[i];
00036
00037 Vector4d::MapType(meas.data()+3).normalize();
00038 setMeasurement(g2o::internal::fromVectorQT(meas));
00039
00040 for (int i=0; i<6; i++)
00041 for (int j=i; j<6; j++) {
00042 is >> information()(i,j);
00043 if (i!=j)
00044 information()(j,i) = information()(i,j);
00045 }
00046 return true;
00047
00048 }
00049
00050 bool EdgeSE3Switchable::write(std::ostream& os) const
00051 {
00052 g2o::Vector7d meas = g2o::internal::toVectorQT(measurement());
00053 for (int i=0; i<7; i++) os << meas[i] << " ";
00054 for (int i = 0; i < 6; ++i)
00055 for (int j = i; j < 6; ++j)
00056 os << " " << information()(i, j);
00057 return os.good();
00058 }
00059
00060
00061 void EdgeSE3Switchable::linearizeOplus()
00062 {
00063
00064 g2o::VertexSE3* from = static_cast<g2o::VertexSE3*>(_vertices[0]);
00065 g2o::VertexSE3* to = static_cast<g2o::VertexSE3*>(_vertices[1]);
00066 const VertexSwitchLinear* vSwitch = static_cast<const VertexSwitchLinear*>(_vertices[2]);
00067
00068 Eigen::Isometry3d E;
00069 const Eigen::Isometry3d& Xi=from->estimate();
00070 const Eigen::Isometry3d& Xj=to->estimate();
00071 const Eigen::Isometry3d& Z=_measurement;
00072 g2o::internal::computeEdgeSE3Gradient(E, _jacobianOplus[0], _jacobianOplus[1], Z, Xi, Xj);
00073
00074 _jacobianOplus[0]*=vSwitch->estimate();
00075 _jacobianOplus[1]*=vSwitch->estimate();
00076
00077
00078 _jacobianOplus[2].setZero();
00079 _jacobianOplus[2] = g2o::internal::toVectorMQT(E) * vSwitch->gradient();
00080 }
00081
00082
00083
00084 void EdgeSE3Switchable::computeError()
00085 {
00086 const g2o::VertexSE3* v1 = dynamic_cast<const g2o::VertexSE3*>(_vertices[0]);
00087 const g2o::VertexSE3* v2 = dynamic_cast<const g2o::VertexSE3*>(_vertices[1]);
00088 const VertexSwitchLinear* v3 = static_cast<const VertexSwitchLinear*>(_vertices[2]);
00089
00090 Eigen::Isometry3d delta = _inverseMeasurement * (v1->estimate().inverse()*v2->estimate());
00091 _error = g2o::internal::toVectorMQT(delta) * v3->estimate();
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121