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

#include <sensor_pointxyz.h>

Inheritance diagram for g2o::SensorPointXYZ:
Collaboration diagram for g2o::SensorPointXYZ:

Public Member Functions

 SensorPointXYZ (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, EdgeSE3PointXYZ, 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, EdgeSE3PointXYZ, WorldObjectTrackXYZ >
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Protected Member Functions

bool isVisible (WorldObjectType *to)
Protected Member Functions inherited from g2o::BinarySensor< Robot3D, EdgeSE3PointXYZ, 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, EdgeSE3PointXYZ, 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, EdgeSE3PointXYZ, WorldObjectTrackXYZ >
typedef Robot3D RobotType
typedef RobotType::PoseObject PoseObject
typedef RobotType::TrajectoryType TrajectoryType
typedef RobotType::PoseObject::VertexType PoseVertexType
typedef EdgeSE3PointXYZ EdgeType
typedef WorldObjectTrackXYZ WorldObjectType
typedef WorldObjectType::VertexType VertexType
typedef EdgeType::InformationType InformationType

Detailed Description

Definition at line 35 of file sensor_pointxyz.h.

Constructor & Destructor Documentation

◆ SensorPointXYZ()

Member Function Documentation

◆ addNoise()

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

Definition at line 68 of file sensor_pointxyz.cpp.

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

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

Referenced by sense().

◆ addParameters()

void g2o::SensorPointXYZ::addParameters ( )
virtual

Reimplemented from g2o::BaseSensor.

Definition at line 62 of file sensor_pointxyz.cpp.

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

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

◆ isVisible()

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

Definition at line 45 of file sensor_pointxyz.cpp.

45 {
46 if (!_robotPoseObject) return false;
47 assert(to && to->vertex());
48 VertexType* v = to->vertex();
49 VertexType::EstimateType pose = v->estimate();
50 VertexType::EstimateType delta = _sensorPose.inverse() * pose;
51 Vector3d translation = delta;
52 double range2 = translation.squaredNorm();
53 if (range2 > _maxRange2) return false;
54 if (range2 < _minRange2) return false;
55 translation.normalize();
56 // the cameras have the z in front
57 double bearing = acos(translation.z());
58 if (fabs(bearing) > _fov) return false;
59 return true;
60}
RobotPoseType _sensorPose
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, EdgeSE3PointXYZ, WorldObjectTrackXYZ >::_robotPoseObject, _sensorPose, and g2o::BaseVertex< D, T >::estimate().

Referenced by sense().

◆ offsetParam()

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

Definition at line 44 of file sensor_pointxyz.h.

44{ return _offsetParam; };

References _offsetParam.

Referenced by main().

◆ sense()

void g2o::SensorPointXYZ::sense ( )
virtual

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

Definition at line 74 of file sensor_pointxyz.cpp.

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

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

Member Data Documentation

◆ _offsetParam

ParameterSE3Offset* g2o::SensorPointXYZ::_offsetParam
protected

Definition at line 50 of file sensor_pointxyz.h.

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

◆ _sensorPose

RobotPoseType g2o::SensorPointXYZ::_sensorPose
protected

Definition at line 49 of file sensor_pointxyz.h.

Referenced by isVisible(), and sense().

◆ RobotPoseType

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef PoseVertexType::EstimateType g2o::SensorPointXYZ::RobotPoseType

Definition at line 40 of file sensor_pointxyz.h.


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