Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
pf_kdtree.hpp
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey & Kasper Stoy
4  * gerkey@usc.edu kaspers@robotics.usc.edu
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 /**************************************************************************
22  * Desc: KD tree functions
23  * Author: Andrew Howard
24  * Date: 18 Dec 2002
25  * CVS: $Id: pf_kdtree.h 6532 2008-06-11 02:45:56Z gbiggs $
26  *************************************************************************/
27 
28 #ifndef NAV2_AMCL__PF__PF_KDTREE_HPP_
29 #define NAV2_AMCL__PF__PF_KDTREE_HPP_
30 
31 #ifdef INCLUDE_RTKGUI
32 #include <rtk.h>
33 #endif
34 
35 
36 // Info for a node in the tree
37 typedef struct pf_kdtree_node
38 {
39  // Depth in the tree
40  int leaf, depth;
41 
42  // Pivot dimension and value
43  int pivot_dim;
44  double pivot_value;
45 
46  // The key for this node
47  int key[3];
48 
49  // The value for this node
50  double value;
51 
52  // The cluster label (leaf nodes)
53  int cluster;
54 
55  // Child nodes
56  struct pf_kdtree_node * children[2];
58 
59 
60 // A kd tree
61 typedef struct
62 {
63  // Cell size
64  double size[3];
65 
66  // The root node of the tree
67  pf_kdtree_node_t * root;
68 
69  // The number of nodes in the tree
70  int node_count, node_max_count;
71  pf_kdtree_node_t * nodes;
72 
73  // The number of leaf nodes in the tree
74  int leaf_count;
75 } pf_kdtree_t;
76 
77 
78 // Create a tree
79 extern pf_kdtree_t * pf_kdtree_alloc(int max_size);
80 
81 // Destroy a tree
82 extern void pf_kdtree_free(pf_kdtree_t * self);
83 
84 // Clear all entries from the tree
85 extern void pf_kdtree_clear(pf_kdtree_t * self);
86 
87 // Insert a pose into the tree
88 extern void pf_kdtree_insert(pf_kdtree_t * self, pf_vector_t pose, double value);
89 
90 // Cluster the leaves in the tree
91 extern void pf_kdtree_cluster(pf_kdtree_t * self);
92 
93 // Determine the probability estimate for the given pose
94 // extern double pf_kdtree_get_prob(pf_kdtree_t * self, pf_vector_t pose);
95 
96 // Determine the cluster label for the given pose
97 extern int pf_kdtree_get_cluster(pf_kdtree_t * self, pf_vector_t pose);
98 
99 
100 #ifdef INCLUDE_RTKGUI
101 
102 // Draw the tree
103 extern void pf_kdtree_draw(pf_kdtree_t * self, rtk_fig_t * fig);
104 
105 #endif
106 
107 #endif // NAV2_AMCL__PF__PF_KDTREE_HPP_