A class template for creating a behavior tree decorator node to help iterate through a vector of items.
More...
template<typename T>
class moveit_studio::behaviors::ForEach< T >
A class template for creating a behavior tree decorator node to help iterate through a vector of items.
- Given an instance of std::vector<T> which is provided on an input data port and contains N items, set the value of an output data port to the item in the vector which is at index 0 and then tick the ForEach decorator's child node until the child returns SUCCESS or FAILURE.
- If the child returns SUCCESS, set the value of the output data port to the item at index 1 and repeat ticking the child node.
- If the child returns FAILURE, stop iterating through the vector or ticking the child and return FAILURE.
- Repeat until we have iterated through all elements of the input vector, and finally return SUCCESS.
NOTE: The value of the out
output data port is only expected to be used by the child node or subtree of the ForEach node which sets it. While it is possible to access this port from elsewhere in the behavior tree, this may result in unexpected behavior so it is not recommended.
Data Port Name | Port Type | Object Type |
vector_in | input | std::vector<T> |
out | output | T |
- Template Parameters
-
T | Determines the types of the input and output data port. |