MoveIt Pro Behavior Interface  5.0.1
Library for developing custom behaviors for use in MoveIt Pro
moveit_studio::behaviors::ForEach< T > Class Template Reference

A class template for creating a behavior tree decorator node to help iterate through a vector of items. More...

#include <for_each.hpp>

Inheritance diagram for moveit_studio::behaviors::ForEach< T >:
Collaboration diagram for moveit_studio::behaviors::ForEach< T >:

Public Member Functions

 ForEach (const std::string &name, const BT::NodeConfiguration &config)
 
virtual ~ForEach () override=default
 

Static Public Member Functions

static BT::PortsList providedPorts ()
 Required implementation of the static providedPorts function. More...
 
static BT::KeyValueVector metadata ()
 

Static Public Attributes

static constexpr auto kPortIDInput = "vector_in"
 Input/output port names that should be used in all ForEach Behaviors. More...
 
static constexpr auto kPortIDOutput = "out"
 

Detailed Description

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
TDetermines the types of the input and output data port.

Constructor & Destructor Documentation

◆ ForEach()

template<typename T >
moveit_studio::behaviors::ForEach< T >::ForEach ( const std::string &  name,
const BT::NodeConfiguration &  config 
)

◆ ~ForEach()

template<typename T >
virtual moveit_studio::behaviors::ForEach< T >::~ForEach ( )
overridevirtualdefault

Member Function Documentation

◆ metadata()

template<typename T >
static BT::KeyValueVector moveit_studio::behaviors::ForEach< T >::metadata ( )
static

◆ providedPorts()

template<typename T >
static BT::PortsList moveit_studio::behaviors::ForEach< T >::providedPorts ( )
static

Required implementation of the static providedPorts function.

Returns
The list of input and output ports used by this behavior.

Member Data Documentation

◆ kPortIDInput

template<typename T >
constexpr auto moveit_studio::behaviors::ForEach< T >::kPortIDInput = "vector_in"
staticconstexpr

Input/output port names that should be used in all ForEach Behaviors.

◆ kPortIDOutput

template<typename T >
constexpr auto moveit_studio::behaviors::ForEach< T >::kPortIDOutput = "out"
staticconstexpr

The documentation for this class was generated from the following files: