MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_studio::behaviors::BreakpointSubscriber Class Referencefinal

A behavior that subscribes to a topic that can be used for pausing an objective during execution to allow introspection. This behavior will listen on the configured topic for a True/False message which will cause it to continue or abort from a breakpoint that is included in an objective. More...

#include <breakpoint_subscriber.hpp>

Inheritance diagram for moveit_studio::behaviors::BreakpointSubscriber:
Collaboration diagram for moveit_studio::behaviors::BreakpointSubscriber:

Public Member Functions

 BreakpointSubscriber (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
 BreakpointSubscriber (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< SubscriberInterface< std_msgs::msg::Bool > > subscriber_interface, std::unique_ptr< PublisherInterfaceBase< std_msgs::msg::String > > encountered_publisher_interface, std::unique_ptr< PublisherInterfaceBase< std_msgs::msg::String > > resumed_publisher_interface)
 Constructor with injected interfaces for testing.
 
- Public Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
 AsyncBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
virtual ~AsyncBehaviorBase ()=default
 
BT::NodeStatus onStart () override
 Required implementation of BT::StatefulActionNode::onStart().
 
BT::NodeStatus onRunning () override
 Required implementation of BT::StatefulActionNode::onRunning().
 
void onHalted () override
 Required implementation of BT::StatefulActionNode::onHalted().
 
void resetStatus ()
 Resets the internal status of this node.
 
- Public Member Functions inherited from moveit_studio::behaviors::SharedResourcesNode< BT::StatefulActionNode >
 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 ()
 
static BT::KeyValueVector metadata ()
 

Protected Member Functions

tl::expected< bool, std::string > doWork () override
 Function called in the async process thread after the behavior starts running.
 
tl::expected< void, std::string > doHalt () override
 Stops message checking if in progress.
 
std::shared_future< tl::expected< bool, std::string > > & getFuture () override
 Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.
 
- Protected Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
void notifyCanHalt ()
 Called when runAsync() finishes to notify onHalted() that the async process has finished.
 

Additional Inherited Members

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

Detailed Description

A behavior that subscribes to a topic that can be used for pausing an objective during execution to allow introspection. This behavior will listen on the configured topic for a True/False message which will cause it to continue or abort from a breakpoint that is included in an objective.

Data Port Name Port Type Object Type
breakpoint_topic Input std::string
Note
IMPORTANT: The breakpoint subscriber has QoS settings of reliable so the publisher to continue or abort is required to match those settings.
EXAMPLE: To continue from a breakpoint on the topic /breakpoint_topic_name the user can enter the following in a terminal to continue. If the value of data is False then the objective will be aborted. ros2 topic pub -1 /breakpoint_topic_name std_msgs/msg/Bool "{data: True}"

Constructor & Destructor Documentation

◆ BreakpointSubscriber() [1/2]

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

◆ BreakpointSubscriber() [2/2]

moveit_studio::behaviors::BreakpointSubscriber::BreakpointSubscriber ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< BehaviorContext > &  shared_resources,
std::unique_ptr< SubscriberInterface< std_msgs::msg::Bool > >  subscriber_interface,
std::unique_ptr< PublisherInterfaceBase< std_msgs::msg::String > >  encountered_publisher_interface,
std::unique_ptr< PublisherInterfaceBase< std_msgs::msg::String > >  resumed_publisher_interface 
)

Constructor with injected interfaces for testing.

Member Function Documentation

◆ doHalt()

tl::expected< void, std::string > moveit_studio::behaviors::BreakpointSubscriber::doHalt ( )
overrideprotectedvirtual

Stops message checking if in progress.

Halts the subscriber interface to interrupt waiting for messages.

Reimplemented from moveit_studio::behaviors::AsyncBehaviorBase.

◆ doWork()

tl::expected< bool, std::string > moveit_studio::behaviors::BreakpointSubscriber::doWork ( )
overrideprotectedvirtual

Function called in the async process thread after the behavior starts running.

Initializes the subscriber, waits for a message on the breakpoint topic, and publishes notifications about breakpoint status.

Returns
True if the breakpoint should continue, False if it should abort. Returns an error result if initialization failed or message reception failed.

Implements moveit_studio::behaviors::AsyncBehaviorBase.

◆ getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_studio::behaviors::BreakpointSubscriber::getFuture ( )
inlineoverrideprotectedvirtual

Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.

Implements moveit_studio::behaviors::AsyncBehaviorBase.

◆ metadata()

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

◆ providedPorts()

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

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