Closed
Description
Describe the bug
I am testing simple mock testing using the guide here and I am experiencing that my tree stops ticking once the tree gets to the substituted node.
The tree is loaded using XML and the substitution rules are loaded using a JSON file
How to Reproduce
This is my tree:
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence>
<PrintToConsole
name="PrintToConsole"
string="testing"
prefix="pre sub"
timestamp="false"
/>
<Script name="script_1" code=" next_inspection_point:='0' "/>
<PrintToConsole
name="PrintToConsole"
string="testing"
prefix="post sub"
timestamp="false"
/>
<Delay delay_msec="2000">
<AlwaysSuccess/>
</Delay>
</Sequence>
</BehaviorTree>
</root>
This is the part of the code that runs the tree:
void Mk4BehaviorTrees::execute(const std::shared_ptr<BtGoalHandle> goal_handle)
{
RCLCPP_INFO(get_logger(), "Executing goal");
const auto goal_details = goal_handle->get_goal();
if (does_inspection_file_exist(goal_details->path)) {
load_inspection(goal_details->path);
} else {
send_no_inspection_file(goal_handle, goal_details->path);
return;
}
// This is called if the using_mock_nodes is set to true
load_mock_nodes();
start_time_ = get_clock()->now();
while (rclcpp::ok()) {
if (goal_handle->is_canceling()) {
running_tree_->haltTree();
cleanup_tree();
send_goal_cancelled(goal_handle);
is_tree_being_executed_ = false;
return;
}
send_feedback(goal_handle);
running_tree_->tickOnce();
RCLCPP_INFO(get_logger(), "Ticking");
running_tree_->sleep(std::chrono::milliseconds(100));
}
if (rclcpp::ok()) {
cleanup_tree();
send_goal_completed(goal_handle);
}
}
Without the substitutions this is the trees output:
[component_container-1] [INFO] [1738660757.723056057] [behavior_trees_node]:
[component_container-1] pre sub
[component_container-1] testing
[component_container-1]
[component_container-1] [INFO] [1738660757.723304994] [behavior_trees_node]:
[component_container-1] post sub
[component_container-1] testing
[component_container-1]
[component_container-1] [INFO] [1738660757.723522637] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660757.824344850] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660757.925034097] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.025824578] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.126585792] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.227266241] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.327910303] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.428539384] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.529365846] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.633216384] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.733816826] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.834551317] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660758.935329955] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.036006334] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.136620944] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.237264127] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.337703341] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.438322202] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.539171086] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.639594343] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.723999631] [behavior_trees_node]: Ticking
[component_container-1] [INFO] [1738660759.824982967] [behavior_trees_node]:
[component_container-1] pre sub
[component_container-1] testing
[component_container-1]
[component_container-1] [INFO] [1738660759.825460732] [behavior_trees_node]:
[component_container-1] post sub
[component_container-1] testing
[component_container-1]
When loading the following substitution:
{
"TestNodeConfigs": {
"MyTest": {
"return_status": "SUCCESS"
}
},
"SubstitutionRules": {
"script_1": "MyTest"
}
}
The code output is:
[component_container-1] [INFO] [1738660946.246000910] [behavior_trees_node]:
[component_container-1] pre sub
[component_container-1] testing
[component_container-1]
And never prints the Ticking message.
Also the execution hangs so I cannot finish the process cleanly.
Any pointer how I could debug this?
Metadata
Metadata
Assignees
Labels
No labels