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

#include <sensor_pointxy_offset.h>

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

Public Member Functions

 SensorPointXYOffset (const std::string &name_)
 
virtual void sense ()
 
virtual void addNoise (EdgeType *e)
 
virtual void addParameters ()
 
- 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, EdgeSE2PointXYOffset, WorldObjectPointXY >
 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 ()
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef PoseVertexType::EstimateType RobotPoseType
 
- Public Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 

Protected Member Functions

bool isVisible (WorldObjectType *to)
 
- Protected Member Functions inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >
EdgeTypemkEdge (WorldObjectType *object)
 
virtual void addNoise (EdgeType *)
 

Protected Attributes

ParameterSE2Offset_offsetParam
 
RobotPoseType _sensorPose
 
- Protected Attributes inherited from g2o::PointSensorParameters
double _maxRange2
 
double _minRange2
 
double _fov
 
double _maxAngularDifference
 
- Protected Attributes inherited from g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >
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, EdgeSE2PointXYOffset, WorldObjectPointXY >
typedef Robot2D RobotType
 
typedef RobotType::PoseObject PoseObject
 
typedef RobotType::TrajectoryType TrajectoryType
 
typedef RobotType::PoseObject::VertexType PoseVertexType
 
typedef EdgeSE2PointXYOffset EdgeType
 
typedef WorldObjectPointXY WorldObjectType
 
typedef WorldObjectType::VertexType VertexType
 
typedef EdgeType::InformationType InformationType
 

Detailed Description

Definition at line 36 of file sensor_pointxy_offset.h.

Constructor & Destructor Documentation

◆ SensorPointXYOffset()

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

Member Function Documentation

◆ addNoise()

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

Definition at line 70 of file sensor_pointxy_offset.cpp.

70 {
72 e->setMeasurement(e->measurement() + n);
73 e->setInformation(information());
74}
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, EdgeSE2PointXYOffset, WorldObjectPointXY >::_sampler, g2o::GaussianSampler< SampleType, CovarianceType >::generateSample(), and g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >::information().

Referenced by sense().

◆ addParameters()

void g2o::SensorPointXYOffset::addParameters ( )
virtual

Reimplemented from g2o::BaseSensor.

Definition at line 64 of file sensor_pointxy_offset.cpp.

64 {
65 if (!_offsetParam) _offsetParam = new ParameterSE2Offset();
66 assert(world());
68}
World * world() const
Definition simulator.cpp:71
bool addParameter(Parameter *p)

References _offsetParam, g2o::World::addParameter(), and g2o::BaseSensor::world().

◆ isVisible()

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

Definition at line 46 of file sensor_pointxy_offset.cpp.

46 {
47 if (!_robotPoseObject) return false;
48 assert(to && to->vertex());
49 VertexType* v = to->vertex();
50 VertexType::EstimateType pose = v->estimate();
51 VertexType::EstimateType delta = _sensorPose.inverse() * pose;
52 Vector2d translation = delta;
53 double range2 = translation.squaredNorm();
54 if (range2 > _maxRange2) return false;
55 if (range2 < _minRange2) return false;
56 translation.normalize();
57 // the cameras have the z in front
58 double bearing = atan2(translation.y(), translation.x());
59 if (fabs(bearing) > _fov) return false;
60 // cerr <<"a";
61 return true;
62}
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
Definition jet.h:730

References g2o::PointSensorParameters::_fov, g2o::PointSensorParameters::_maxRange2, g2o::PointSensorParameters::_minRange2, g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >::_robotPoseObject, and _sensorPose.

Referenced by sense().

◆ sense()

void g2o::SensorPointXYOffset::sense ( )
virtual

Reimplemented from g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >.

Definition at line 76 of file sensor_pointxy_offset.cpp.

76 {
77 if (!_offsetParam) {
78 return;
79 }
81 RobotType* r = dynamic_cast<RobotType*>(robot());
82 std::list<PoseObject*>::reverse_iterator it = r->trajectory().rbegin();
83 int count = 0;
84 while (it != r->trajectory().rend() && count < 1) {
86 ++it;
87 count++;
88 }
89 if (!_robotPoseObject) return;
90 _sensorPose = _robotPoseObject->vertex()->estimate() * _offsetParam->offset();
91 for (std::set<BaseWorldObject*>::iterator it = world()->objects().begin();
92 it != world()->objects().end(); ++it) {
93 WorldObjectType* o = dynamic_cast<WorldObjectType*>(*it);
94 if (o && isVisible(o)) {
95 EdgeType* e = mkEdge(o);
96 if (e && graph()) {
97 e->setParameterId(0, _offsetParam->id());
98 graph()->addEdge(e);
99 e->setMeasurementFromState();
100 addNoise(e);
101 }
102 }
103 }
104}
OptimizableGraph * graph() const
Definition simulator.cpp:76
BaseRobot * robot()
Definition simulator.h:162
int id() const
Definition parameter.h:44
bool isVisible(WorldObjectType *to)
virtual void addNoise(EdgeType *e)
std::set< BaseWorldObject * > & objects()
Definition simulator.h:115
virtual bool addEdge(HyperGraph::Edge *e)

References _offsetParam, g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >::_robotPoseObject, _sensorPose, g2o::OptimizableGraph::addEdge(), addNoise(), g2o::BaseSensor::graph(), g2o::Parameter::id(), isVisible(), g2o::BinarySensor< Robot2D, EdgeSE2PointXYOffset, WorldObjectPointXY >::mkEdge(), g2o::World::objects(), g2o::ParameterSE2Offset::offset(), g2o::BaseSensor::robot(), and g2o::BaseSensor::world().

Member Data Documentation

◆ _offsetParam

ParameterSE2Offset* g2o::SensorPointXYOffset::_offsetParam
protected

Definition at line 49 of file sensor_pointxy_offset.h.

Referenced by addParameters(), sense(), and SensorPointXYOffset().

◆ _sensorPose

RobotPoseType g2o::SensorPointXYOffset::_sensorPose
protected

Definition at line 50 of file sensor_pointxy_offset.h.

Referenced by isVisible(), and sense().

◆ RobotPoseType

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef PoseVertexType::EstimateType g2o::SensorPointXYOffset::RobotPoseType

Definition at line 41 of file sensor_pointxy_offset.h.


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