.. _program_listing_file__tmp_ws_src_ros2_planning_system_plansys2_planner_include_plansys2_planner_PlannerNode.hpp: Program Listing for File PlannerNode.hpp ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ros2_planning_system/plansys2_planner/include/plansys2_planner/PlannerNode.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2019 Intelligent Robotics Lab // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef PLANSYS2_PLANNER__PLANNERNODE_HPP_ #define PLANSYS2_PLANNER__PLANNERNODE_HPP_ #include #include #include #include #include "plansys2_domain_expert/DomainExpertClient.hpp" #include "plansys2_problem_expert/ProblemExpertClient.hpp" #include "plansys2_core/PlanSolverBase.hpp" #include "std_msgs/msg/empty.hpp" #include "lifecycle_msgs/msg/state.hpp" #include "lifecycle_msgs/msg/transition.hpp" #include "plansys2_msgs/srv/get_plan.hpp" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "pluginlib/class_loader.hpp" #include "pluginlib/class_list_macros.hpp" namespace plansys2 { class PlannerNode : public rclcpp_lifecycle::LifecycleNode { public: PlannerNode(); using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; using SolverMap = std::unordered_map; CallbackReturnT on_configure(const rclcpp_lifecycle::State & state); CallbackReturnT on_activate(const rclcpp_lifecycle::State & state); CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state); CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state); CallbackReturnT on_shutdown(const rclcpp_lifecycle::State & state); CallbackReturnT on_error(const rclcpp_lifecycle::State & state); void get_plan_service_callback( const std::shared_ptr request_header, const std::shared_ptr request, const std::shared_ptr response); private: pluginlib::ClassLoader lp_loader_; SolverMap solvers_; std::vector default_ids_; std::vector default_types_; std::vector solver_ids_; std::vector solver_types_; rclcpp::Service::SharedPtr get_plan_service_; }; template void declare_parameter_if_not_declared( NodeT node, const std::string & param_name, const rclcpp::ParameterValue & default_value = rclcpp::ParameterValue(), const rcl_interfaces::msg::ParameterDescriptor & parameter_descriptor = rcl_interfaces::msg::ParameterDescriptor()) { if (!node->has_parameter(param_name)) { node->declare_parameter(param_name, default_value, parameter_descriptor); } } template std::string get_plugin_type_param( NodeT node, const std::string & plugin_name) { declare_parameter_if_not_declared(node, plugin_name + ".plugin", rclcpp::ParameterValue("")); std::string plugin_type; if (!node->get_parameter(plugin_name + ".plugin", plugin_type)) { RCLCPP_FATAL(node->get_logger(), "'plugin' param not defined for %s", plugin_name.c_str()); exit(-1); } return plugin_type; } } // namespace plansys2 #endif // PLANSYS2_PLANNER__PLANNERNODE_HPP_