Debian Codegraph @

debian/tests/build1

raw symbols SCIP
1 #!/bin/sh
2 # autopkgtest check
3 # (C) 2020 Leopold Palomo-Avellaneda
4
5 set -e
6
7 WORKDIR=$(mktemp -d)
8 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
9 cd $WORKDIR
10 cat <<EOF > exampleEDTOctomap.cpp
11 /**
12 * dynamicEDT3D:
13 * A library for incrementally updatable Euclidean distance transforms in 3D.
14 * @author C. Sprunk, B. Lau, W. Burgard, University of Freiburg, Copyright (C) 2011.
15 * @see http://octomap.sourceforge.net/
16 * License: New BSD License
17 */
18
19 /*
20 * Copyright (c) 2011-2012, C. Sprunk, B. Lau, W. Burgard, University of Freiburg
21 * All rights reserved.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions are met:
25 *
26 * * Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * * Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * * Neither the name of the University of Freiburg nor the names of its
32 * contributors may be used to endorse or promote products derived from
33 * this software without specific prior written permission.
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
39 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 * POSSIBILITY OF SUCH DAMAGE.
46 */
47
48 #include <dynamicEDT3D/dynamicEDTOctomap.h>
49
50 #include <iostream>
51
52
53
54 int main( int argc, char *argv[] ) {
55 if(argc<=1){
56 std::cout<<"usage: "<<argv[0]<<" <octoMap.bt>"<<std::endl;
57 exit(0);
58 }
59
60 octomap::OcTree *tree = NULL;
61 tree = new octomap::OcTree(0.05);
62
63 //read in octotree
64 tree->readBinary(argv[1]);
65
66 std::cout<<"read in tree, "<<tree->getNumLeafNodes()<<" leaves "<<std::endl;
67
68 double x,y,z;
69 tree->getMetricMin(x,y,z);
70 octomap::point3d min(x,y,z);
71 //std::cout<<"Metric min: "<<x<<","<<y<<","<<z<<std::endl;
72 tree->getMetricMax(x,y,z);
73 octomap::point3d max(x,y,z);
74 //std::cout<<"Metric max: "<<x<<","<<y<<","<<z<<std::endl;
75
76 bool unknownAsOccupied = true;
77 unknownAsOccupied = false;
78 float maxDist = 1.0;
79 //- the first argument ist the max distance at which distance computations are clamped
80 //- the second argument is the octomap
81 //- arguments 3 and 4 can be used to restrict the distance map to a subarea
82 //- argument 5 defines whether unknown space is treated as occupied or free
83 //The constructor copies data but does not yet compute the distance map
84 DynamicEDTOctomap distmap(maxDist, tree, min, max, unknownAsOccupied);
85
86 //This computes the distance map
87 distmap.update();
88
89 //This is how you can query the map
90 octomap::point3d p(5.0,5.0,0.6);
91 //As we don't know what the dimension of the loaded map are, we modify this point
92 p.x() = min.x() + 0.3 * (max.x() - min.x());
93 p.y() = min.y() + 0.6 * (max.y() - min.y());
94 p.z() = min.z() + 0.5 * (max.z() - min.z());
95
96 octomap::point3d closestObst;
97 float distance;
98
99 distmap.getDistanceAndClosestObstacle(p, distance, closestObst);
100
101 std::cout<<"\n\ndistance at point "<<p.x()<<","<<p.y()<<","<<p.z()<<" is "<<distance<<std::endl;
102 if(distance < distmap.getMaxDist())
103 std::cout<<"closest obstacle to "<<p.x()<<","<<p.y()<<","<<p.z()<<" is at "<<closestObst.x()<<","<<closestObst.y()<<","<<closestObst.z()<<std::endl;
104
105 //if you modify the octree via tree->insertScan() or tree->updateNode()
106 //just call distmap.update() again to adapt the distance map to the changes made
107
108 delete tree;
109
110 return 0;
111 }
112
113 EOF
114 cat <<EOF > CMakeLists.txt
115 cmake_minimum_required(VERSION 3.10)
116 PROJECT( demo1 )
117
118 find_package(dynamicEDT3D REQUIRED)
119 find_package(octomap REQUIRED )
120
121 include_directories(\${OCTOMAP_INCLUDE_DIRS})
122 message(STATUS "Found dynamicEDT3D version: " \${dynamicEDT3D_VERSION})
123 message(STATUS "dynamicEDT3D libraries: \${DYNAMICEDT3D_LIBRARIES}")
124 message(STATUS "Found octomap version: " \${OCTOMAP_VERSION})
125 message(STATUS "octomap libraries: \${OCTOMAP_LIBRARIES}")
126
127 add_executable(demo1 exampleEDTOctomap.cpp)
128 target_link_libraries (demo1 \${DYNAMICEDT3D_LIBRARIES} \${OCTOMAP_LIBRARIES})
129 EOF
130
131 cmake .
132 make
133 [ -x demo1 ]
134 echo "build: OK"
135 [ -x demo1 ]
136 ./demo1 /usr/share/doc/liboctomap-dev/examples/data/geb079.bt && echo run:OK || echo run:Failed