-
Notifications
You must be signed in to change notification settings - Fork 785
Open
Description
I have noticed in the tutorials that the input ports are parsed in the tick() method, which means they will be parsed repeatedly on every tick.
Is it safe to do the following, if we don't expect the input ports values to change?
class SaySomething : public SyncActionNode
{
public:
// If your Node has ports, you must use this constructor signature
SaySomething(const std::string& name, const NodeConfig& config)
: SyncActionNode(name, config)
{
Expected<std::string> msg = getInput<std::string>("message");
// Check if expected is valid. If not, throw its error
if (!msg)
{
throw BT::RuntimeError("missing required input [message]: ",
msg.error() );
}
input = msg.value();
}
// It is mandatory to define this STATIC method.
static PortsList providedPorts()
{
// This action has a single input port called "message"
return { InputPort<std::string>("message") };
}
// Override the virtual function tick()
NodeStatus tick() override
{
return NodeStatus::SUCCESS;
}
std::string input;
};
Metadata
Metadata
Assignees
Labels
No labels