MCPcopy Create free account
hub / github.com/OctoMap/octomap / main

Function main

octomap/src/intersection_example.cpp:43–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41using namespace octomap;
42
43int main(int /*argc*/, char** /*argv*/) {
44
45 cout << "generating example map" << endl;
46
47 OcTree tree (0.1); // create empty tree with resolution 0.1
48
49 // insert some measurements of free cells
50
51 for (float x = -2; x <= 0; x += 0.02f) {
52 for (float y = -2; y <= 0; y += 0.02f) {
53 for (float z = -2; z <= 0; z += 0.02f) {
54 point3d endpoint(x, y, z);
55 tree.updateNode(endpoint, false); // integrate 'free' measurement
56 }
57 }
58 }
59
60 // insert some measurements of occupied cells (twice as much)
61 for (float x = -1; x <= 0; x += 0.01f) {
62 for (float y = -1; y <= 0; y += 0.01f) {
63 for (float z = -1; z <= 0; z += 0.01f) {
64 point3d endpoint(x, y, z);
65 tree.updateNode(endpoint, true); // integrate 'occupied' measurement
66 }
67 }
68 }
69
70 point3d origin(-1.5, -1.5, -0.5);
71 point3d direction;
72 point3d ray_end;
73
74
75 for(float z = 0; z <= 0.25; z += 0.125){
76 direction = point3d(1, 1, z);
77 cout << endl;
78 cout << "casting ray from " << origin << " in the " << direction << " direction"<< endl;
79 bool success = tree.castRay(origin, direction, ray_end);
80
81 if(success){
82 cout << "ray hit cell with center " << ray_end << endl;
83
84 point3d intersection;
85 success = tree.getRayIntersection(origin, direction, ray_end, intersection);
86 if(success)
87 cout << "entrance point is " << intersection << endl;
88 }
89 }
90
91 return 0;
92}

Callers

nothing calls this directly

Calls 1

updateNodeMethod · 0.80

Tested by

no test coverage detected