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