26 template <
class node_t>
46 class NODE_TYPE_DATA,
class EDGE_TYPE,
53 struct node_t :
public NODE_TYPE_DATA
64 EDGE_TYPE* edge_to_parent_,
const NODE_TYPE_DATA&
data)
65 : NODE_TYPE_DATA(
data),
77 using node_map_t =
typename MAPS_IMPLEMENTATION::template map<
83 template <
class NODE_TYPE_FOR_METRIC>
85 const NODE_TYPE_FOR_METRIC& query_pt,
87 double* out_distance =
nullptr,
88 const std::set<mrpt::graphs::TNodeID>* ignored_nodes =
nullptr)
const 91 double min_d = std::numeric_limits<double>::max();
96 ignored_nodes->find(it->first) != ignored_nodes->end())
98 const NODE_TYPE_FOR_METRIC ptTo(query_pt.state);
99 const NODE_TYPE_FOR_METRIC ptFrom(it->second.state);
100 if (distanceMetricEvaluator.cannotBeNearerThan(ptFrom, ptTo, min_d))
103 double d = distanceMetricEvaluator.distance(ptFrom, ptTo);
110 if (out_distance) *out_distance = min_d;
117 const NODE_TYPE_DATA& new_child_node_data,
118 const EDGE_TYPE& new_edge_data)
123 edges_of_parent.push_back(
typename base_t::TEdgeInfo(
124 new_child_id,
false , new_edge_data));
127 new_child_id, parent_id, &edges_of_parent.back().data,
128 new_child_node_data);
149 auto it_src =
m_nodes.find(target_node);
151 throw std::runtime_error(
152 "backtrackPath: target_node not found in tree!");
153 const node_t* node = &it_src->second;
156 out_path.push_front(*node);
165 auto it_next =
m_nodes.find(next_node_id);
167 throw std::runtime_error(
168 "backtrackPath: Node ID not found during tree " 170 node = &it_next->second;
269 bool tp_point_is_exact =
270 m_ptg.inverseMap_WS2TP(relPose.
x(), relPose.
y(), k, d);
271 if (tp_point_is_exact)
272 return d * m_ptg.getRefDistance();
274 return std::numeric_limits<double>::max();
TMapNode2ListEdges edges_to_children
The edges of each node.
mrpt::math::TPose2D state
state in SE2 as 2D pose (x, y, phi)
A special kind of graph in the form of a tree with directed edges and optional edge annotations of te...
mrpt::graphs::TNodeID getNextFreeNodeID() const
const mrpt::nav::CParameterizedTrajectoryGenerator & m_ptg
TNodeSE2_TP(const mrpt::math::TPose2D &state_)
mrpt::graphs::TNodeID parent_id
The ID of the parent node in the tree.
TNodeSE2(const mrpt::math::TPose2D &state_)
T angDistance(T from, T to)
Computes the shortest angular increment (or distance) between two planar orientations, such that it is constrained to [-pi,pi] and is correct for any combination of angles (e.g.
mrpt::graphs::TNodeID parent_id
INVALID_NODEID for the root, a valid ID otherwise.
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 node_map_t & getAllNodes() const
int ptg_index
indicate the type of trajectory used for this motion
bool cannotBeNearerThan(const TNodeSE2 &a, const TNodeSE2 &b, const double d) const
std::list< node_t > path_t
A topological path up-tree.
Generic base for metrics.
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...
#define ASSERT_(f)
Defines an assertion mechanism.
This is the base class for any user-defined PTG.
double distance(const TNodeSE2_TP &src, const TNodeSE2_TP &dst) const
std::list< TEdgeInfo > TListEdges
This class contains motions and motions tree structures for the hybrid navigation algorithm...
node_t(mrpt::graphs::TNodeID node_id_, mrpt::graphs::TNodeID parent_id_, EDGE_TYPE *edge_to_parent_, const NODE_TYPE_DATA &data)
double x() const
Common members of all points & poses classes.
return_t square(const num_t x)
Inline function for the square of a number.
Traits for using a mrpt::containers::map_as_vector<> (dense, fastest representation) ...
mrpt::math::TPose2D state
state in SE2 as 2D pose (x, y, phi)
PoseDistanceMetric(const mrpt::nav::CParameterizedTrajectoryGenerator &ptg)
double distance(const TNodeSE2 &a, const TNodeSE2 &b) const
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
typename MAPS_IMPLEMENTATION::template map< mrpt::graphs::TNodeID, node_t > node_map_t
Map: TNode_ID => Node info.
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::graphs::TNodeID getNearestNode(const NODE_TYPE_FOR_METRIC &query_pt, const PoseDistanceMetric< NODE_TYPE_FOR_METRIC > &distanceMetricEvaluator, double *out_distance=nullptr, const std::set< mrpt::graphs::TNodeID > *ignored_nodes=nullptr) const
Finds the nearest node to a given pose, using the given metric.
EDGE_TYPE * edge_to_parent
NULL for root, a valid edge otherwise.
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
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...
double ptg_dist
identify the lenght of the trajectory for this motion
An edge for the move tree used for planning in SE2 and TP-space.
TMoveEdgeSE2_TP(const mrpt::graphs::TNodeID parent_id_, const mrpt::math::TPose2D end_pose_)
mrpt::math::TPose2D end_state
state in SE2 as 2D pose (x, y, phi) -
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...
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...
node_map_t m_nodes
Info per node.
bool cannotBeNearerThan(const TNodeSE2_TP &a, const TNodeSE2_TP &b, const double d) const
double phi
Orientation (rads)
static struct FontData data