Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
constants.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__CONSTANTS_HPP_
16 #define NAV2_SMAC_PLANNER__CONSTANTS_HPP_
17 
18 #include <string>
19 
20 namespace nav2_smac_planner
21 {
22 enum class MotionModel
23 {
24  UNKNOWN = 0,
25  TWOD = 1,
26  DUBIN = 2,
27  REEDS_SHEPP = 3,
28  STATE_LATTICE = 4,
29  OMNI = 5,
30 };
31 
32 enum class GoalHeadingMode
33 {
34  UNKNOWN = 0,
35  DEFAULT = 1,
36  BIDIRECTIONAL = 2,
37  ALL_DIRECTION = 3,
38 };
39 
40 inline std::string toString(const MotionModel & n)
41 {
42  switch (n) {
43  case MotionModel::TWOD:
44  return "2D";
45  case MotionModel::DUBIN:
46  return "Dubin";
47  case MotionModel::REEDS_SHEPP:
48  return "Reeds-Shepp";
49  case MotionModel::STATE_LATTICE:
50  return "State Lattice";
51  default:
52  return "Unknown";
53  }
54 }
55 
56 inline MotionModel fromString(const std::string & n)
57 {
58  if (n == "2D") {
59  return MotionModel::TWOD;
60  } else if (n == "DUBIN") {
61  return MotionModel::DUBIN;
62  } else if (n == "REEDS_SHEPP") {
63  return MotionModel::REEDS_SHEPP;
64  } else if (n == "STATE_LATTICE") {
65  return MotionModel::STATE_LATTICE;
66  } else {
67  return MotionModel::UNKNOWN;
68  }
69 }
70 
71 inline std::string toString(const GoalHeadingMode & n)
72 {
73  switch (n) {
74  case GoalHeadingMode::DEFAULT:
75  return "DEFAULT";
76  case GoalHeadingMode::BIDIRECTIONAL:
77  return "BIDIRECTIONAL";
78  case GoalHeadingMode::ALL_DIRECTION:
79  return "ALL_DIRECTION";
80  default:
81  return "Unknown";
82  }
83 }
84 
85 inline GoalHeadingMode fromStringToGH(const std::string & n)
86 {
87  if (n == "DEFAULT") {
88  return GoalHeadingMode::DEFAULT;
89  } else if (n == "BIDIRECTIONAL") {
90  return GoalHeadingMode::BIDIRECTIONAL;
91  } else if (n == "ALL_DIRECTION") {
92  return GoalHeadingMode::ALL_DIRECTION;
93  } else {
94  return GoalHeadingMode::UNKNOWN;
95  }
96 }
97 
98 const float UNKNOWN_COST = 255.0;
99 const float OCCUPIED_COST = 254.0;
100 const float INSCRIBED_COST = 253.0;
101 const float MAX_NON_OBSTACLE_COST = 252.0;
102 const float FREE_COST = 0;
103 
104 } // namespace nav2_smac_planner
105 
106 #endif // NAV2_SMAC_PLANNER__CONSTANTS_HPP_