Nav2 Navigation Stack - humble  humble
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 #include <xtensor/xtensor.hpp>
23 
24 #include "geometry_msgs/msg/twist.hpp"
25 #include "geometry_msgs/msg/twist_stamped.hpp"
26 
27 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
28 #include "rclcpp_lifecycle/lifecycle_node.hpp"
29 
30 #include "nav2_mppi_controller/tools/parameters_handler.hpp"
31 #include "nav2_mppi_controller/tools/utils.hpp"
32 #include "nav2_mppi_controller/critic_data.hpp"
33 #include "nav2_mppi_controller/critic_function.hpp"
34 
35 namespace mppi
36 {
37 
43 {
44 public:
48  CriticManager() = default;
49 
53  virtual ~CriticManager() = default;
54 
62  void on_configure(
63  rclcpp_lifecycle::LifecycleNode::WeakPtr parent, const std::string & name,
64  std::shared_ptr<nav2_costmap_2d::Costmap2DROS>, ParametersHandler *);
65 
70  void evalTrajectoriesScores(CriticData & data) const;
71 
72 protected:
76  void getParams();
77 
81  virtual void loadCritics();
82 
86  std::string getFullName(const std::string & name);
87 
88 protected:
89  rclcpp_lifecycle::LifecycleNode::WeakPtr parent_;
90  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
91  std::string name_;
92 
93  ParametersHandler * parameters_handler_;
94  std::vector<std::string> critic_names_;
95  std::unique_ptr<pluginlib::ClassLoader<critics::CriticFunction>> loader_;
96  std::vector<std::unique_ptr<critics::CriticFunction>> critics_;
97 
98  rclcpp::Logger logger_{rclcpp::get_logger("MPPIController")};
99 };
100 
101 } // namespace mppi
102 
103 #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 parmaeter changes.
Data to pass to critics for scoring, including state, trajectories, pruned path, global goal,...
Definition: critic_data.hpp:39