g2o
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 ()
 
OptimizableGraphgraph ()
 
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)
 

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

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

Definition at line 34 of file sensor_segment2d_pointline.cpp.

34 : BinarySensor<Robot2D, EdgeSE2Segment2DPointLine, WorldObjectSegment2D>(name_) {}

Member Function Documentation

void g2o::SensorSegment2DPointLine::addNoise ( EdgeType e)
virtual
bool g2o::SensorSegment2DPointLine::isVisible ( SensorSegment2DPointLine::WorldObjectType to)
protected

Definition at line 42 of file sensor_segment2d_pointline.cpp.

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

Referenced by sense().

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

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

Definition at line 106 of file sensor_segment2d_pointline.cpp.

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(), g2o::EdgeSE2Segment2DPointLine::setMeasurementFromState(), g2o::EdgeSE2Segment2DPointLine::setPointNum(), g2o::Robot< RobotPoseObject >::trajectory(), and g2o::BaseSensor::world().

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

Member Data Documentation

int g2o::SensorSegment2DPointLine::_visiblePoint
protected

Definition at line 45 of file sensor_segment2d_pointline.h.

Referenced by isVisible(), and sense().


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