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

#include <sensor_pointxy_bearing.h>

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

Public Member Functions

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

Additional Inherited Members

- Public Types inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXYBearing, WorldObjectPointXY >
typedef Robot2D RobotType
 
typedef RobotType::PoseObject PoseObject
 
typedef RobotType::TrajectoryType TrajectoryType
 
typedef RobotType::PoseObject::VertexType PoseVertexType
 
typedef EdgeSE2PointXYBearing EdgeType
 
typedef WorldObjectPointXY WorldObjectType
 
typedef WorldObjectType::VertexType VertexType
 
typedef EdgeType::InformationType InformationType
 
- Public Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXYBearing, 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, EdgeSE2PointXYBearing, 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_bearing.h.

Constructor & Destructor Documentation

◆ SensorPointXYBearing()

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

Definition at line 35 of file sensor_pointxy_bearing.cpp.

36 : BinarySensor<Robot2D, EdgeSE2PointXYBearing, WorldObjectPointXY>(name_) {
37 _information(0, 0) = 180.0 / M_PI;
38}

References g2o::BinarySensor< Robot2D, EdgeSE2PointXYBearing, WorldObjectPointXY >::_information.

Member Function Documentation

◆ addNoise()

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

Definition at line 40 of file sensor_pointxy_bearing.cpp.

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

Referenced by sense().

◆ isVisible()

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

Definition at line 46 of file sensor_pointxy_bearing.cpp.

47 {
48 if (!_robotPoseObject) return false;
49
50 assert(to && to->vertex());
51 VertexType* v = to->vertex();
52 VertexType::EstimateType pose = v->estimate();
53 VertexType::EstimateType delta =
54 _robotPoseObject->vertex()->estimate().inverse() * pose;
55 Vector2d translation = delta;
56 double range2 = translation.squaredNorm();
57 if (range2 > _maxRange2) return false;
58 if (range2 < _minRange2) return false;
59 translation.normalize();
60 double bearing = acos(translation.x());
61 if (fabs(bearing) > _fov) return false;
62 return true;
63}
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, EdgeSE2PointXYBearing, WorldObjectPointXY >::_robotPoseObject.

Referenced by sense().

◆ sense()

void g2o::SensorPointXYBearing::sense ( )
virtual

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

Definition at line 65 of file sensor_pointxy_bearing.cpp.

65 {
67 RobotType* r = dynamic_cast<RobotType*>(robot());
68 std::list<PoseObject*>::reverse_iterator it = r->trajectory().rbegin();
69 int count = 0;
70 while (it != r->trajectory().rend() && count < 1) {
72 ++it;
73 count++;
74 }
75 for (std::set<BaseWorldObject*>::iterator it = world()->objects().begin();
76 it != world()->objects().end(); ++it) {
77 WorldObjectType* o = dynamic_cast<WorldObjectType*>(*it);
78 if (o && isVisible(o)) {
79 EdgeType* e = mkEdge(o);
80 if (e && graph()) {
81 e->setMeasurementFromState();
82 addNoise(e);
83 graph()->addEdge(e);
84 }
85 }
86 }
87}
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, EdgeSE2PointXYBearing, WorldObjectPointXY >::_robotPoseObject, g2o::OptimizableGraph::addEdge(), addNoise(), g2o::BaseSensor::graph(), isVisible(), g2o::BinarySensor< Robot2D, EdgeSE2PointXYBearing, WorldObjectPointXY >::mkEdge(), g2o::World::objects(), g2o::BaseSensor::robot(), and g2o::BaseSensor::world().


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