Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
types.hpp
1 // Copyright (c) 2020, 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 #ifndef NAV2_SMAC_PLANNER__TYPES_HPP_
16 #define NAV2_SMAC_PLANNER__TYPES_HPP_
17 
18 #include <vector>
19 #include <utility>
20 #include <string>
21 #include <memory>
22 
23 #include "rclcpp_lifecycle/lifecycle_node.hpp"
24 #include "nav2_util/node_utils.hpp"
25 
26 namespace nav2_smac_planner
27 {
28 
29 typedef std::pair<float, unsigned int> NodeHeuristicPair;
30 
35 struct SearchInfo
36 {
37  float minimum_turning_radius;
38  float non_straight_penalty;
39  float change_penalty;
40  float reverse_penalty;
41  float cost_penalty;
42  float retrospective_penalty;
43  float rotation_penalty;
44  float analytic_expansion_ratio;
45  float analytic_expansion_max_length;
46  std::string lattice_filepath;
47  bool cache_obstacle_heuristic;
48  bool allow_reverse_expansion;
49 };
50 
55 struct SmootherParams
56 {
61  : holonomic_(false)
62  {
63  }
64 
70  void get(std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node, const std::string & name)
71  {
72  std::string local_name = name + std::string(".smoother.");
73 
74  // Smoother params
75  nav2_util::declare_parameter_if_not_declared(
76  node, local_name + "tolerance", rclcpp::ParameterValue(1e-10));
77  node->get_parameter(local_name + "tolerance", tolerance_);
78  nav2_util::declare_parameter_if_not_declared(
79  node, local_name + "max_iterations", rclcpp::ParameterValue(1000));
80  node->get_parameter(local_name + "max_iterations", max_its_);
81  nav2_util::declare_parameter_if_not_declared(
82  node, local_name + "w_data", rclcpp::ParameterValue(0.2));
83  node->get_parameter(local_name + "w_data", w_data_);
84  nav2_util::declare_parameter_if_not_declared(
85  node, local_name + "w_smooth", rclcpp::ParameterValue(0.3));
86  node->get_parameter(local_name + "w_smooth", w_smooth_);
87  nav2_util::declare_parameter_if_not_declared(
88  node, local_name + "do_refinement", rclcpp::ParameterValue(true));
89  node->get_parameter(local_name + "do_refinement", do_refinement_);
90  }
91 
92  double tolerance_;
93  int max_its_;
94  double w_data_;
95  double w_smooth_;
96  bool holonomic_;
97  bool do_refinement_;
98 };
99 
105 {
110 
117  MotionPose(const float & x, const float & y, const float & theta)
118  : _x(x), _y(y), _theta(theta)
119  {}
120 
121  MotionPose operator-(const MotionPose & p2)
122  {
123  return MotionPose(this->_x - p2._x, this->_y - p2._y, this->_theta - p2._theta);
124  }
125 
126  float _x;
127  float _y;
128  float _theta;
129 };
130 
131 typedef std::vector<MotionPose> MotionPoses;
132 
138 {
139  float min_turning_radius;
140  float grid_resolution;
141  unsigned int number_of_headings;
142  std::vector<float> heading_angles;
143  unsigned int number_of_trajectories;
144  std::string motion_model;
145 };
146 
152 {
153  unsigned int trajectory_id;
154  float start_angle;
155  float end_angle;
156  float turning_radius;
157  float trajectory_length;
158  float arc_length;
159  float straight_length;
160  bool left_turn;
161  MotionPoses poses;
162 };
163 
164 typedef std::vector<MotionPrimitive> MotionPrimitives;
165 typedef std::vector<MotionPrimitive *> MotionPrimitivePtrs;
166 
167 } // namespace nav2_smac_planner
168 
169 #endif // NAV2_SMAC_PLANNER__TYPES_HPP_
A struct of all lattice metadata.
Definition: types.hpp:138
A struct for poses in motion primitives.
Definition: types.hpp:105
MotionPose(const float &x, const float &y, const float &theta)
A constructor for nav2_smac_planner::MotionPose.
Definition: types.hpp:117
MotionPose()
A constructor for nav2_smac_planner::MotionPose.
Definition: types.hpp:109
A struct of all motion primitive data.
Definition: types.hpp:152
Search properties and penalties.
Definition: types.hpp:36
Parameters for the smoother cost function.
void get(std::shared_ptr< rclcpp_lifecycle::LifecycleNode > node, const std::string &name)
Get params from ROS parameter.
Definition: types.hpp:70
SmootherParams()
A constructor for nav2_smac_planner::SmootherParams.
Definition: types.hpp:60