Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
path_angle_critic.hpp
1 // Copyright (c) 2022 Samsung Research America, @artofnothingness Alexey Budyakov
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.
14 
15 #ifndef NAV2_MPPI_CONTROLLER__CRITICS__PATH_ANGLE_CRITIC_HPP_
16 #define NAV2_MPPI_CONTROLLER__CRITICS__PATH_ANGLE_CRITIC_HPP_
17 
18 #include <string>
19 #include "nav2_mppi_controller/critic_function.hpp"
20 #include "nav2_mppi_controller/models/state.hpp"
21 #include "nav2_mppi_controller/tools/utils.hpp"
22 #include "nav2_core/controller_exceptions.hpp"
23 
24 namespace mppi::critics
25 {
26 
30 enum class PathAngleMode
31 {
32  FORWARD_PREFERENCE = 0,
33  NO_DIRECTIONAL_PREFERENCE = 1,
34  CONSIDER_FEASIBLE_PATH_ORIENTATIONS = 2
35 };
36 
40 std::string modeToStr(const PathAngleMode & mode)
41 {
42  if (mode == PathAngleMode::FORWARD_PREFERENCE) {
43  return "Forward Preference";
44  } else if (mode == PathAngleMode::CONSIDER_FEASIBLE_PATH_ORIENTATIONS) {
45  return "Consider Feasible Path Orientations";
46  } else if (mode == PathAngleMode::NO_DIRECTIONAL_PREFERENCE) {
47  return "No Directional Preference";
48  } else {
49  return "Invalid mode!";
50  }
51 }
52 
59 {
60 public:
64  void initialize() override;
65 
72  void score(CriticData & data) override;
73 
74 protected:
75  float max_angle_to_furthest_{0};
76  float threshold_to_consider_{0};
77 
78  size_t offset_from_furthest_{0};
79  bool reversing_allowed_{true};
80  PathAngleMode mode_{0};
81 
82  unsigned int power_{0};
83  float weight_{0};
84  bool enforce_path_inversion_{false};
85 };
86 
87 } // namespace mppi::critics
88 
89 #endif // NAV2_MPPI_CONTROLLER__CRITICS__PATH_ANGLE_CRITIC_HPP_
Abstract critic objective function to score trajectories.
void initialize() override
Initialize critic.
void score(CriticData &data) override
Evaluate cost related to robot orientation at goal pose (considered only if robot near last goal in c...
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...
Definition: critic_data.hpp:40