g2o
Loading...
Searching...
No Matches
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 <map>
31#include <vector>
32
34#include "se2.h"
35
36namespace g2o {
37namespace tutorial {
38
40 public:
41 enum G2O_TUTORIAL_SLAM2D_API MotionType { MO_LEFT, MO_RIGHT, MO_NUM_ELEMS };
42
48 int id;
49 Eigen::Vector2d truePose;
50 Eigen::Vector2d simulatedPose;
51 std::vector<int> seenBy;
52 Landmark() : id(-1) {}
53 };
54 using LandmarkVector = std::vector<Landmark>;
55 using LandmarkPtrVector = std::vector<Landmark*>;
56
67 using PosesVector = std::vector<GridPose>;
68
80 using GridEdgeVector = std::vector<GridEdge>;
81
83 int from;
84 int to;
85 Eigen::Vector2d trueMeas;
86 Eigen::Vector2d simulatorMeas;
87 Eigen::Matrix2d information;
89 };
90 using LandmarkEdgeVector = std::vector<LandmarkEdge>;
91
92 public:
93 Simulator();
94 ~Simulator();
95
96 void simulate(int numPoses, const SE2& sensorOffset = SE2());
97
98 const PosesVector& poses() const { return _poses; }
99 const LandmarkVector& landmarks() const { return _landmarks; }
100 const GridEdgeVector& odometry() const { return _odometry; }
102 return _landmarkObservations;
103 }
104
105 protected:
110
111 GridPose generateNewPose(const GridPose& prev, const SE2& trueMotion,
112 const Eigen::Vector2d& transNoise, double rotNoise);
113 SE2 getMotion(int motionDirection, double stepLen);
114 SE2 sampleTransformation(const SE2& trueMotion_,
115 const Eigen::Vector2d& transNoise, double rotNoise);
116};
117
118} // namespace tutorial
119} // namespace g2o
120
121#endif
std::vector< GridEdge > GridEdgeVector
Definition simulator.h:80
const PosesVector & poses() const
Definition simulator.h:98
std::vector< Landmark * > LandmarkPtrVector
Definition simulator.h:55
std::vector< GridPose > PosesVector
Definition simulator.h:67
const LandmarkEdgeVector & landmarkObservations() const
Definition simulator.h:101
LandmarkVector _landmarks
Definition simulator.h:107
LandmarkEdgeVector _landmarkObservations
Definition simulator.h:109
const LandmarkVector & landmarks() const
Definition simulator.h:99
const GridEdgeVector & odometry() const
Definition simulator.h:100
std::vector< Landmark > LandmarkVector
Definition simulator.h:54
std::vector< LandmarkEdge > LandmarkEdgeVector
Definition simulator.h:90
GridEdgeVector _odometry
Definition simulator.h:108
MO_LEFT
Definition simulator.h:41
MO_RIGHT
Definition simulator.h:41
#define G2O_TUTORIAL_SLAM2D_API
LandmarkPtrVector landmarks
the landmarks observed by this node
Definition simulator.h:65