Repository navigation
post conditions #1063
Replies: 2 comments
|
That's right. The XML post-conditions ( The idiomatic XML way is a <RetryUntilSuccessful num_attempts="10">
<Sequence>
<GetStateNode state="{state}"/>
<ScriptCondition code="state == 5"/>
</Sequence>
</RetryUntilSuccessful>If If you need it in many places, you have two options:
|
|
You read the code right. The post-condition attributes ( The usual way to write "succeed only if the output is X" is to put a <RetryUntilSuccessful num_attempts="-1">
<Sequence>
<GetState state="{state}"/>
<ScriptCondition code="state == 5"/>
</Sequence>
</RetryUntilSuccessful>If If you really want it on the node itself, the only hook that can override the status is the C++ post-tick callback. auto bb = tree.rootBlackboard();
tree.applyVisitor([bb](BT::TreeNode* node) {
if(node->registrationName() == "GetState") {
node->setPostTickFunction([bb](BT::TreeNode&, BT::NodeStatus s) {
if(s == BT::NodeStatus::SUCCESS && bb->get<int>("state") != 5)
return BT::NodeStatus::FAILURE;
return s;
});
}
});The condition is then hidden in C++, so the XML option is usually easier to maintain. I tested both versions against current master with a dummy |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have a question about post conditions. I have an action node that checks a certain state and outputs this as an int on the output named "state".
I wanted to have a post condition that would fail if the "state" output after the tick is for example not 5. That would be nice to use in a retry until success decorator.
Intuitively I would want to say _successIf="state == 5" in the xml for my node. But then I found out that is actually a pre condition, so that was not usable for this. But, something similar would be nice... I would like to be able to check after the tick of the node: when the tick() returns success, then execute a script, and override the tick success status by the result of the outcome of this script.
I see in code this is not supported, only a post tick function can change the status, but it has no scripting possiblity it seems?
What would be the best way to do this? I could use precondition decorator after this "GetStateNode" and check the output port value there, but it would be nice if it could be written more compact.
Best regards
All reactions