MoveIt Pro Behavior Interface  5.2.0
Library for developing custom behaviors for use in MoveIt Pro
test_behavior.hpp File Reference
#include <gmock/gmock.h>
#include <behaviortree_cpp/tree_node.h>
#include <behaviortree_cpp/blackboard.h>
#include <moveit_studio_behavior_interface/behavior_context.hpp>
#include <moveit_studio_common/test_utils/mock_logger.hpp>
#include <tf2_eigen/tf2_eigen.hpp>
#include <moveit_studio_behavior_interface/action_client_behavior_base.hpp>
#include <moveit_studio_behavior_interface/impl/test_behavior_impl.hpp>
Include dependency graph for test_behavior.hpp:
This graph shows which files directly or indirectly include this file:

Classes

class  moveit_studio::test_utils::WithBehaviorWithoutContext< BehaviorT >
 Adds testing capabilities of Behaviors without context to any test fixture. More...
 
class  moveit_studio::test_utils::WithBehavior< BehaviorT >
 Adds testing capabilities of Behaviors with context to any test fixture. More...
 
class  moveit_studio::test_utils::WithActionBehavior< BehaviorT, ClientInterfaceT >
 
class  moveit_studio::test_utils::WrongBehaviorPortsException
 Exception thrown by Behavior testing classes when the Behavior does not define exactly the expected ports. More...
 

Namespaces

 moveit_studio
 
 moveit_studio::test_utils
 

Macros

#define BEGIN_BEHAVIOR_PORT_SETTER_MAP_WITH_ATTRIBUTES(name, attributes)
 Begins the definition of a port setter map and adds attributes to its generator function. More...
 
#define BEGIN_BEHAVIOR_PORT_SETTER_MAP(name)   BEGIN_BEHAVIOR_PORT_SETTER_MAP_WITH_ATTRIBUTES(name, )
 Begins the definition of a port setter map. More...
 
#define DEFINE_BEHAVIOR_PORT_SETTER(port_id, default_object)
 Defines the port setter for a port ID. More...
 
#define DEFINE_OPTIONAL_BEHAVIOR_PORT_SETTER(port_id, default_object)    { port_id, ::moveit_studio::test_utils::PortSetter() },
 Defines the port setter for an optional port ID. More...
 
#define END_BEHAVIOR_PORT_SETTER_MAP()
 Ends the definition of a port setter map. More...
 

Typedefs

using moveit_studio::test_utils::PortSetter = std::function< void(BT::Blackboard &, const std::string &)>
 A callable that sets a Behavior port in a blackboard. More...
 
using moveit_studio::test_utils::PortSetterMap = std::map< std::string, PortSetter >
 A map associating port names to their setters. More...
 
using moveit_studio::test_utils::PortSetterMapGenerator = const PortSetterMap &(*)(void)
 A function generating a map of port setters. More...
 

Functions

std::set< std::string > moveit_studio::test_utils::getPortIDs (const PortSetterMap &map, bool only_mandatory=false)
 Returns port IDs in a port setter map. More...
 

Macro Definition Documentation

◆ BEGIN_BEHAVIOR_PORT_SETTER_MAP

#define BEGIN_BEHAVIOR_PORT_SETTER_MAP (   name)    BEGIN_BEHAVIOR_PORT_SETTER_MAP_WITH_ATTRIBUTES(name, )

Begins the definition of a port setter map.

Must be followed by a instance of END_BEHAVIOR_PORT_SETTER_MAP; there can be instances of DEFINE_BEHAVIOR_PORT_SETTER between the two.

Parameters
nameName of this port setter map. Must be unique within the file.

◆ BEGIN_BEHAVIOR_PORT_SETTER_MAP_WITH_ATTRIBUTES

#define BEGIN_BEHAVIOR_PORT_SETTER_MAP_WITH_ATTRIBUTES (   name,
  attributes 
)
Value:
namespace \
{ \
{ \
static const auto* port_setter = new ::moveit_studio::test_utils::PortSetterMap \
{
std::map< std::string, PortSetter > PortSetterMap
A map associating port names to their setters.
Definition: test_behavior.hpp:28

Begins the definition of a port setter map and adds attributes to its generator function.

Unless you have a very specific need to add attributes to the function this macro generates, you probably want to use BEGIN_BEHAVIOR_PORT_SETTER_MAP instead. Must be followed by an instance of END_BEHAVIOR_PORT_SETTER_MAP; there can be instances of DEFINE_BEHAVIOR_PORT_SETTER between the two.

Parameters
nameName of this port setter map. Must be unique within the file.
attributesAttributes to prefix the generator function with.

◆ DEFINE_BEHAVIOR_PORT_SETTER

#define DEFINE_BEHAVIOR_PORT_SETTER (   port_id,
  default_object 
)
Value:
{ port_id, ::moveit_studio::test_utils::PortSetter([](BT::Blackboard& blackboard, const std::string& port_name) { \
blackboard.set(port_name, default_object); \
}) },
std::function< void(BT::Blackboard &, const std::string &)> PortSetter
A callable that sets a Behavior port in a blackboard.
Definition: test_behavior.hpp:23

Defines the port setter for a port ID.

Parameters
port_idID of the Behavior port to set.
default_objectValue the port will be set to.

◆ DEFINE_OPTIONAL_BEHAVIOR_PORT_SETTER

#define DEFINE_OPTIONAL_BEHAVIOR_PORT_SETTER (   port_id,
  default_object 
)     { port_id, ::moveit_studio::test_utils::PortSetter() },

Defines the port setter for an optional port ID.

Optional ports are those that can have no value set when the behavior is run, although the behavior still has to create them.

Parameters
port_idID of the Behavior port to set.
default_objectValue the port will be set to.

◆ END_BEHAVIOR_PORT_SETTER_MAP

#define END_BEHAVIOR_PORT_SETTER_MAP ( )
Value:
} \
; \
return *port_setter; \
} \
}

Ends the definition of a port setter map.

Must be preceded by a instance of BEGIN_BEHAVIOR_PORT_SETTER_MAP*; there can be instances of DEFINE_BEHAVIOR_PORT_SETTER between the two.