Skip to content
Snippets Groups Projects

fix(engine): Do not stop if StopTrigger is not set

Closed René Paris requested to merge behavior_triggerable_composite_node into main
1 file
+ 11
6
Compare changes
  • Side-by-side
  • Inline
@@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@
#include <cassert>
#include <cassert>
#include <memory>
#include <memory>
 
#include "agnostic_behavior_tree/behavior_node.h"
namespace yase
namespace yase
{
{
@@ -99,6 +100,8 @@ using StopTriggerPtr = StrongNodePtr<struct StopTriggerTag>;
@@ -99,6 +100,8 @@ using StopTriggerPtr = StrongNodePtr<struct StopTriggerTag>;
/// └─ StartTrigger - optional
/// └─ StartTrigger - optional
/// └─ Child - mandatory
/// └─ Child - mandatory
///
///
 
/// @note According to the standard, the node never finishes if no StopTrigger
 
/// is defined, but the inner structure will be ticked every time.
class TriggerableCompositeNode : public CompositeNode
class TriggerableCompositeNode : public CompositeNode
{
{
public:
public:
@@ -194,25 +197,24 @@ private:
@@ -194,25 +197,24 @@ private:
}
}
///@brief tick as if no triggers would decorate the child
///@brief tick as if no triggers would decorate the child
NodeStatus tickWithoutTriggers()
void tickWithoutTriggers()
{
{
const auto status = m_child_node->executeTick();
const auto status = m_child_node->executeTick();
if (status == NodeStatus::kFailure)
if (status == NodeStatus::kFailure)
{
{
throw std::runtime_error("Child reported failure");
throw std::runtime_error("Child reported failure");
}
}
return status;
}
}
///@brief tick as if no stop trigger would decorate the start trigger
///@brief tick as if no stop trigger would decorate the start trigger
NodeStatus tickWithStartTrigger()
void tickWithStartTrigger()
{
{
if (start_trigger_node_)
if (start_trigger_node_)
{
{
const auto status = start_trigger_node_->executeTick();
const auto status = start_trigger_node_->executeTick();
if (status == NodeStatus::kRunning)
if (status == NodeStatus::kRunning)
{
{
return status;
return;
}
}
if (status == NodeStatus::kFailure)
if (status == NodeStatus::kFailure)
{
{
@@ -221,7 +223,7 @@ private:
@@ -221,7 +223,7 @@ private:
}
}
// descent to next hierarchy level
// descent to next hierarchy level
return tickWithoutTriggers();
tickWithoutTriggers();
}
}
///@brief tick the highest level, i.e. starting with the (optional) stop trigger
///@brief tick the highest level, i.e. starting with the (optional) stop trigger
@@ -241,7 +243,10 @@ private:
@@ -241,7 +243,10 @@ private:
}
}
// descent to next hierarchy level
// descent to next hierarchy level
return tickWithStartTrigger();
tickWithStartTrigger();
 
 
// don't consider children on purpose (see class description)
 
return NodeStatus::kRunning;
}
}
TransientNode::Ptr stop_trigger_node_{nullptr};
TransientNode::Ptr stop_trigger_node_{nullptr};
Loading