Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
node_basic.cpp
1 // Copyright (c) 2021, Samsung Research America
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License. Reserved.
14 
15 #include "nav2_smac_planner/node_basic.hpp"
16 
17 namespace nav2_smac_planner
18 {
19 
20 template<typename Node2D>
22 {
23 }
24 
25 template<>
27 {
28  // We only want to override the node's pose if it has not yet been visited
29  // to prevent the case that a node has been queued multiple times and
30  // a new branch is overriding one of lower cost already visited.
31  if (!this->graph_node_ptr->wasVisited()) {
32  this->graph_node_ptr->pose = this->pose;
33  this->graph_node_ptr->setMotionPrimitiveIndex(this->motion_index, this->turn_dir);
34  }
35 }
36 
37 template<>
39 {
40  // We only want to override the node's pose/primitive if it has not yet been visited
41  // to prevent the case that a node has been queued multiple times and
42  // a new branch is overriding one of lower cost already visited.
43  if (!this->graph_node_ptr->wasVisited()) {
44  this->graph_node_ptr->pose = this->pose;
45  this->graph_node_ptr->setMotionPrimitive(this->prim_ptr);
46  this->graph_node_ptr->backwards(this->backward);
47  }
48 }
49 
50 template<>
51 void NodeBasic<Node2D>::populateSearchNode(Node2D * & node)
52 {
53  this->graph_node_ptr = node;
54 }
55 
56 template<>
57 void NodeBasic<NodeHybrid>::populateSearchNode(NodeHybrid * & node)
58 {
59  this->pose = node->pose;
60  this->graph_node_ptr = node;
61  this->motion_index = node->getMotionPrimitiveIndex();
62  this->turn_dir = node->getTurnDirection();
63 }
64 
65 template<>
66 void NodeBasic<NodeLattice>::populateSearchNode(NodeLattice * & node)
67 {
68  this->pose = node->pose;
69  this->graph_node_ptr = node;
70  this->prim_ptr = node->getMotionPrimitive();
71  this->backward = node->isBackward();
72 }
73 
74 template class NodeBasic<Node2D>;
75 template class NodeBasic<NodeHybrid>;
76 template class NodeBasic<NodeLattice>;
77 
78 } // namespace nav2_smac_planner
void populateSearchNode(NodeT *&node)
Take a NodeBasic and populate it with any necessary state cached in the queue for NodeT.
void processSearchNode()
Take a NodeBasic and populate it with any necessary state cached in the queue for NodeTs.
Definition: node_basic.cpp:21