g2o
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
LineSensor Struct Reference
Inheritance diagram for LineSensor:
Inheritance graph
[legend]
Collaboration diagram for LineSensor:
Collaboration graph
[legend]

Public Member Functions

 LineSensor (Robot *r, int offsetId, const Isometry3d &offset_)
 
virtual bool isVisible (const WorldItem *wi) const
 
virtual bool sense (WorldItem *wi, const Isometry3d &position)
 
- Public Member Functions inherited from Sensor
 Sensor (Robot *robot_)
 
Robotrobot ()
 
virtual ~Sensor ()
 
 Sensor (Robot *robot_)
 
Robotrobot ()
 
virtual ~Sensor ()
 

Public Attributes

 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 
VertexSE3_offsetVertex
 
Vector4d _nline
 

Additional Inherited Members

- Protected Attributes inherited from Sensor
Robot_robot
 

Detailed Description

Definition at line 183 of file simulator_3d_line.cpp.

Constructor & Destructor Documentation

◆ LineSensor()

LineSensor::LineSensor ( Robot r,
int  offsetId,
const Isometry3d &  offset_ 
)
inline

Definition at line 186 of file simulator_3d_line.cpp.

186 : Sensor(r) {
187 _offsetVertex = new VertexSE3();
188 _offsetVertex->setId(offsetId);
189 _offsetVertex->setEstimate(offset_);
191 };
OptimizableGraph * graph() const
Definition simulator.cpp:46
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
3D pose Vertex, represented as an Isometry3
Definition vertex_se3.h:50
VertexSE3 * _offsetVertex
Robot * robot()
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)

References _offsetVertex, g2o::OptimizableGraph::addVertex(), g2o::BaseRobot::graph(), Sensor::robot(), g2o::BaseVertex< D, T >::setEstimate(), and g2o::OptimizableGraph::Vertex::setId().

Member Function Documentation

◆ isVisible()

virtual bool LineSensor::isVisible ( const WorldItem wi) const
inlinevirtual

Reimplemented from Sensor.

Definition at line 193 of file simulator_3d_line.cpp.

193 {
194 if (!wi) {
195 return false;
196 }
197 const LineItem* li = dynamic_cast<const LineItem*>(wi);
198 if (!li) {
199 return false;
200 }
201 return true;
202 }

◆ sense()

virtual bool LineSensor::sense ( WorldItem wi,
const Isometry3d &  position 
)
inlinevirtual

Reimplemented from Sensor.

Definition at line 204 of file simulator_3d_line.cpp.

204 {
205 if (!wi) {
206 return false;
207 }
208 LineItem* li = dynamic_cast<LineItem*>(wi);
209 if (!li) {
210 return false;
211 }
212 OptimizableGraph::Vertex* rv = robot()->vertex();
213 if (!rv) {
214 return false;
215 }
216 VertexSE3* robotVertex = dynamic_cast<VertexSE3*>(rv);
217 if (!robotVertex) {
218 return false;
219 }
220 const Isometry3d& robotPose = position;
221 Isometry3d sensorPose = robotPose * _offsetVertex->estimate();
222 VertexLine3D* lineVertex = dynamic_cast<VertexLine3D*>(li->vertex());
223 Line3D worldLine = lineVertex->estimate();
224
225 Line3D measuredLine = sensorPose.inverse() * worldLine;
226
227 EdgeSE3Line3D* e = new EdgeSE3Line3D();
228 e->vertices()[0] = robotVertex;
229 e->vertices()[1] = lineVertex;
230 Vector4d noise = sample_noise_from_line(_nline);
231 measuredLine.oplus(noise);
232 e->setMeasurement(measuredLine);
233 Matrix4d m = Matrix4d::Zero();
234 m(0, 0) = 1.0 / (_nline(0));
235 m(1, 1) = 1.0 / (_nline(1));
236 m(2, 2) = 1.0 / (_nline(2));
237 m(3, 3) = 1.0 / (_nline(3));
238 e->setInformation(m);
239 e->setParameterId(0, 0);
240 robot()->graph()->addEdge(e);
241 return true;
242 }
void setInformation(const InformationType &information)
Definition base_edge.h:111
const EstimateType & estimate() const
return the current estimate of the vertex
virtual void setMeasurement(const Vector6 &m)
const VertexContainer & vertices() const
G2O_TYPES_SLAM3D_ADDONS_API void oplus(const Vector4 &v)
Definition line3d.h:142
bool setParameterId(int argNum, int paramId)
A general case Vertex for optimization.
Vector4d sample_noise_from_line(const Vector4d &cov)
OptimizableGraph::Vertex * vertex()
virtual bool addEdge(HyperGraph::Edge *e)

References _nline, _offsetVertex, g2o::OptimizableGraph::addEdge(), g2o::BaseVertex< D, T >::estimate(), g2o::BaseRobot::graph(), g2o::Line3D::oplus(), Sensor::robot(), sample_noise_from_line(), g2o::BaseEdge< D, E >::setInformation(), g2o::EdgeSE3Line3D::setMeasurement(), g2o::OptimizableGraph::Edge::setParameterId(), WorldItem::vertex(), and g2o::HyperGraph::Edge::vertices().

Member Data Documentation

◆ _nline

Vector4d LineSensor::_nline

Definition at line 245 of file simulator_3d_line.cpp.

Referenced by main(), and sense().

◆ _offsetVertex

VertexSE3* LineSensor::_offsetVertex

Definition at line 244 of file simulator_3d_line.cpp.

Referenced by LineSensor(), main(), and sense().

◆ EIGEN_MAKE_ALIGNED_OPERATOR_NEW

LineSensor::EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Definition at line 184 of file simulator_3d_line.cpp.


The documentation for this struct was generated from the following file: