Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about setPreTickFunction #859

Open
robologics1 opened this issue Aug 21, 2024 · 0 comments
Open

Question about setPreTickFunction #859

robologics1 opened this issue Aug 21, 2024 · 0 comments

Comments

@robologics1
Copy link

I am trying to add constant check function to my structure via setPreTickFunction() . I want the node whose turn it is to check the condition just before it runs. Should I write the following code inside a while loop, or is it enough to set the pretickfunction just once?
Additionally, in the code below, it prints the ros_info and the second cerr message, but it does not print the cerr message inside the lambda function, so I think I am making a mistake somewhere in the pretickfunction. Thank you.
Function
`void Test::setupActionNodesPreTick(BT::Tree& tree_)
{
tree_.applyVisitor([&](BT::TreeNode* node) -> void {

    if (node->type() == BT::NodeType::ACTION && node->config().action_ptr->conditions != "null") 
    {
      
        ROS_INFO("it arrives here %s ", node->config().action_ptr->conditions.c_str());
        
        node->setPreTickFunction([this, node](BT::TreeNode& action_node) -> BT::NodeStatus {
        std::cerr << "Processing node in : " << node->registrationName().c_str() << std::endl;
        if (!this->checkConditions(node->config().action_ptr->conditions)) {
        return BT::NodeStatus::SKIPPED;
        }
        return BT::NodeStatus::IDLE;
        });

        std::cerr << "Processing node in : " << node->registrationName().c_str() << std::endl;
      
    }
});

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant