MCPcopy Create free account
hub / github.com/PlanSys2/ros2_planning_system / TEST

Function TEST

plansys2_executor/test/unit/bt_node_test.cpp:77–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75};
76
77TEST(problem_expert, wait_overall_req_test)
78{
79 {
80 auto test_node = rclcpp::Node::make_shared("test_node");
81 auto test_lc_node = rclcpp_lifecycle::LifecycleNode::make_shared("test_lc_node");
82 auto domain_node = std::make_shared<plansys2::DomainExpertNode>();
83 auto problem_node = std::make_shared<plansys2::ProblemExpertNode>();
84
85 auto domain_client = std::make_shared<plansys2::DomainExpertClient>();
86 auto problem_client = std::make_shared<plansys2::ProblemExpertClient>();
87
88 std::string pkgpath = ament_index_cpp::get_package_share_directory("plansys2_executor");
89
90 domain_node->set_parameter({"model_file", pkgpath + "/pddl/factory2.pddl"});
91 problem_node->set_parameter({"model_file", pkgpath + "/pddl/factory2.pddl"});
92
93 rclcpp::experimental::executors::EventsExecutor exe;
94
95 exe.add_node(domain_node->get_node_base_interface());
96 exe.add_node(problem_node->get_node_base_interface());
97
98 bool finish = false;
99 std::thread t([&]() {
100 while (!finish) {exe.spin_some();}
101 });
102
103
104 domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE);
105 problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE);
106
107 {
108 rclcpp::Rate rate(10);
109 auto start = test_node->now();
110 while ((test_node->now() - start).seconds() < 0.5) {
111 rate.sleep();
112 }
113 }
114
115 domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);
116 problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);
117
118 {
119 rclcpp::Rate rate(10);
120 auto start = test_node->now();
121 while ((test_node->now() - start).seconds() < 0.5) {
122 rate.sleep();
123 }
124 }
125
126 auto action_map = std::make_shared<std::map<std::string, plansys2::ActionExecutionInfo>>();
127 (*action_map)["(move robot1 wheels_zone assembly_zone):5"] = plansys2::ActionExecutionInfo();
128 (*action_map)["(move robot1 wheels_zone assembly_zone):5"].action_info =
129 domain_client->getDurativeAction(
130 plansys2::get_action_name("(move robot1 wheels_zone assembly_zone)"),
131 plansys2::get_action_params("(move robot1 wheels_zone assembly_zone)"));
132
133 ASSERT_FALSE(
134 (*action_map)["(move robot1 wheels_zone assembly_zone):5"].action_info.is_empty());

Callers

nothing calls this directly

Calls 11

ActionExecutionInfoClass · 0.85
get_action_nameFunction · 0.85
get_action_paramsFunction · 0.85
PredicateClass · 0.85
drain_rosFunction · 0.85
is_emptyMethod · 0.80
InstanceClass · 0.50
getDurativeActionMethod · 0.45
addInstanceMethod · 0.45
addPredicateMethod · 0.45
existPredicateMethod · 0.45

Tested by

no test coverage detected