@@ -62,6 +62,17 @@ class BlackboardPreconditionNode : public DecoratorNode
62
62
63
63
// ----------------------------------------------------
64
64
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
+
65
76
template <typename T> inline
66
77
NodeStatus BlackboardPreconditionNode<T>::tick()
67
78
{
@@ -72,17 +83,10 @@ NodeStatus BlackboardPreconditionNode<T>::tick()
72
83
setStatus (NodeStatus::RUNNING);
73
84
74
85
if ( getInput (" value_A" , value_A) &&
75
- getInput (" value_B" , value_B) )
86
+ getInput (" value_B" , value_B) &&
87
+ IsSame (value_A, value_B))
76
88
{
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 ();
86
90
}
87
91
88
92
if ( child ()->status () == NodeStatus::RUNNING )
@@ -93,6 +97,7 @@ NodeStatus BlackboardPreconditionNode<T>::tick()
93
97
return default_return_status;
94
98
}
95
99
100
+
96
101
} // end namespace
97
102
98
103
#endif
0 commit comments