Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "edge_se2MaxMixture.h"
00010
00011 using namespace std;
00012 using namespace Eigen;
00013
00014
00015 EdgeSE2MaxMixture::EdgeSE2MaxMixture()
00016 {
00017 nullHypothesisMoreLikely = false;
00018 }
00019
00020
00021 bool EdgeSE2MaxMixture::read(std::istream& is)
00022 {
00023 Vector3d p;
00024 is >> weight >> p[0] >> p[1] >> p[2];
00025 setMeasurement(g2o::SE2(p));
00026 _inverseMeasurement = measurement().inverse();
00027
00028
00029 for (int i = 0; i < 3; ++i)
00030 for (int j = i; j < 3; ++j) {
00031 is >> information()(i, j);
00032 if (i != j)
00033 information()(j, i) = information()(i, j);
00034 }
00035
00036 information_constraint = _information;
00037 nu_constraint = 1.0/sqrt(information_constraint.inverse().determinant());
00038 information_nullHypothesis = information_constraint*weight;
00039 nu_nullHypothesis = 1.0/sqrt(information_nullHypothesis.inverse().determinant());
00040
00041 return true;
00042 }
00043
00044 bool EdgeSE2MaxMixture::write(std::ostream& os) const
00045 {
00046 Vector3d p = measurement().toVector();
00047 os << p.x() << " " << p.y() << " " << p.z();
00048 for (int i = 0; i < 3; ++i)
00049 for (int j = i; j < 3; ++j)
00050 os << " " << information()(i, j);
00051 return os.good();
00052 }
00053
00054
00055 void EdgeSE2MaxMixture::linearizeOplus()
00056 {
00057 g2o::EdgeSE2::linearizeOplus();
00058 if (nullHypothesisMoreLikely) {
00059 _jacobianOplusXi *= weight;
00060 _jacobianOplusXj *= weight;
00061 }
00062 }
00063
00064
00065 void EdgeSE2MaxMixture::computeError()
00066 {
00067
00068 g2o::EdgeSE2::computeError();
00069
00070
00071 double mahal_constraint = _error.transpose() * information_constraint * _error;
00072 double likelihood_constraint = nu_constraint * exp(-mahal_constraint);
00073
00074 double mahal_nullHypothesis = _error.transpose() * (information_nullHypothesis) * _error;
00075 double likelihood_nullHypothesis = nu_nullHypothesis * exp(-mahal_nullHypothesis);
00076
00077
00078 if (likelihood_nullHypothesis > likelihood_constraint) {
00079 _information = information_nullHypothesis;
00080 nullHypothesisMoreLikely = true;
00081 }
00082 else {
00083 _information = information_constraint;
00084 nullHypothesisMoreLikely = false;
00085 }
00086
00087
00088 }
00089
00090
00091
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
00122