g2o
Loading...
Searching...
No Matches
sensor_pose3d_offset.cpp
Go to the documentation of this file.
1// g2o - General Graph Optimization
2// Copyright (C) 2011 G. Grisetti, R. Kuemmerle, W. Burgard
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
28
29#include <cassert>
30
32
33namespace g2o {
34using namespace std;
35using namespace Eigen;
36
40 _stepsToIgnore = 10;
41 _information.setIdentity();
42 _information *= 100;
43 _information(3, 3) = 10000;
44 _information(4, 4) = 10000;
45 _information(5, 5) = 1000;
47}
48
56
60 e->setMeasurement(e->measurement() * n);
61 e->setInformation(information());
62}
63
65 if (!_robotPoseObject) return false;
66 if (_posesToIgnore.find(to) != _posesToIgnore.end()) return false;
67
68 assert(to && to->vertex());
69 VertexType* v = to->vertex();
70 VertexType::EstimateType pose = v->estimate();
71 VertexType::EstimateType delta =
72 _robotPoseObject->vertex()->estimate().inverse() * pose;
73 Vector3d translation = delta.translation();
74 double range2 = translation.squaredNorm();
75 if (range2 > _maxRange2) return false;
76 if (range2 < _minRange2) return false;
77 translation.normalize();
78 double bearing = acos(translation.x());
79 if (fabs(bearing) > _fov) return false;
80 AngleAxisd a(delta.rotation());
81 if (fabs(a.angle()) > _maxAngularDifference) return false;
82 return true;
83}
84
87 RobotType* r = dynamic_cast<RobotType*>(robot());
88 std::list<PoseObject*>::reverse_iterator it = r->trajectory().rbegin();
89 _posesToIgnore.clear();
90 int count = 0;
91 while (it != r->trajectory().rend() && count < _stepsToIgnore) {
93 _posesToIgnore.insert(*it);
94 ++it;
95 count++;
96 }
97 for (std::set<BaseWorldObject*>::iterator it = world()->objects().begin();
98 it != world()->objects().end(); ++it) {
99 WorldObjectType* o = dynamic_cast<WorldObjectType*>(*it);
100 if (o && isVisible(o)) {
101 EdgeType* e = mkEdge(o);
102 if (e && graph()) {
103 e->setParameterId(0, _offsetParam1->id());
104 e->setParameterId(1, _offsetParam2->id());
105 graph()->addEdge(e);
106 e->setMeasurementFromState();
107 addNoise(e);
108 }
109 }
110 }
111}
112
113} // namespace g2o
internal::BaseEdgeTraits< D >::ErrorVector ErrorVector
Definition base_edge.h:90
OptimizableGraph * graph() const
Definition simulator.cpp:76
World * world() const
Definition simulator.cpp:71
BaseRobot * robot()
Definition simulator.h:162
void setInformation(const InformationType &information_)
Definition simulator.h:251
GaussianSampler< typename EdgeType::ErrorVector, InformationType > _sampler
Definition simulator.h:298
SampleType generateSample()
return a sample of the Gaussian distribution
Definition sampler.h:63
int id() const
Definition parameter.h:44
bool isVisible(WorldObjectType *to)
ParameterSE3Offset * _offsetParam1
std::set< PoseObject * > _posesToIgnore
ParameterSE3Offset * _offsetParam2
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SensorPose3DOffset(const std::string &name_)
std::set< BaseWorldObject * > & objects()
Definition simulator.h:115
bool addParameter(Parameter *p)
Definition jet.h:938
Isometry3 fromVectorMQT(const Vector6 &v)
WorldObject< VertexSE3 > WorldObjectSE3
Robot< WorldObjectSE3 > Robot3D
Definition jet.h:876
virtual bool addEdge(HyperGraph::Edge *e)