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

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

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

Definition at line 34 of file sensor_segment2d_line.cpp.

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

Member Function Documentation

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

Definition at line 43 of file sensor_segment2d_line.cpp.

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

Referenced by sense().

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

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

Definition at line 102 of file sensor_segment2d_line.cpp.

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

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