MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_studio::behaviors::ForEachUntilSuccess Class Reference

A decorator node that iterates through a vector of items, stopping on first successful child node tick. More...

#include <for_each_until_success.hpp>

Inheritance diagram for moveit_studio::behaviors::ForEachUntilSuccess:
Collaboration diagram for moveit_studio::behaviors::ForEachUntilSuccess:

Public Member Functions

 ForEachUntilSuccess (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< moveit_studio::behaviors::BehaviorContext > &shared_resources)
 
 ~ForEachUntilSuccess () override=default
 
- Public Member Functions inherited from moveit_studio::behaviors::SharedResourcesNode< BT::DecoratorNode >
 SharedResourcesNode (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 Constructor for SharedResourcesNode. Called by BT::BehaviorTreeFactory when creating a new behavior tree containing this node.
 

Static Public Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from moveit_studio::behaviors::SharedResourcesNode< BT::DecoratorNode >
std::shared_ptr< BehaviorContextshared_resources_
 

Detailed Description

A decorator node that iterates through a vector of items, stopping on first successful child node tick.

  • Given an instance of std::vector<BT::Any> 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 ForEachUntilSuccess decorator's child node until the child returns SUCCESS or FAILURE.
  • If the vector is empty do not call the child, return SUCCESS.
  • If the child returns SUCCESS, stop iterating through the vector or ticking the child and return SUCCESS.
  • If the child returns FAILURE, move on to the next vector element and repeat ticking the child node.
  • Repeat until we have iterated through all elements of the input vector, and finally return FAILURE.

For each element set in the output, the index of the element in the input vector is also set in the index output data port. Therefore this Behavior outputs pairs [index, out] for each element in the input vector, containing the element index (starting at 0) and its value.

NOTE: The output values are only expected to be used by the child node or subtree of the ForEachUntilSuccess node which sets it. While it is possible to access these ports 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<BT::Any>
index output int
out output BT::Any

Constructor & Destructor Documentation

◆ ForEachUntilSuccess()

moveit_studio::behaviors::ForEachUntilSuccess::ForEachUntilSuccess ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< moveit_studio::behaviors::BehaviorContext > &  shared_resources 
)

◆ ~ForEachUntilSuccess()

moveit_studio::behaviors::ForEachUntilSuccess::~ForEachUntilSuccess ( )
overridedefault

Member Function Documentation

◆ metadata()

BT::KeyValueVector moveit_studio::behaviors::ForEachUntilSuccess::metadata ( )
static

◆ providedPorts()

BT::PortsList moveit_studio::behaviors::ForEachUntilSuccess::providedPorts ( )
static

Required implementation of the static providedPorts function.

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

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