Skip to main content

WithBehavior Class Template

Adds testing capabilities of Behaviors with context to any test fixture. More...

Declaration

template <class BehaviorT>
class moveit_pro::test_utils::WithBehavior<BehaviorT> { ... }

Included Headers

#include <test_behavior.hpp>

Derived Classes

classWithActionBehavior<BehaviorT, ClientInterfaceT>

Public Member Functions Index

template <class BehaviorT>
voidinitBehavior (const std::string &name, PortSetterMapGenerator input_port_setter_generator, PortSetterMapGenerator output_port_setter_generator)

Initializes the Behavior under test. More...

template <class BehaviorT>
BehaviorT &behavior ()
template <class BehaviorT>
BT::NodeConfiguration &config ()
template <class BehaviorT>
BT::Blackboard &blackboard ()
template <class BehaviorT>
MockLogger &mockLogger ()
template <class BehaviorT>
behaviors::BehaviorContext &behaviorContext ()
template <class BehaviorT>
auto behaviorContextSharedPtr () -> std::shared_ptr< behaviors::BehaviorContext >
template <class BehaviorT>
rclcpp::Node &behaviorNode ()
template <class BehaviorT>
auto behaviorNodePtr () -> std::shared_ptr< rclcpp::Node >
template <class BehaviorT>
voidsetTestDataDirectories (const std::vector< std::string > &objective_library_directories)

Configure the directories that a test will read data from and/or write data to. More...

template <class BehaviorT>
voidsetTransform (const geometry_msgs::msg::TransformStamped &transform_msg)

Makes a transform available in the shared transform buffer. More...

template <class BehaviorT>
voidsetTransform (const builtin_interfaces::msg::Time &stamp, std::string_view parent_frame, std::string_view child_frame, const Eigen::Isometry3d &transform)

Makes a transform available in the shared transform buffer. More...

template <class BehaviorT>
voidinitBehaviorCommon (const std::string &name, PortSetterMapGenerator input_port_setter_generator, PortSetterMapGenerator output_port_setter_generator)
template <class BehaviorT>
auto behaviorPtr () -> std::unique_ptr< BehaviorT > &

Private Member Functions Index

template <class BehaviorT>
voidinitBehaviorCommon (const std::string &name, PortSetterMapGenerator const input_port_setter_generator, PortSetterMapGenerator const output_port_setter_generator, bool tf2_spin_thread, bool load_robot_model)

Private Member Attributes Index

template <class BehaviorT>
std::unique_ptr< BehaviorT >behavior_
template <class BehaviorT>
BT::NodeConfigurationconfig_
template <class BehaviorT>
std::shared_ptr< behaviors::BehaviorContext >shared_resources_
template <class BehaviorT>
std::shared_ptr< rclcpp::Node >node_
template <class BehaviorT>
MockLogger *mock_logger_ptr_

Description

Adds testing capabilities of Behaviors with context to any test fixture.

To test a Behavior with context (shared resources), a test fixture inherits from this class in addition to any base test fixture, e.g. ::testing::Test, ::moveit_pro::test_utils::RostTest, etc. The fixture automatically tests that the Behavior creates all and only the expected ports.

Template Parameters
BehaviorT

The class of the Behavior under test.

Definition at line 94 of file test_behavior.hpp.

Public Member Functions

behavior()

template <class BehaviorT>
BehaviorT & moveit_pro::test_utils::WithBehavior< BehaviorT >::behavior ()
inline

Definition at line 108 of file test_behavior.hpp.

behaviorContext()

template <class BehaviorT>
behaviors::BehaviorContext & moveit_pro::test_utils::WithBehavior< BehaviorT >::behaviorContext ()
inline

Definition at line 124 of file test_behavior.hpp.

behaviorContextSharedPtr()

template <class BehaviorT>
std::shared_ptr< behaviors::BehaviorContext > moveit_pro::test_utils::WithBehavior< BehaviorT >::behaviorContextSharedPtr ()
inline

Definition at line 128 of file test_behavior.hpp.

behaviorNode()

template <class BehaviorT>
rclcpp::Node & moveit_pro::test_utils::WithBehavior< BehaviorT >::behaviorNode ()
inline

Definition at line 132 of file test_behavior.hpp.

behaviorNodePtr()

template <class BehaviorT>
std::shared_ptr< rclcpp::Node > moveit_pro::test_utils::WithBehavior< BehaviorT >::behaviorNodePtr ()
inline

Definition at line 136 of file test_behavior.hpp.

behaviorPtr()

template <class BehaviorT>
std::unique_ptr< BehaviorT > & moveit_pro::test_utils::WithBehavior< BehaviorT >::behaviorPtr ()
inline

Definition at line 167 of file test_behavior.hpp.

blackboard()

template <class BehaviorT>
BT::Blackboard & moveit_pro::test_utils::WithBehavior< BehaviorT >::blackboard ()
inline

Definition at line 116 of file test_behavior.hpp.

config()

template <class BehaviorT>
BT::NodeConfiguration & moveit_pro::test_utils::WithBehavior< BehaviorT >::config ()
inline

Definition at line 112 of file test_behavior.hpp.

initBehavior()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::initBehavior (const std::string & name, PortSetterMapGenerator input_port_setter_generator, PortSetterMapGenerator output_port_setter_generator)

Initializes the Behavior under test.

Call this function in your fixture's constructor, SetUp() or any of its setUp* variations.

Parameters
name

The name of the Behavior.

input_port_setter_generator

A port setter map generator defining the expected input ports.

output_port_setter_generator

A port setter map generator defining the expected output ports.

Exceptions
<a href="/api/classes/moveit-pro/test-utils/wrongbehaviorportsexception">WrongBehaviorPortsException</a>

if the Behavior does not define exactly the expected ports.

Declaration at line 105 of file test_behavior.hpp, definition at line 158 of file test_behavior_impl.hpp.

initBehaviorCommon()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::initBehaviorCommon (const std::string & name, PortSetterMapGenerator input_port_setter_generator, PortSetterMapGenerator output_port_setter_generator)

Declaration at line 165 of file test_behavior.hpp, definition at line 141 of file test_behavior_impl.hpp.

mockLogger()

template <class BehaviorT>
MockLogger & moveit_pro::test_utils::WithBehavior< BehaviorT >::mockLogger ()
inline

Definition at line 120 of file test_behavior.hpp.

setTestDataDirectories()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::setTestDataDirectories (const std::vector< std::string > & objective_library_directories)

Configure the directories that a test will read data from and/or write data to.

Parameters
objective_library_directories

Directories where the test should search for data and/or write data to.

Declaration at line 145 of file test_behavior.hpp, definition at line 178 of file test_behavior_impl.hpp.

setTransform()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::setTransform (const geometry_msgs::msg::TransformStamped & transform_msg)

Makes a transform available in the shared transform buffer.

The Behavior will have access to the transform, as well as other Behaviors sharing the buffer.

Parameters
transform_msg

The stamped transform message.

Declaration at line 152 of file test_behavior.hpp, definition at line 184 of file test_behavior_impl.hpp.

setTransform()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::setTransform (const builtin_interfaces::msg::Time & stamp, std::string_view parent_frame, std::string_view child_frame, const Eigen::Isometry3d & transform)

Makes a transform available in the shared transform buffer.

The Behavior will have access to the transform, as well as other Behaviors sharing the buffer.

Parameters
stamp

Timestamp of the transform.

parent_frame

Frame from which the transform is expressed.

child_frame

Child frame described by the transform with respect to the parent frame.

transform

Transform from the parent frame to the child frame.

Declaration at line 162 of file test_behavior.hpp, definition at line 190 of file test_behavior_impl.hpp.

Private Member Functions

initBehaviorCommon()

template <class BehaviorT>
void moveit_pro::test_utils::WithBehavior< BehaviorT >::initBehaviorCommon (const std::string & name, PortSetterMapGenerator const input_port_setter_generator, PortSetterMapGenerator const output_port_setter_generator, bool tf2_spin_thread, bool load_robot_model)

Definition at line 178 of file test_behavior.hpp.

Private Member Attributes

behavior_

template <class BehaviorT>
std::unique_ptr<BehaviorT> moveit_pro::test_utils::WithBehavior< BehaviorT >::behavior_

Definition at line 173 of file test_behavior.hpp.

config_

template <class BehaviorT>
BT::NodeConfiguration moveit_pro::test_utils::WithBehavior< BehaviorT >::config_

Definition at line 174 of file test_behavior.hpp.

mock_logger_ptr_

template <class BehaviorT>
MockLogger* moveit_pro::test_utils::WithBehavior< BehaviorT >::mock_logger_ptr_

Definition at line 177 of file test_behavior.hpp.

node_

template <class BehaviorT>
std::shared_ptr<rclcpp::Node> moveit_pro::test_utils::WithBehavior< BehaviorT >::node_

Definition at line 176 of file test_behavior.hpp.

shared_resources_

template <class BehaviorT>
std::shared_ptr<behaviors::BehaviorContext> moveit_pro::test_utils::WithBehavior< BehaviorT >::shared_resources_

Definition at line 175 of file test_behavior.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.