Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
critic_manager.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__CRITIC_MANAGER_HPP_
16 #define NAV2_MPPI_CONTROLLER__CRITIC_MANAGER_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 #include <pluginlib/class_loader.hpp>
22 
23 #include "geometry_msgs/msg/twist.hpp"
24 #include "geometry_msgs/msg/twist_stamped.hpp"
25 
26 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
27 #include "rclcpp_lifecycle/lifecycle_node.hpp"
28 
29 #include "nav2_mppi_controller/tools/parameters_handler.hpp"
30 #include "nav2_mppi_controller/tools/utils.hpp"
31 #include "nav2_mppi_controller/critic_data.hpp"
32 #include "nav2_mppi_controller/critic_function.hpp"
33 
34 namespace mppi
35 {
36 
42 {
43 public:
44  typedef std::vector<std::unique_ptr<critics::CriticFunction>> Critics;
48  CriticManager() = default;
49 
50 
54  virtual ~CriticManager() = default;
55 
63  void on_configure(
64  rclcpp_lifecycle::LifecycleNode::WeakPtr parent, const std::string & name,
65  std::shared_ptr<nav2_costmap_2d::Costmap2DROS>, ParametersHandler *);
66 
71  void evalTrajectoriesScores(CriticData & data) const;
72 
73 protected:
77  void getParams();
78 
82  virtual void loadCritics();
83 
87  std::string getFullName(const std::string & name);
88 
89 protected:
90  rclcpp_lifecycle::LifecycleNode::WeakPtr parent_;
91  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
92  std::string name_;
93 
94  ParametersHandler * parameters_handler_;
95  std::vector<std::string> critic_names_;
96  std::unique_ptr<pluginlib::ClassLoader<critics::CriticFunction>> loader_;
97  Critics critics_;
98 
99  rclcpp::Logger logger_{rclcpp::get_logger("MPPIController")};
100 };
101 
102 } // namespace mppi
103 
104 #endif // NAV2_MPPI_CONTROLLER__CRITIC_MANAGER_HPP_
Manager of objective function plugins for scoring trajectories.
virtual ~CriticManager()=default
Virtual Destructor for mppi::CriticManager.
void on_configure(rclcpp_lifecycle::LifecycleNode::WeakPtr parent, const std::string &name, std::shared_ptr< nav2_costmap_2d::Costmap2DROS >, ParametersHandler *)
Configure critic manager on bringup and load plugins.
void getParams()
Get parameters (critics to load)
void evalTrajectoriesScores(CriticData &data) const
Score trajectories by the set of loaded critic functions.
CriticManager()=default
Constructor for mppi::CriticManager.
virtual void loadCritics()
Load the critic plugins.
std::string getFullName(const std::string &name)
Get full-name namespaced critic IDs.
Handles getting parameters and dynamic parameter changes.
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...
Definition: critic_data.hpp:40