map_test.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "gmapping/grid/map.h"
4 
5 using namespace std;
6 using namespace GMapping;
7 
8 struct SimpleCell{
9  int value;
10  SimpleCell(int v=0){value=v;}
11  static const SimpleCell& Unknown();
13 };
14 
16 
18  if (address)
19  return *address;
20  address=new SimpleCell(-1);
21  return *address;
22 }
23 
25 
26 int main (int argc, char ** argv){
27  CGrid g1(Point(0.,0.), 200, 200, 0.1);
28  CGrid g2(Point(10.,10.), 200, 200, 0.1);
29  {
31  IntPoint pp=g1.world2map(Point(5.1,5.1));
32  cout << pp.x << " " << pp.y << endl;
33  ps.insert(pp);
34  g1.storage().setActiveArea(ps,false);
35  g1.storage().allocActiveArea();
36  g1.cell(Point(5.1,5.1)).value=5;
37  cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
38  g1.resize(-150, -150, 150, 150);
39  cout << "cell value" << (int) g1.cell(Point(5.1,5.1)).value << endl;
40  CGrid g3(g1);
41  g1=g2;
42  }
43  cerr << "copy and modify test" << endl;
44  CGrid *ap,* gp1=new CGrid(Point(0,0), 200, 200, 0.1);
45  CGrid* gp0=new CGrid(*gp1);
46  for (int i=1; i<10; i++){
47  ap=new CGrid(*gp1);
48  delete gp1;
49  gp1=gp0;
50  gp0=ap;
51  IntPoint pp=gp0->world2map(Point(5.1,5.1));
53  ps.insert(pp);
54  gp1->storage().setActiveArea(ps,false);
55  gp1->storage().allocActiveArea();
56  gp1->cell(Point(5.1,5.1)).value=i;
57  cout << "cell value" << (int) gp1->cell(Point(5.1,5.1)).value << endl;
58  }
59  delete gp0;
60  delete gp1;
61  return 0;
62 }
SimpleCell::Unknown
static const SimpleCell & Unknown()
Definition: map_test.cpp:17
harray2d.h
SimpleCell::address
static SimpleCell * address
Definition: map_test.cpp:12
main
int main(int argc, char **argv)
Definition: map_test.cpp:26
GMapping
Definition: configfile.cpp:34
GMapping::Map::storage
Storage & storage()
Definition: map.h:81
GMapping::Map
Definition: map.h:16
SimpleCell::SimpleCell
SimpleCell(int v=0)
Definition: map_test.cpp:10
GMapping::point::y
T y
Definition: point.h:16
SimpleCell
Definition: map_test.cpp:8
GMapping::Point
point< double > Point
Definition: point.h:202
CGrid
Map< SimpleCell, HierarchicalArray2D< SimpleCell > > CGrid
Definition: map_test.cpp:24
map.h
GMapping::HierarchicalArray2D::PointSet
std::set< point< int >, pointcomparator< int > > PointSet
Definition: harray2d.h:13
GMapping::point
Definition: point.h:13
GMapping::Map::world2map
IntPoint world2map(const Point &p) const
Definition: map.h:179
GMapping::Map::cell
Cell & cell(int x, int y)
Definition: map.h:46
GMapping::Map::resize
void resize(double xmin, double ymin, double xmax, double ymax)
Definition: map.h:138
SimpleCell::value
int value
Definition: map_test.cpp:9
GMapping::point::x
T x
Definition: point.h:16


openslam_gmapping
Author(s): Cyrill Stachniss, Udo Frese, Giorgio Grisetti, Wolfram Burgard
autogenerated on Thu Oct 19 2023 02:25:51