g2o
Public Member Functions | Protected Member Functions | List of all members
g2o::SensorSegment2D Class Reference

#include <sensor_segment2d.h>

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW SensorSegment2D (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, EdgeSE2Segment2D, 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, EdgeSE2Segment2D, WorldObjectSegment2D >
EdgeTypemkEdge (WorldObjectType *object)
 

Additional Inherited Members

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

Constructor & Destructor Documentation

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

Definition at line 35 of file sensor_segment2d.cpp.

35  : BinarySensor<Robot2D, EdgeSE2Segment2D, WorldObjectSegment2D>(name_) {
36  cerr << "I am the constructor" << endl;
37  }

Member Function Documentation

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

Definition at line 45 of file sensor_segment2d.cpp.

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

Referenced by sense().

45  {
46  if (! _robotPoseObject)
47  return false;
48 
49  assert(to && to->vertex());
50  VertexType* v=to->vertex();
51 
52  Vector2d p1, p2;
53  SE2 iRobot=_robotPoseObject->vertex()->estimate().inverse();
54  p1 = iRobot * v->estimateP1();
55  p2 = iRobot * v->estimateP2();
56 
57  Vector3d vp1(p1.x(), p1.y(), 0.);
58  Vector3d vp2(p2.x(), p2.y(), 0.);
59  Vector3d cp=vp1.cross(vp2); // visibility check
60  if (cp[2]<0)
61  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 not been clipped do something
98  return true;
99  }
100  // if all these checks went well, we set the point
101  return false;
102  }
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::SensorSegment2D::sense ( )
virtual

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

Definition at line 104 of file sensor_segment2d.cpp.

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

104  {
106  RobotType* r= dynamic_cast<RobotType*>(robot());
107  std::list<PoseObject*>::reverse_iterator it=r->trajectory().rbegin();
108  int count = 0;
109  while (it!=r->trajectory().rend() && count < 1){
110  if (!_robotPoseObject)
111  _robotPoseObject = *it;
112  it++;
113  count++;
114  }
115  for (std::set<BaseWorldObject*>::iterator it=world()->objects().begin(); it!=world()->objects().end(); it++){
116  WorldObjectType* o=dynamic_cast<WorldObjectType*>(*it);
117  if (o && isVisible(o)){
118  EdgeType* e=mkEdge(o);
119  if (e && graph()) {
120  e->setMeasurementFromState();
121  addNoise(e);
122  graph()->addEdge(e);
123  }
124  }
125  }
126  }
bool isVisible(WorldObjectType *to)
virtual void addNoise(EdgeType *e)
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)

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