27 #ifndef G2O_SIMULATOR_ 28 #define G2O_SIMULATOR_ 32 #include "g2o/config.h" 57 template <
class VertexType_>
64 _vertex =
new VertexType();
67 if(! dynamic_cast<VertexType*>(vertex_))
73 if (! _vertex)
return 0;
74 return dynamic_cast<VertexType*
>(_vertex);
80 BaseRobot(
World* world_,
const std::string& name_){_world = world_; _name = name_; }
83 const std::string&
name()
const {
return _name;}
86 const std::set<BaseSensor*>
sensors() {
return _sensors;}
94 template <
class RobotPoseObject>
101 typedef typename PoseObject::EstimateType
PoseType;
105 _pose=_pose*movement_;
109 virtual void move(
const PoseType& pose_) {
112 PoseObject* po=
new PoseObject();
113 po->vertex()->setEstimate(_pose);
114 world()->addWorldObject(po);
115 _trajectory.push_back(po);
120 const PoseType&
pose()
const {
return _pose;}
134 virtual void sense() = 0;
142 template <
class RobotType_,
class EdgeType_>
154 _information.setIdentity();
158 _information = information_ ;
159 _sampler.setDistribution(_information.inverse());
165 _robotPoseObject = 0;
170 RobotType* r =
dynamic_cast<RobotType*
>(robot());
175 _robotPoseObject = *(r->
trajectory().rbegin());
177 if (! world() || !
graph())
180 EdgeType* e=mkEdge();
194 PoseVertexType* robotVertex = (PoseVertexType*)_robotPoseObject->
vertex();
195 EdgeType* e =
new EdgeType();
204 template <
class RobotType_,
class EdgeType_,
class WorldObjectType_>
218 _information.setIdentity();
222 _information = information_ ;
223 _sampler.setDistribution(_information.inverse());
229 _robotPoseObject = 0;
234 RobotType* r =
dynamic_cast<RobotType*
>(robot());
239 _robotPoseObject = *(r->
trajectory().rbegin());
241 if (! world() || !
graph())
245 for(std::set<BaseWorldObject*>::iterator it=world()->objects().begin(); it!=world()->objects().end(); it++){
246 WorldObjectType * wo =
dynamic_cast<WorldObjectType*
>(*it);
248 EdgeType* e=mkEdge(wo);
263 EdgeType*
mkEdge(WorldObjectType*
object){
264 PoseVertexType* robotVertex = (PoseVertexType*)_robotPoseObject->
vertex();
265 EdgeType* e =
new EdgeType();
284 std::set<BaseWorldObject*>&
objects() {
return _objects;}
285 std::set<BaseRobot*>&
robots() {
return _robots; }
RobotType::PoseObject::VertexType PoseVertexType
WorldObjectType::VertexType VertexType
const Vertex * vertex(size_t i) const
World(OptimizableGraph *graph_)
RobotType::PoseObject::VertexType PoseVertexType
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
const std::set< BaseSensor * > sensors()
std::set< BaseWorldObject * > _objects
RobotPoseObject PoseObject
std::set< BaseRobot * > _robots
InformationType _information
virtual void addParameters()
virtual bool setMeasurementFromState()
std::vector< Parameter * > parameters()
BaseWorldObject(World *world_=0)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
void setWorld(World *world_)
virtual bool setMeasurementFromState()
GaussianSampler< typename EdgeType::ErrorVector, InformationType > _sampler
OptimizableGraph * graph()
GaussianSampler< typename EdgeType::ErrorVector, InformationType > _sampler
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
RobotType::TrajectoryType TrajectoryType
RobotType::PoseObject PoseObject
BaseRobot(World *world_, const std::string &name_)
EdgeType::InformationType InformationType
std::list< PoseObject * > TrajectoryType
WorldObjectType_ WorldObjectType
std::set< BaseSensor * > _sensors
BaseSensor(const std::string &name_)
OptimizableGraph * _graph
OptimizableGraph::Vertex * _vertex
const std::string & name() const
BinarySensor(const std::string &name)
const VertexContainer & vertices() const
void setInformation(const InformationType &information_)
const InformationType & information()
VertexType_::EstimateType EstimateType
TrajectoryType & trajectory()
PoseObject * _robotPoseObject
#define G2O_SIMULATOR_API
virtual void addNoise(EdgeType *)
InformationType _information
virtual void addNoise(EdgeType *)
UnarySensor(const std::string &name)
PoseObject::EstimateType PoseType
EdgeType::InformationType InformationType
RobotType::PoseObject PoseObject
A general case Vertex for optimization.
TrajectoryType _trajectory
const PoseType & pose() const
virtual void relativeMove(const PoseType &movement_)
PoseObject * _robotPoseObject
Robot(World *world_, const std::string &name_)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
RobotType::TrajectoryType TrajectoryType
std::set< BaseWorldObject * > & objects()
std::set< BaseRobot * > & robots()
void setWorld(World *world_)
virtual void setVertex(OptimizableGraph::Vertex *vertex_)
std::vector< Parameter * > _parameters
PoseObject::VertexType VertexType
WorldObject(World *world_=0)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
virtual void move(const PoseType &pose_)
void setRobot(BaseRobot *robot_)
OptimizableGraph::Vertex * vertex()
void setInformation(const InformationType &information_)
EdgeType * mkEdge(WorldObjectType *object)
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the graph
const InformationType & information()
OptimizableGraph * _graph