Go to the documentation of this file.
28 template <
class node_t>
48 class NODE_TYPE_DATA,
class EDGE_TYPE,
55 struct node_t :
public NODE_TYPE_DATA
66 EDGE_TYPE* edge_to_parent_,
const NODE_TYPE_DATA&
data)
67 : NODE_TYPE_DATA(
data),
79 using node_map_t =
typename MAPS_IMPLEMENTATION::template map<
85 template <
class NODE_TYPE_FOR_METRIC>
87 const NODE_TYPE_FOR_METRIC& query_pt,
89 double* out_distance = NULL,
90 const std::set<mrpt::graphs::TNodeID>* ignored_nodes = NULL)
const
93 double min_d = std::numeric_limits<double>::max();
99 ignored_nodes->find(it->first) != ignored_nodes->end())
101 const NODE_TYPE_FOR_METRIC ptTo(query_pt.state);
102 const NODE_TYPE_FOR_METRIC ptFrom(it->second.state);
103 if (distanceMetricEvaluator.cannotBeNearerThan(ptFrom, ptTo, min_d))
106 double d = distanceMetricEvaluator.distance(ptFrom, ptTo);
113 if (out_distance) *out_distance = min_d;
120 const NODE_TYPE_DATA& new_child_node_data,
121 const EDGE_TYPE& new_edge_data)
126 edges_of_parent.push_back(
typename base_t::TEdgeInfo(
127 new_child_id,
false , new_edge_data));
130 new_child_id, parent_id, &edges_of_parent.back().data,
131 new_child_node_data);
154 throw std::runtime_error(
155 "backtrackPath: target_node not found in tree!");
156 const node_t* node = &it_src->second;
159 out_path.push_front(*node);
171 throw std::runtime_error(
172 "backtrackPath: Node ID not found during tree "
174 node = &it_next->second;
232 if (std::abs(
a.state.x -
b.state.x) > d)
return true;
233 if (std::abs(
a.state.y -
b.state.y) > d)
return true;
262 if (std::abs(
a.state.x -
b.state.x) > d)
return true;
263 if (std::abs(
a.state.y -
b.state.y) > d)
return true;
273 bool tp_point_is_exact =
274 m_ptg.inverseMap_WS2TP(relPose.
x(), relPose.
y(), k, d);
275 if (tp_point_is_exact)
276 return d * m_ptg.getRefDistance();
278 return std::numeric_limits<double>::max();
typename MAPS_IMPLEMENTATION::template map< mrpt::graphs::TNodeID, node_t > node_map_t
Map: TNode_ID => Node info.
void insertNodeAndEdge(const mrpt::graphs::TNodeID parent_id, const mrpt::graphs::TNodeID new_child_id, const NODE_TYPE_DATA &new_child_node_data, const EDGE_TYPE &new_edge_data)
const Scalar * const_iterator
T angDistance(T from, T to)
Computes the shortest angular increment (or distance) between two planar orientations,...
This class contains motions and motions tree structures for the hybrid navigation algorithm.
TMoveEdgeSE2_TP(const mrpt::graphs::TNodeID parent_id_, const mrpt::math::TPose2D end_pose_)
void backtrackPath(const mrpt::graphs::TNodeID target_node, path_t &out_path) const
Builds the path (sequence of nodes, with info about next edge) up-tree from a target_node towards the...
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
Generic base for metrics.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::graphs::TNodeID getNextFreeNodeID() const
#define ASSERT_(f)
Defines an assertion mechanism.
T square(const T x)
Inline function for the square of a number.
void inverseComposeFrom(const CPose2D &A, const CPose2D &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
A special kind of graph in the form of a tree with directed edges and optional edge annotations of te...
int ptg_K
identify the trajectory number K of the type ptg_index
double cost
cost associated to each motion, this should be defined by the user according to a spefic cost functio...
const mrpt::nav::CParameterizedTrajectoryGenerator & m_ptg
TNodeSE2(const mrpt::math::TPose2D &state_)
bool cannotBeNearerThan(const TNodeSE2 &a, const TNodeSE2 &b, const double d) const
GLsizei GLsizei GLenum GLenum const GLvoid * data
mrpt::graphs::TNodeID getNearestNode(const NODE_TYPE_FOR_METRIC &query_pt, const PoseDistanceMetric< NODE_TYPE_FOR_METRIC > &distanceMetricEvaluator, double *out_distance=NULL, const std::set< mrpt::graphs::TNodeID > *ignored_nodes=NULL) const
Finds the nearest node to a given pose, using the given metric.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
double x() const
Common members of all points & poses classes.
double distance(const TNodeSE2 &a, const TNodeSE2 &b) const
PoseDistanceMetric(const mrpt::nav::CParameterizedTrajectoryGenerator &ptg)
TMapNode2ListEdges edges_to_children
The edges of each node.
EDGE_TYPE * edge_to_parent
NULL for root, a valid edge otherwise.
std::list< node_t > path_t
A topological path up-tree.
double distance(const TNodeSE2_TP &src, const TNodeSE2_TP &dst) const
node_t(mrpt::graphs::TNodeID node_id_, mrpt::graphs::TNodeID parent_id_, EDGE_TYPE *edge_to_parent_, const NODE_TYPE_DATA &data)
Traits for using a mrpt::utils::map_as_vector<> (dense, fastest representation)
void insertNode(const mrpt::graphs::TNodeID node_id, const NODE_TYPE_DATA &node_data)
Insert a node without edges (should be used only for a tree root node)
mrpt::math::TPose2D state
state in SE2 as 2D pose (x, y, phi)
mrpt::graphs::TNodeID node_id
Duplicated ID (it's also in the map::iterator->first), but put here to make it available in path_t.
const node_map_t & getAllNodes() const
An edge for the move tree used for planning in SE2 and TP-space.
mrpt::graphs::TNodeID parent_id
The ID of the parent node in the tree.
node_map_t m_nodes
Info per node.
std::list< TEdgeInfo > TListEdges
TNodeSE2_TP(const mrpt::math::TPose2D &state_)
bool cannotBeNearerThan(const TNodeSE2_TP &a, const TNodeSE2_TP &b, const double d) const
int ptg_index
indicate the type of trajectory used for this motion
mrpt::graphs::TNodeID parent_id
INVALID_NODEID for the root, a valid ID otherwise.
double ptg_dist
identify the lenght of the trajectory for this motion
mrpt::math::TPose2D state
state in SE2 as 2D pose (x, y, phi)
This is the base class for any user-defined PTG.
mrpt::math::TPose2D end_state
state in SE2 as 2D pose (x, y, phi) -
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |