g2o
Loading...
Searching...
No Matches
g2o::SensorPointXYZDepth Class Reference

#include <sensor_pointxyz_depth.h>

Inheritance diagram for g2o::SensorPointXYZDepth:
Collaboration diagram for g2o::SensorPointXYZDepth:

Public Member Functions

 SensorPointXYZDepth (const std::string &name_)
virtual void sense ()
virtual void addParameters ()
ParameterSE3Offset * offsetParam ()
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< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >
 BinarySensor (const std::string &name)
void setInformation (const InformationType &information_)
const InformationType & information ()
Public Member Functions inherited from g2o::BaseSensor
 BaseSensor (const std::string &name_)
BaseRobot * robot ()
void setRobot (BaseRobot *robot_)
World * world () const
OptimizableGraph * graph () const
const std::vector< Parameter * > & parameters ()

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef PoseVertexType::EstimateType RobotPoseType
Public Attributes inherited from g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Protected Member Functions

bool isVisible (WorldObjectType *to)
Protected Member Functions inherited from g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >
EdgeType * mkEdge (WorldObjectType *object)
virtual void addNoise (EdgeType *)

Protected Attributes

RobotPoseType _sensorPose
ParameterSE3Offset * _offsetParam
Protected Attributes inherited from g2o::PointSensorParameters
double _maxRange2
double _minRange2
double _fov
double _maxAngularDifference
Protected Attributes inherited from g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >
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< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >
typedef Robot3D RobotType
typedef RobotType::PoseObject PoseObject
typedef RobotType::TrajectoryType TrajectoryType
typedef RobotType::PoseObject::VertexType PoseVertexType
typedef EdgeSE3PointXYZDepth EdgeType
typedef WorldObjectTrackXYZ WorldObjectType
typedef WorldObjectType::VertexType VertexType
typedef EdgeType::InformationType InformationType

Detailed Description

Definition at line 35 of file sensor_pointxyz_depth.h.

Constructor & Destructor Documentation

◆ SensorPointXYZDepth()

Member Function Documentation

◆ addNoise()

void g2o::SensorPointXYZDepth::addNoise ( EdgeType * e)

Definition at line 67 of file sensor_pointxyz_depth.cpp.

67 {
68 EdgeType::ErrorVector n = _sampler.generateSample();
69 e->setMeasurement(e->measurement() + n);
70 e->setInformation(information());
71}
GaussianSampler< typename EdgeType::ErrorVector, InformationType > _sampler
Definition simulator.h:298

References g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >::_sampler, and g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >::information().

Referenced by sense().

◆ addParameters()

void g2o::SensorPointXYZDepth::addParameters ( )
virtual

Reimplemented from g2o::BaseSensor.

Definition at line 61 of file sensor_pointxyz_depth.cpp.

61 {
62 if (!_offsetParam) _offsetParam = new ParameterCamera();
63 assert(world());
65}
World * world() const
Definition simulator.cpp:71
bool addParameter(Parameter *p)

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

◆ isVisible()

bool g2o::SensorPointXYZDepth::isVisible ( WorldObjectType * to)
protected

Definition at line 44 of file sensor_pointxyz_depth.cpp.

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

References g2o::PointSensorParameters::_fov, g2o::PointSensorParameters::_maxRange2, g2o::PointSensorParameters::_minRange2, g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >::_robotPoseObject, _sensorPose, and g2o::BaseVertex< D, T >::estimate().

Referenced by sense().

◆ offsetParam()

ParameterSE3Offset * g2o::SensorPointXYZDepth::offsetParam ( )
inline

Definition at line 44 of file sensor_pointxyz_depth.h.

44{ return _offsetParam; };

References _offsetParam.

Referenced by main().

◆ sense()

void g2o::SensorPointXYZDepth::sense ( )
virtual

Reimplemented from g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >.

Definition at line 73 of file sensor_pointxyz_depth.cpp.

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

References _offsetParam, g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >::_robotPoseObject, _sensorPose, g2o::OptimizableGraph::addEdge(), addNoise(), g2o::BaseSensor::graph(), isVisible(), g2o::BinarySensor< Robot3D, EdgeSE3PointXYZDepth, WorldObjectTrackXYZ >::mkEdge(), g2o::World::objects(), g2o::BaseSensor::robot(), g2o::Robot< RobotPoseObject >::trajectory(), and g2o::BaseSensor::world().

Member Data Documentation

◆ _offsetParam

ParameterSE3Offset* g2o::SensorPointXYZDepth::_offsetParam
protected

Definition at line 50 of file sensor_pointxyz_depth.h.

Referenced by addParameters(), offsetParam(), sense(), and SensorPointXYZDepth().

◆ _sensorPose

RobotPoseType g2o::SensorPointXYZDepth::_sensorPose
protected

Definition at line 49 of file sensor_pointxyz_depth.h.

Referenced by isVisible(), and sense().

◆ RobotPoseType

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef PoseVertexType::EstimateType g2o::SensorPointXYZDepth::RobotPoseType

Definition at line 40 of file sensor_pointxyz_depth.h.


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