15 #ifndef NAV2_ROUTE__NODE_SPATIAL_TREE_HPP_
16 #define NAV2_ROUTE__NODE_SPATIAL_TREE_HPP_
21 #include <nanoflann.hpp>
23 #include "nav2_ros_common/lifecycle_node.hpp"
24 #include "nav2_route/types.hpp"
25 #include "nav2_route/utils.hpp"
31 const size_t DIMENSION = 2;
42 inline size_t kdtree_get_point_count()
const {
return obj.size();}
44 inline double kdtree_get_pt(
const size_t idx,
const size_t dim)
const
47 return obj[idx].coords.x;
49 return obj[idx].coords.y;
52 template<
class BBOX>
bool kdtree_get_bbox(BBOX & )
const {
return false;}
57 typedef nanoflann::KDTreeSingleIndexAdaptor<
58 nanoflann::L2_Simple_Adaptor<double, GraphAdaptor>,
GraphAdaptor, DIMENSION,
95 const geometry_msgs::msg::PoseStamped & pose_in,
96 std::vector<unsigned int> & node_ids);
108 int num_of_nearest_nodes_{3};
An object to find kNNs of the graph to determining the start and end nodes to utilize for planning in...
bool findNearestGraphNodesToPose(const geometry_msgs::msg::PoseStamped &pose_in, std::vector< unsigned int > &node_ids)
Find the closest node to a given pose.
~NodeSpatialTree()
Destructor.
NodeSpatialTree()=default
Constructor.
void setNumOfNearestNodes(int num_of_nearest_nodes)
Set the number of nodes to search in local area for.
void computeTree(Graph &graph)
Compute the kd-tree based on the graph node information.
An adaptor for Nanoflann to operate on our graph object without copying.