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

#include <sensor_pointxy.h>

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SensorPointXY (const std::string &name_)
 
virtual void sense ()
 
virtual void addNoise (EdgeType *e)
 
- 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, EdgeSE2PointXY, WorldObjectPointXY >
 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, EdgeSE2PointXY, WorldObjectPointXY >
EdgeTypemkEdge (WorldObjectType *object)
 
virtual void addNoise (EdgeType *)
 

Additional Inherited Members

- Public Types inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >
typedef Robot2D RobotType
 
typedef RobotType::PoseObject PoseObject
 
typedef RobotType::TrajectoryType TrajectoryType
 
typedef RobotType::PoseObject::VertexType PoseVertexType
 
typedef EdgeSE2PointXY EdgeType
 
typedef WorldObjectPointXY WorldObjectType
 
typedef WorldObjectType::VertexType VertexType
 
typedef EdgeType::InformationType InformationType
 
- Public Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 
- Protected Attributes inherited from g2o::PointSensorParameters
double _maxRange2
 
double _minRange2
 
double _fov
 
double _maxAngularDifference
 
- Protected Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >
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
 

Detailed Description

Definition at line 36 of file sensor_pointxy.h.

Constructor & Destructor Documentation

◆ SensorPointXY()

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

Definition at line 35 of file sensor_pointxy.cpp.

36 : BinarySensor<Robot2D, EdgeSE2PointXY, WorldObjectPointXY>(name_) {}

Member Function Documentation

◆ addNoise()

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

Definition at line 38 of file sensor_pointxy.cpp.

38 {
40 e->setMeasurement(e->measurement() + n);
41 e->setInformation(information());
42}
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, EdgeSE2PointXY, WorldObjectPointXY >::_sampler, g2o::GaussianSampler< SampleType, CovarianceType >::generateSample(), and g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >::information().

Referenced by sense().

◆ isVisible()

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

Definition at line 44 of file sensor_pointxy.cpp.

44 {
45 if (!_robotPoseObject) return false;
46
47 assert(to && to->vertex());
48 VertexType* v = to->vertex();
49 VertexType::EstimateType pose = v->estimate();
50 VertexType::EstimateType delta =
51 _robotPoseObject->vertex()->estimate().inverse() * pose;
52 Vector2d translation = delta;
53 double range2 = translation.squaredNorm();
54 if (range2 > _maxRange2) return false;
55 if (range2 < _minRange2) return false;
56 translation.normalize();
57 double bearing = acos(translation.x());
58 if (fabs(bearing) > _fov) return false;
59 return true;
60}
Jet< T, N > acos(const Jet< T, N > &f)
Definition jet.h:458

References g2o::PointSensorParameters::_fov, g2o::PointSensorParameters::_maxRange2, g2o::PointSensorParameters::_minRange2, and g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >::_robotPoseObject.

Referenced by sense().

◆ sense()

void g2o::SensorPointXY::sense ( )
virtual

Reimplemented from g2o::BinarySensor< Robot2D, EdgeSE2PointXY, WorldObjectPointXY >.

Definition at line 62 of file sensor_pointxy.cpp.

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

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


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