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

#include <sensor_segment2d_pointline.h>

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SensorSegment2DPointLine (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, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >
 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, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >
EdgeTypemkEdge (WorldObjectType *object)
 
virtual void addNoise (EdgeType *)
 

Protected Attributes

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

Detailed Description

Definition at line 37 of file sensor_segment2d_pointline.h.

Constructor & Destructor Documentation

◆ SensorSegment2DPointLine()

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

Definition at line 37 of file sensor_segment2d_pointline.cpp.

38 : BinarySensor<Robot2D, EdgeSE2Segment2DPointLine, WorldObjectSegment2D>(
39 name_),
40 _visiblePoint(0) {}

Member Function Documentation

◆ addNoise()

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

Definition at line 42 of file sensor_segment2d_pointline.cpp.

42 {
44 e->setMeasurement(e->measurement() + n);
45 e->setInformation(information());
46}
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, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >::_sampler, g2o::GaussianSampler< SampleType, CovarianceType >::generateSample(), and g2o::BinarySensor< Robot2D, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >::information().

Referenced by sense().

◆ isVisible()

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

Definition at line 48 of file sensor_segment2d_pointline.cpp.

49 {
50 if (!_robotPoseObject) return false;
51
52 assert(to && to->vertex());
53 VertexType* v = to->vertex();
54
55 Vector2d p1, p2;
56 SE2 iRobot = _robotPoseObject->vertex()->estimate().inverse();
57 p1 = iRobot * v->estimateP1();
58 p2 = iRobot * v->estimateP2();
59
60 Vector3d vp1(p1.x(), p1.y(), 0.);
61 Vector3d vp2(p2.x(), p2.y(), 0.);
62 Vector3d cp = vp1.cross(vp2); // visibility check
63 if (cp[2] < 0) return false;
64
65 int circleClip = clipSegmentCircle(p1, p2, sqrt(_maxRange2));
66 bool clip1 = false, clip2 = false;
67 switch (circleClip) {
68 case -1:
69 return false;
70 case 0:
71 clip1 = true;
72 break;
73 case 1:
74 clip2 = true;
75 break;
76 case 3:
77 clip1 = true;
78 clip2 = true;
79 break;
80 default:;
81 }
82
83 int fovClip = clipSegmentFov(p1, p2, -_fov, +_fov);
84 switch (fovClip) {
85 case -1:
86 return false;
87 case 0:
88 clip1 = true;
89 break;
90 case 1:
91 clip2 = true;
92 break;
93 case 3:
94 clip1 = true;
95 clip2 = true;
96 break;
97 default:;
98 }
99 if ((clip1 && !clip2)) {
100 _visiblePoint = 1;
101 return true;
102 }
103 if ((!clip1 && clip2)) {
104 _visiblePoint = 0;
105 return true;
106 }
107 return false;
108}
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition jet.h:444
int clipSegmentCircle(Eigen::Vector2d &p1, Eigen::Vector2d &p2, double r)
Definition simutils.cpp:37
int clipSegmentFov(Eigen::Vector2d &p1, Eigen::Vector2d &p2, double min, double max)
Definition simutils.cpp:107

References g2o::PointSensorParameters::_fov, g2o::PointSensorParameters::_maxRange2, g2o::BinarySensor< Robot2D, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >::_robotPoseObject, _visiblePoint, g2o::clipSegmentCircle(), g2o::clipSegmentFov(), and g2o::SE2::inverse().

Referenced by sense().

◆ sense()

void g2o::SensorSegment2DPointLine::sense ( )
virtual

Reimplemented from g2o::BinarySensor< Robot2D, EdgeSE2Segment2DPointLine, WorldObjectSegment2D >.

Definition at line 110 of file sensor_segment2d_pointline.cpp.

110 {
112 RobotType* r = dynamic_cast<RobotType*>(robot());
113 std::list<PoseObject*>::reverse_iterator it = r->trajectory().rbegin();
114 int count = 0;
115 while (it != r->trajectory().rend() && count < 1) {
117 ++it;
118 count++;
119 }
120 for (std::set<BaseWorldObject*>::iterator it = world()->objects().begin();
121 it != world()->objects().end(); ++it) {
122 WorldObjectType* o = dynamic_cast<WorldObjectType*>(*it);
123 if (o && isVisible(o)) {
124 EdgeType* e = mkEdge(o);
125 if (e && graph()) {
126 e->setPointNum(_visiblePoint);
127 e->setMeasurementFromState();
128 addNoise(e);
129 graph()->addEdge(e);
130 }
131 }
132 }
133}
OptimizableGraph * graph() const
Definition simulator.cpp:76
World * world() const
Definition simulator.cpp:71
BaseRobot * robot()
Definition simulator.h:162
std::set< BaseWorldObject * > & objects()
Definition simulator.h:115
virtual bool addEdge(HyperGraph::Edge *e)

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

Member Data Documentation

◆ _visiblePoint

int g2o::SensorSegment2DPointLine::_visiblePoint
protected

Definition at line 49 of file sensor_segment2d_pointline.h.

Referenced by isVisible(), and sense().


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