Skip to content

Commit 5b474b8

Browse files
committed
fix compilation
1 parent e493cc1 commit 5b474b8

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

include/behaviortree_cpp_v3/decorators/blackboard_precondition.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ class BlackboardPreconditionNode : public DecoratorNode
6262

6363
//----------------------------------------------------
6464

65+
template<typename T> inline bool IsSame(const T& a, const T& b)
66+
{
67+
return a == b;
68+
}
69+
70+
inline bool IsSame(const double& a, const double& b)
71+
{
72+
constexpr double EPS = static_cast<double>(std::numeric_limits<float>::epsilon());
73+
return std::abs(a - b) <= EPS;
74+
}
75+
6576
template<typename T> inline
6677
NodeStatus BlackboardPreconditionNode<T>::tick()
6778
{
@@ -72,17 +83,10 @@ NodeStatus BlackboardPreconditionNode<T>::tick()
7283
setStatus(NodeStatus::RUNNING);
7384

7485
if( getInput("value_A", value_A) &&
75-
getInput("value_B", value_B) )
86+
getInput("value_B", value_B) &&
87+
IsSame(value_A, value_B))
7688
{
77-
bool is_equal = (value_B == value_A);
78-
if ( std::is_same<double, T>::value || std::is_same<float, T>::value )
79-
{
80-
is_equal = std::abs(value_B - value_A) <= std::numeric_limits<float>::epsilon();
81-
}
82-
if(is_equal)
83-
{
84-
return child_node_->executeTick();
85-
}
89+
return child_node_->executeTick();
8690
}
8791

8892
if( child()->status() == NodeStatus::RUNNING )
@@ -93,6 +97,7 @@ NodeStatus BlackboardPreconditionNode<T>::tick()
9397
return default_return_status;
9498
}
9599

100+
96101
} // end namespace
97102

98103
#endif

0 commit comments

Comments
 (0)