Skip to content

Commit

Permalink
(roseus_bt) Enable execution of layered behavior trees
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Nov 21, 2022
1 parent 4d8793a commit 7b70972
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions roseus_bt/include/roseus_bt/gen_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ std::string GenTemplate::main_function_template(std::string roscpp_node_name,
return fmt::format(" ros::init(argc, argv, \"{}\");", roscpp_node_name);
};
auto format_create_tree = [xml_filename]() {
return fmt::format(" auto tree = factory.createTreeFromFile(\"{}\");", xml_filename);
return fmt::format(" auto tree = factory.maybeCreateLayeredTreeFromFile(\"{}\");",
xml_filename);
};

std::string fmt_string = 1 + R"(
Expand All @@ -463,14 +464,14 @@ int main(int argc, char **argv)
%4%%5%%6%
%3%
roseus_bt::register_blackboard_variables(&tree, init_variables);
roseus_bt::register_blackboard_variables(tree.get(), init_variables);
std::string timestamp = std::to_string(ros::Time::now().toNSec());
std::string log_filename(fmt::format("%7%", timestamp));
StdCoutLogger logger_cout(tree);
FileLogger logger_file(tree, log_filename.c_str());
PublisherZMQ publisher_zmq(tree);
StdCoutLogger logger_cout(*tree);
FileLogger logger_file(*tree, log_filename.c_str());
PublisherZMQ publisher_zmq(*tree);
NodeStatus status = NodeStatus::IDLE;
Expand All @@ -480,7 +481,7 @@ int main(int argc, char **argv)
while( ros::ok() && (status == NodeStatus::IDLE || status == NodeStatus::RUNNING))
{
ros::spinOnce();
status = tree.tickRoot();
status = tree->tickRoot();
ros::Duration sleep_time(0.005);
sleep_time.sleep();
}
Expand Down

0 comments on commit 7b70972

Please sign in to comment.