g2o
simulator.h
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #ifndef G2O_SIMULATOR_H
28 #define G2O_SIMULATOR_H
29 
30 #include "se2.h"
32 
33 #include <Eigen/StdVector>
34 
35 #include <vector>
36 #include <map>
37 
38 namespace g2o {
39  namespace tutorial {
40 
42  public:
43 
44  enum G2O_TUTORIAL_SLAM2D_API MotionType {
46  MO_NUM_ELEMS
47  };
48 
53  {
55  int id;
56  Eigen::Vector2d truePose;
57  Eigen::Vector2d simulatedPose;
58  std::vector<int> seenBy;
59  Landmark() : id(-1) {}
60  };
61  typedef std::vector<Landmark, Eigen::aligned_allocator<Landmark> > LandmarkVector;
62  typedef std::vector<Landmark*> LandmarkPtrVector;
63 
68  {
70  int id;
73  LandmarkPtrVector landmarks;
74  };
75  typedef std::vector<GridPose, Eigen::aligned_allocator<GridPose> > PosesVector;
76 
81  {
82  int from;
83  int to;
86  Eigen::Matrix3d information;
88  };
89  typedef std::vector<GridEdge, Eigen::aligned_allocator<GridEdge> > GridEdgeVector;
90 
92  {
93  int from;
94  int to;
95  Eigen::Vector2d trueMeas;
96  Eigen::Vector2d simulatorMeas;
97  Eigen::Matrix2d information;
99  };
100  typedef std::vector<LandmarkEdge, Eigen::aligned_allocator<LandmarkEdge> > LandmarkEdgeVector;
101 
102  public:
103  Simulator();
104  ~Simulator();
105 
106  void simulate(int numPoses, const SE2& sensorOffset = SE2());
107 
108  const PosesVector& poses() const { return _poses;}
109  const LandmarkVector& landmarks() const { return _landmarks;}
110  const GridEdgeVector& odometry() const { return _odometry;}
111  const LandmarkEdgeVector& landmarkObservations() const { return _landmarkObservations;}
112 
113  protected:
114  PosesVector _poses;
115  LandmarkVector _landmarks;
116  GridEdgeVector _odometry;
117  LandmarkEdgeVector _landmarkObservations;
118 
119  GridPose generateNewPose(const GridPose& prev, const SE2& trueMotion, const Eigen::Vector2d& transNoise, double rotNoise);
120  SE2 getMotion(int motionDirection, double stepLen);
121  SE2 sampleTransformation(const SE2& trueMotion_, const Eigen::Vector2d& transNoise, double rotNoise);
122  };
123 
124  } // end namespace
125 } // end namespace
126 
127 #endif
LandmarkEdgeVector _landmarkObservations
Definition: simulator.h:117
const PosesVector & poses() const
Definition: simulator.h:108
std::vector< GridPose, Eigen::aligned_allocator< GridPose > > PosesVector
Definition: simulator.h:75
LandmarkVector _landmarks
Definition: simulator.h:115
const LandmarkEdgeVector & landmarkObservations() const
Definition: simulator.h:111
std::vector< GridEdge, Eigen::aligned_allocator< GridEdge > > GridEdgeVector
Definition: simulator.h:89
std::vector< LandmarkEdge, Eigen::aligned_allocator< LandmarkEdge > > LandmarkEdgeVector
Definition: simulator.h:100
const LandmarkVector & landmarks() const
Definition: simulator.h:109
LandmarkPtrVector landmarks
the landmarks observed by this node
Definition: simulator.h:73
#define G2O_TUTORIAL_SLAM2D_API
MO_LEFT
Definition: simulator.h:45
const GridEdgeVector & odometry() const
Definition: simulator.h:110
GridEdgeVector _odometry
Definition: simulator.h:116
MO_RIGHT
Definition: simulator.h:45
odometry constraint
Definition: simulator.h:80
std::vector< Landmark, Eigen::aligned_allocator< Landmark > > LandmarkVector
Definition: simulator.h:61
std::vector< Landmark * > LandmarkPtrVector
Definition: simulator.h:62