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

#include <sensor_segment2d_line.h>

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

Public Member Functions

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

Additional Inherited Members

- Public Types inherited from g2o::BinarySensor< Robot2D, EdgeSE2Segment2DLine, WorldObjectSegment2D >
typedef Robot2D RobotType
 
typedef RobotType::PoseObject PoseObject
 
typedef RobotType::TrajectoryType TrajectoryType
 
typedef RobotType::PoseObject::VertexType PoseVertexType
 
typedef EdgeSE2Segment2DLine EdgeType
 
typedef WorldObjectSegment2D WorldObjectType
 
typedef WorldObjectType::VertexType VertexType
 
typedef EdgeType::InformationType InformationType
 
- Public Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2Segment2DLine, WorldObjectSegment2D >
 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, EdgeSE2Segment2DLine, 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
 

Detailed Description

Definition at line 37 of file sensor_segment2d_line.h.

Constructor & Destructor Documentation

◆ SensorSegment2DLine()

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

Definition at line 37 of file sensor_segment2d_line.cpp.

38 : BinarySensor<Robot2D, EdgeSE2Segment2DLine, WorldObjectSegment2D>(name_) {
39}

Member Function Documentation

◆ addNoise()

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

Definition at line 41 of file sensor_segment2d_line.cpp.

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

Referenced by sense().

◆ isVisible()

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

Definition at line 47 of file sensor_segment2d_line.cpp.

47 {
48 if (!_robotPoseObject) return false;
49
50 assert(to && to->vertex());
51 VertexType* v = to->vertex();
52
53 Vector2d p1, p2;
54 SE2 iRobot = _robotPoseObject->vertex()->estimate().inverse();
55 p1 = iRobot * v->estimateP1();
56 p2 = iRobot * v->estimateP2();
57
58 Vector3d vp1(p1.x(), p1.y(), 0.);
59 Vector3d vp2(p2.x(), p2.y(), 0.);
60 Vector3d cp = vp1.cross(vp2); // visibility check
61 if (cp[2] < 0) return false;
62
63 int circleClip = clipSegmentCircle(p1, p2, sqrt(_maxRange2));
64 bool clip1 = false, clip2 = false;
65 switch (circleClip) {
66 case -1:
67 return false;
68 case 0:
69 clip1 = true;
70 break;
71 case 1:
72 clip2 = true;
73 break;
74 case 3:
75 clip1 = true;
76 clip2 = true;
77 break;
78 default:;
79 }
80
81 int fovClip = clipSegmentFov(p1, p2, -_fov, +_fov);
82 switch (fovClip) {
83 case -1:
84 return false;
85 case 0:
86 clip1 = true;
87 break;
88 case 1:
89 clip2 = true;
90 break;
91 case 3:
92 clip1 = true;
93 clip2 = true;
94 break;
95 default:;
96 }
97 if (clip1 && clip2) // only if both endpoints have been clipped do something
98 return true;
99 // if all these checks went well, we set the point
100 return false;
101}
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, EdgeSE2Segment2DLine, WorldObjectSegment2D >::_robotPoseObject, g2o::clipSegmentCircle(), g2o::clipSegmentFov(), and g2o::SE2::inverse().

Referenced by sense().

◆ sense()

void g2o::SensorSegment2DLine::sense ( )
virtual

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

Definition at line 103 of file sensor_segment2d_line.cpp.

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

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


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