Nav2 Navigation Stack - jazzy  jazzy
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, uint64_t> NodeHeuristicPair;
30 
35 struct SearchInfo
36 {
37  float minimum_turning_radius{8.0};
38  float non_straight_penalty{1.05};
39  float change_penalty{0.0};
40  float reverse_penalty{2.0};
41  float cost_penalty{2.0};
42  float retrospective_penalty{0.015};
43  float rotation_penalty{5.0};
44  float analytic_expansion_ratio{3.5};
45  float analytic_expansion_max_length{60.0};
46  float analytic_expansion_max_cost{200.0};
47  bool analytic_expansion_max_cost_override{false};
48  std::string lattice_filepath;
49  bool cache_obstacle_heuristic{false};
50  bool allow_reverse_expansion{false};
51  bool allow_primitive_interpolation{false};
52  bool downsample_obstacle_heuristic{true};
53  bool use_quadratic_cost_penalty{false};
54 };
55 
60 struct SmootherParams
61 {
66  : holonomic_(false)
67  {
68  }
69 
75  void get(std::shared_ptr<rclcpp_lifecycle::LifecycleNode> node, const std::string & name)
76  {
77  std::string local_name = name + std::string(".smoother.");
78 
79  // Smoother params
80  nav2_util::declare_parameter_if_not_declared(
81  node, local_name + "tolerance", rclcpp::ParameterValue(1e-10));
82  node->get_parameter(local_name + "tolerance", tolerance_);
83  nav2_util::declare_parameter_if_not_declared(
84  node, local_name + "max_iterations", rclcpp::ParameterValue(1000));
85  node->get_parameter(local_name + "max_iterations", max_its_);
86  nav2_util::declare_parameter_if_not_declared(
87  node, local_name + "w_data", rclcpp::ParameterValue(0.2));
88  node->get_parameter(local_name + "w_data", w_data_);
89  nav2_util::declare_parameter_if_not_declared(
90  node, local_name + "w_smooth", rclcpp::ParameterValue(0.3));
91  node->get_parameter(local_name + "w_smooth", w_smooth_);
92  nav2_util::declare_parameter_if_not_declared(
93  node, local_name + "do_refinement", rclcpp::ParameterValue(true));
94  node->get_parameter(local_name + "do_refinement", do_refinement_);
95  nav2_util::declare_parameter_if_not_declared(
96  node, local_name + "refinement_num", rclcpp::ParameterValue(2));
97  node->get_parameter(local_name + "refinement_num", refinement_num_);
98  }
99 
100  double tolerance_;
101  int max_its_;
102  double w_data_;
103  double w_smooth_;
104  bool holonomic_;
105  bool do_refinement_;
106  int refinement_num_;
107 };
108 
113 enum struct TurnDirection
114 {
115  UNKNOWN = 0,
116  FORWARD = 1,
117  LEFT = 2,
118  RIGHT = 3,
119  REVERSE = 4,
120  REV_LEFT = 5,
121  REV_RIGHT = 6
122 };
123 
129 {
134 
142  MotionPose(const float & x, const float & y, const float & theta, const TurnDirection & turn_dir)
143  : _x(x), _y(y), _theta(theta), _turn_dir(turn_dir)
144  {}
145 
146  MotionPose operator-(const MotionPose & p2)
147  {
148  return MotionPose(
149  this->_x - p2._x, this->_y - p2._y, this->_theta - p2._theta, TurnDirection::UNKNOWN);
150  }
151 
152  float _x;
153  float _y;
154  float _theta;
155  TurnDirection _turn_dir;
156 };
157 
158 typedef std::vector<MotionPose> MotionPoses;
159 
165 {
166  float min_turning_radius;
167  float grid_resolution;
168  unsigned int number_of_headings;
169  std::vector<float> heading_angles;
170  unsigned int number_of_trajectories;
171  std::string motion_model;
172 };
173 
179 {
180  unsigned int trajectory_id;
181  float start_angle;
182  float end_angle;
183  float turning_radius;
184  float trajectory_length;
185  float arc_length;
186  float straight_length;
187  bool left_turn;
188  MotionPoses poses;
189 };
190 
191 typedef std::vector<MotionPrimitive> MotionPrimitives;
192 typedef std::vector<MotionPrimitive *> MotionPrimitivePtrs;
193 
194 } // namespace nav2_smac_planner
195 
196 #endif // NAV2_SMAC_PLANNER__TYPES_HPP_
A struct of all lattice metadata.
Definition: types.hpp:165
A struct for poses in motion primitives.
Definition: types.hpp:129
MotionPose(const float &x, const float &y, const float &theta, const TurnDirection &turn_dir)
A constructor for nav2_smac_planner::MotionPose.
Definition: types.hpp:142
MotionPose()
A constructor for nav2_smac_planner::MotionPose.
Definition: types.hpp:133
A struct of all motion primitive data.
Definition: types.hpp:179
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:75
SmootherParams()
A constructor for nav2_smac_planner::SmootherParams.
Definition: types.hpp:65
A struct with the motion primitive's direction embedded.