g2o
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
g2o::SensorPose2D Class Reference

#include <sensor_pose2d.h>

Inheritance diagram for g2o::SensorPose2D:
Inheritance graph
[legend]
Collaboration diagram for g2o::SensorPose2D:
Collaboration graph
[legend]

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SensorPose2D (const std::string &name_)
 
virtual void sense ()
 
virtual void addNoise (EdgeType *e)
 
int stepsToIgnore () const
 
void setStepsToIgnore (int stepsToIgnore_)
 
- Public Member Functions inherited from g2o::PointSensorParameters
 PointSensorParameters ()
 
double maxRange () const
 
void setMaxRange (double maxRange_)
 
double minRange () const
 
void setMinRange (double minRange_)
 
double fov () const
 
void setFov (double fov_)
 
double maxAngularDifference () const
 
void setMaxAngularDifference (double angularDifference)
 
- Public Member Functions inherited from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >
 BinarySensor (const std::string &name)
 
void setInformation (const InformationType &information_)
 
const InformationTypeinformation ()
 
- Public Member Functions inherited from g2o::BaseSensor
 BaseSensor (const std::string &name_)
 
BaseRobotrobot ()
 
void setRobot (BaseRobot *robot_)
 
Worldworld () const
 
OptimizableGraphgraph () const
 
const std::vector< Parameter * > & parameters ()
 
virtual void addParameters ()
 

Protected Member Functions

bool isVisible (WorldObjectType *to)
 
- Protected Member Functions inherited from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >
EdgeTypemkEdge (WorldObjectType *object)
 
virtual void addNoise (EdgeType *)
 

Protected Attributes

int _stepsToIgnore
 
std::set< PoseObject * > _posesToIgnore
 
- Protected Attributes inherited from g2o::PointSensorParameters
double _maxRange2
 
double _minRange2
 
double _fov
 
double _maxAngularDifference
 
- Protected Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >
PoseObject_robotPoseObject
 
InformationType _information
 
GaussianSampler< typename EdgeType::ErrorVector, InformationType_sampler
 
- Protected Attributes inherited from g2o::BaseSensor
std::string _name
 
std::vector< Parameter * > _parameters
 
BaseRobot_robot
 

Additional Inherited Members

- Public Types inherited from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >
typedef Robot2D RobotType
 
typedef RobotType::PoseObject PoseObject
 
typedef RobotType::TrajectoryType TrajectoryType
 
typedef RobotType::PoseObject::VertexType PoseVertexType
 
typedef EdgeSE2 EdgeType
 
typedef WorldObjectSE2 WorldObjectType
 
typedef WorldObjectType::VertexType VertexType
 
typedef EdgeType::InformationType InformationType
 
- Public Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 

Detailed Description

Definition at line 36 of file sensor_pose2d.h.

Constructor & Destructor Documentation

◆ SensorPose2D()

g2o::SensorPose2D::SensorPose2D ( const std::string &  name_)

Definition at line 34 of file sensor_pose2d.cpp.

35 : BinarySensor<Robot2D, EdgeSE2, WorldObjectSE2>(name_) {
36 _stepsToIgnore = 10;
37}

References _stepsToIgnore.

Member Function Documentation

◆ addNoise()

void g2o::SensorPose2D::addNoise ( EdgeType e)
virtual

Definition at line 59 of file sensor_pose2d.cpp.

59 {
62 n.fromVector(noise);
63 e->setMeasurement(e->measurement() * n);
64 e->setInformation(information());
65}
internal::BaseEdgeTraits< D >::ErrorVector ErrorVector
Definition base_edge.h:90
GaussianSampler< typename EdgeType::ErrorVector, InformationType > _sampler
Definition simulator.h:298
SampleType generateSample()
return a sample of the Gaussian distribution
Definition sampler.h:63

References g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >::_sampler, g2o::GaussianSampler< SampleType, CovarianceType >::generateSample(), and g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >::information().

Referenced by sense().

◆ isVisible()

bool g2o::SensorPose2D::isVisible ( WorldObjectType to)
protected

Definition at line 39 of file sensor_pose2d.cpp.

