System
- OS: Ubuntu 24.04
- CPU: Ryzen 3600x
- GPU: RTX 3080
- ROS: ROS 2 Jazzy
- BehaviorTree.cpp: v4.9.0
Problem description
Hello @facontidavide,
I have a BT::StatefulAction node called MissionOrchestrator. It has two primary branches MISSION_PLAN and NAVIGATE as shown below (cannot show exact code but the following example is illustrative enough)
The problem is with the class wide global variables current_id_ and `
if (incoming_state == State::MISSION_PLAN)
{
// Parse mission plan, sets `mission_plan_` std::vector
bool parse_status = parseMissionPlan(qr_data_str, current_id_);
...
return BT::NodeStatus::SUCCESS;
}
if (incoming_state == State::NAVIGATE)
{
if (something_happens_here){
// Print mission_plan_
std::string plan_str;
for (size_t i = 0; i < mission_plan_.size(); i++) {
plan_str += "[" + std::to_string(i) + "]:" + mission_plan_[i];
if (i < mission_plan_.size() - 1) plan_str += " | ";
}
RCLCPP_INFO(node_->get_logger(), "MissionOrchestrator: mission_plan_ (size=%zu) = %s | ptr=%zu",
mission_plan_.size(), plan_str.c_str(), mission_target_ptr_);
// rest of code
}
The output from the above comes out like the following
[INFO] [1779392658.517353617] [pkg]: MissionOrchestrator: onStart() entered
[INFO] [1779392658.517451354] [pkg]: MissionOrchestrator: mission_plan_ (size=0) = | ptr=0
Is it a normal behavior that when MissionOrchestrator node is encountered in different branches of the BT tree, it is essentially reset? Given this behaivor the solution is to move book keeping of persistent variables to Blackboards but I was wondering if the nodes themselves retain data between re-ticks?
Thanks in advance,
Best,
@Mechazo11
System
Problem description
Hello @facontidavide,
I have a BT::StatefulAction node called
MissionOrchestrator. It has two primary branches MISSION_PLAN and NAVIGATE as shown below (cannot show exact code but the following example is illustrative enough)The problem is with the class wide global variables
current_id_and `The output from the above comes out like the following
Is it a normal behavior that when
MissionOrchestratornode is encountered in different branches of the BT tree, it is essentially reset? Given this behaivor the solution is to move book keeping of persistent variables to Blackboards but I was wondering if the nodes themselves retain data between re-ticks?Thanks in advance,
Best,
@Mechazo11