| 31 | #include "plansys2_tests/execution_logger.hpp" |
| 32 | |
| 33 | TEST(test_2, test_2) |
| 34 | { |
| 35 | auto test_node = rclcpp::Node::make_shared("test_node"); |
| 36 | auto domain_node = std::make_shared<plansys2::DomainExpertNode>(); |
| 37 | auto problem_node = std::make_shared<plansys2::ProblemExpertNode>(); |
| 38 | auto planner_node = std::make_shared<plansys2::PlannerNode>(); |
| 39 | auto executor_node = std::make_shared<plansys2::ExecutorNode>(); |
| 40 | |
| 41 | auto domain_client = std::make_shared<plansys2::DomainExpertClient>(); |
| 42 | auto problem_client = std::make_shared<plansys2::ProblemExpertClient>(); |
| 43 | auto planner_client = std::make_shared<plansys2::PlannerClient>(); |
| 44 | auto executor_client = std::make_shared<plansys2::ExecutorClient>(); |
| 45 | |
| 46 | auto move_action_node = plansys2_tests::TestAction::make_shared("move"); |
| 47 | auto ask_charge_node = plansys2_tests::TestAction::make_shared("askcharge"); |
| 48 | auto charge_node = plansys2_tests::TestAction::make_shared("charge"); |
| 49 | |
| 50 | auto execution_logger = plansys2_tests::ExecutionLogger::make_shared(); |
| 51 | |
| 52 | std::string pkgpath = ament_index_cpp::get_package_share_directory("plansys2_tests"); |
| 53 | |
| 54 | domain_node->set_parameter({"model_file", pkgpath + "/test_2/pddl/test_2.pddl"}); |
| 55 | problem_node->set_parameter({"model_file", pkgpath + "/test_2/pddl/test_2.pddl"}); |
| 56 | |
| 57 | rclcpp::experimental::executors::EventsExecutor exe; |
| 58 | |
| 59 | exe.add_node(domain_node->get_node_base_interface()); |
| 60 | exe.add_node(problem_node->get_node_base_interface()); |
| 61 | exe.add_node(planner_node->get_node_base_interface()); |
| 62 | exe.add_node(executor_node->get_node_base_interface()); |
| 63 | exe.add_node(move_action_node->get_node_base_interface()); |
| 64 | exe.add_node(ask_charge_node->get_node_base_interface()); |
| 65 | exe.add_node(charge_node->get_node_base_interface()); |
| 66 | exe.add_node(execution_logger->get_node_base_interface()); |
| 67 | |
| 68 | bool finish = false; |
| 69 | std::thread t([&]() { |
| 70 | while (!finish) {exe.spin_some();} |
| 71 | }); |
| 72 | |
| 73 | domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 74 | problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 75 | planner_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 76 | executor_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 77 | |
| 78 | { |
| 79 | rclcpp::Rate rate(10); |
| 80 | auto start = test_node->now(); |
| 81 | while ((test_node->now() - start).seconds() < 0.5) { |
| 82 | rate.sleep(); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 87 | problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 88 | planner_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 89 | executor_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 90 |
nothing calls this directly
no test coverage detected