39 {
40 if (!_robotPoseObject) return false;
41 if (_posesToIgnore.find(to) != _posesToIgnore.end()) return false;
42
43 assert(to && to->vertex());
44 VertexType* v = to->vertex();
45 VertexType::EstimateType pose = v->estimate();
46 VertexType::EstimateType delta =
47 _robotPoseObject->vertex()->estimate().inverse() * pose;
48 Vector2d translation = delta.translation();
49 double range2 = translation.squaredNorm();
50 if (range2 > _maxRange2) return false;
51 if (range2 < _minRange2) return false;
52 translation.normalize();
53 double bearing = acos(translation.x());
54 if (fabs(bearing) > _fov) return false;
55 if (fabs(delta.rotation().angle()) > _maxAngularDifference) return false;
56 return true;
57}
std::set< PoseObject * > _posesToIgnore
Jet< T, N > acos(const Jet< T, N > &f)
Definition jet.h:458

References g2o::PointSensorParameters::_fov, g2o::PointSensorParameters::_maxAngularDifference, g2o::PointSensorParameters::_maxRange2, g2o::PointSensorParameters::_minRange2, _posesToIgnore, and g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >::_robotPoseObject.

Referenced by sense().

◆ sense()

void g2o::SensorPose2D::sense ( )
virtual

Reimplemented from g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >.

Definition at line 67 of file sensor_pose2d.cpp.

67 {
69 RobotType* r = dynamic_cast<RobotType*>(robot());
70 std::list<PoseObject*>::reverse_iterator it = r->trajectory().rbegin();
71 _posesToIgnore.clear();
72 int count = 0;
73 while (it != r->trajectory().rend() && count < _stepsToIgnore) {
75 _posesToIgnore.insert(*it);
76 ++it;
77 count++;
78 }
79 for (std::set<BaseWorldObject*>::iterator it = world()->objects().begin();
80 it != world()->objects().end(); ++it) {
81 WorldObjectType* o = dynamic_cast<WorldObjectType*>(*it);
82 if (o && isVisible(o)) {
83 EdgeType* e = mkEdge(o);
84 if (e && graph()) {
85 e->setMeasurementFromState();
86 addNoise(e);
87 graph()->addEdge(e);
88 }
89 }
90 }
91}
OptimizableGraph * graph() const
Definition simulator.cpp:76
World * world() const
Definition simulator.cpp:71
BaseRobot * robot()
Definition simulator.h:162
EdgeType * mkEdge(WorldObjectType *object)
Definition simulator.h:290
virtual void addNoise(EdgeType *e)
bool isVisible(WorldObjectType *to)
std::set< BaseWorldObject * > & objects()
Definition simulator.h:115
virtual bool addEdge(HyperGraph::Edge *e)

References _posesToIgnore, g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >::_robotPoseObject, _stepsToIgnore, g2o::OptimizableGraph::addEdge(), addNoise(), g2o::BaseSensor::graph(), isVisible(), g2o::BinarySensor< Robot2D, EdgeSE2, WorldObjectSE2 >::mkEdge(), g2o::World::objects(), g2o::BaseSensor::robot(), and g2o::BaseSensor::world().

◆ setStepsToIgnore()

void g2o::SensorPose2D::setStepsToIgnore ( int  stepsToIgnore_)
inline

Definition at line 46 of file sensor_pose2d.h.

46{ _stepsToIgnore = stepsToIgnore_; }

◆ stepsToIgnore()

int g2o::SensorPose2D::stepsToIgnore ( ) const
inline

Definition at line 45 of file sensor_pose2d.h.

45{ return _stepsToIgnore; }

Member Data Documentation

◆ _posesToIgnore

std::set<PoseObject*> g2o::SensorPose2D::_posesToIgnore
protected

Definition at line 52 of file sensor_pose2d.h.

Referenced by isVisible(), and sense().

◆ _stepsToIgnore

int g2o::SensorPose2D::_stepsToIgnore
protected

Definition at line 50 of file sensor_pose2d.h.

Referenced by sense(), and SensorPose2D().


The documentation for this class was generated from the following files: