Groot icon indicating copy to clipboard operation
Groot copied to clipboard

Understanding the Nodes

Open NatkaB opened this issue 3 years ago • 1 comments

I am trying to understand what each node in Groot does. I couldn't find information about some of them in the documentation. For example I do not understand what "BlackboardCheckString", "BlackboardCheckDouble" or "BlackboardCheckInt" do. Could someone explain this to me or show me the website with info about this?

NatkaB avatar Sep 08 '21 22:09 NatkaB

#ifndef DECORATOR_BLACKBOARD_PRECONDITION_NODE_H #define DECORATOR_BLACKBOARD_PRECONDITION_NODE_H

#include "behaviortree_cpp_v3/decorator_node.h"

namespace BT { /**

  • This node excute its child only if the value of a given input port
  • is equal to the expected one.
  • If this precondition is met, this node will return the same status of the
  • child, otherwise it will return the value specified in "return_on_mismatch".
  • Example:
  • <BlackboardCheckInt value_A="{the_answer}"
  •                 value_B="42"
    
  •                 return_on_mismatch="FAILURE" />
    

*/ template <typename T> class BlackboardPreconditionNode : public DecoratorNode { public: BlackboardPreconditionNode(const std::string& name, const NodeConfiguration& config) : DecoratorNode(name, config) { if( std::is_same<T,int>::value) setRegistrationID("BlackboardCheckInt"); else if( std::is_same<T,double>::value) setRegistrationID("BlackboardCheckDouble"); else if( std::is_same<T,std::string>::value) setRegistrationID("BlackboardCheckString"); }

virtual ~BlackboardPreconditionNode() override = default;

static PortsList providedPorts()
{
    return {InputPort("value_A"),
            InputPort("value_B"),
            InputPort<NodeStatus>("return_on_mismatch") };
}

private: virtual BT::NodeStatus tick() override; };

//----------------------------------------------------

template<typename T> inline NodeStatus BlackboardPreconditionNode<T>::tick() { T value_A; T value_B; NodeStatus default_return_status = NodeStatus::FAILURE;

setStatus(NodeStatus::RUNNING);

if( getInput("value_A", value_A) &&
    getInput("value_B", value_B) &&
    value_B == value_A )
{
    return child_node_->executeTick();
}

if( child()->status() == NodeStatus::RUNNING )
{
    haltChild();
}
getInput("return_on_mismatch", default_return_status);
return default_return_status;

}

} // end namespace

#endif

DoMissHome avatar Dec 31 '21 08:12 DoMissHome