| 52 | }; |
| 53 | |
| 54 | TEST(executiotest_noden_tree, bt_builder_factory) |
| 55 | { |
| 56 | { |
| 57 | auto test_node = rclcpp::Node::make_shared("get_action_from_string"); |
| 58 | auto domain_node = std::make_shared<plansys2::DomainExpertNode>(); |
| 59 | auto problem_node = std::make_shared<plansys2::ProblemExpertNode>(); |
| 60 | auto planner_node = std::make_shared<plansys2::PlannerNode>(); |
| 61 | auto domain_client = std::make_shared<plansys2::DomainExpertClient>(); |
| 62 | auto problem_client = std::make_shared<plansys2::ProblemExpertClient>(); |
| 63 | auto planner_client = std::make_shared<plansys2::PlannerClient>(); |
| 64 | |
| 65 | std::string pkgpath = ament_index_cpp::get_package_share_directory("plansys2_executor"); |
| 66 | |
| 67 | domain_node->set_parameter({"model_file", pkgpath + "/pddl/factory.pddl"}); |
| 68 | problem_node->set_parameter({"model_file", pkgpath + "/pddl/factory.pddl"}); |
| 69 | |
| 70 | rclcpp::experimental::executors::EventsExecutor exe; |
| 71 | |
| 72 | exe.add_node(domain_node->get_node_base_interface()); |
| 73 | exe.add_node(problem_node->get_node_base_interface()); |
| 74 | exe.add_node(planner_node->get_node_base_interface()); |
| 75 | |
| 76 | bool finish = false; |
| 77 | std::thread t([&]() { |
| 78 | while (!finish) {exe.spin_some();} |
| 79 | }); |
| 80 | |
| 81 | |
| 82 | domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 83 | problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 84 | |
| 85 | planner_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE); |
| 86 | |
| 87 | { |
| 88 | rclcpp::Rate rate(10); |
| 89 | auto start = test_node->now(); |
| 90 | while ((test_node->now() - start).seconds() < 0.5) { |
| 91 | rate.sleep(); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 96 | problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 97 | planner_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE); |
| 98 | |
| 99 | { |
| 100 | rclcpp::Rate rate(10); |
| 101 | auto start = test_node->now(); |
| 102 | while ((test_node->now() - start).seconds() < 0.5) { |
| 103 | rate.sleep(); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | ASSERT_TRUE(problem_client->addInstance(plansys2::Instance("robot1", "robot"))); |
| 108 | ASSERT_TRUE(problem_client->addInstance(plansys2::Instance("robot2", "robot"))); |
| 109 | ASSERT_TRUE(problem_client->addInstance(plansys2::Instance("robot3", "robot"))); |
| 110 | |
| 111 | ASSERT_TRUE(problem_client->addInstance(plansys2::Instance("wheels_zone", "zone"))); |
nothing calls this directly
no test coverage detected