Skip to main content

BreakpointSubscriber Class

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...

Declaration​

class moveit_pro::behaviors::BreakpointSubscriber { ... }

Included Headers​

#include <breakpoint_subscriber.hpp>

Base class​

classAsyncBehaviorBase

A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More...

Public Constructors Index​

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< SubscriberInterface< std_msgs::msg::Bool > > shared_subscriber_interface, std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > > encountered_publisher_interface, std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > > resumed_publisher_interface)

Constructor with injected interfaces for testing. More...

Public Destructor Index​

~BreakpointSubscriber () override

Waits for an announcement already dispatched by the executor before members are gone. More...

Private Member Functions Index​

tl::expected< bool, std::string >doWork () override

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

tl::expected< void, std::string >doHalt () override

Stops message checking if in progress. More...

ResolvedTopicresolveBreakpointTopic (std::string_view configured_topic) const

Resolves the breakpoint_topic port into the topic to wait on. More...

tl::expected< std_msgs::msg::Bool, std::string >waitForResume (bool include_shared_topic)

Blocks until this breakpoint is resumed, or until the Behavior is halted. More...

voidstopEncounteredTimer ()

Stops the announcement and releases its timer, if one is running. More...

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. More...

Private Member Attributes Index​

std::shared_future< tl::expected< bool, std::string > >future_

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. More...

std::unique_ptr< SubscriberInterface< std_msgs::msg::Bool > >subscriber_interface_

Subscriber interface used to get messages from the breakpoint topic. More...

std::unique_ptr< SubscriberInterface< std_msgs::msg::Bool > >shared_subscriber_interface_

Subscriber interface for the shared /moveit_pro_breakpoint topic, used only while breakpoint_topic is left at its default. Unused when the author names a topic. More...

std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > >breakpoint_encountered_publisher_interface_

Publisher interface for broadcasting that a breakpoint has been encountered on a particular subscriber topic. More...

std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > >breakpoint_resumed_publisher_interface_

Publisher interface for broadcasting that a breakpoint has been resumed on a particular subscriber topic. More...

rclcpp::TimerBase::SharedPtrbreakpoint_timer_

Wall timer that periodically publishes the breakpoint encountered message while waiting. More...

std::mutexbreakpoint_timer_mutex_

Serializes access to breakpoint_timer_ between doWork()'s thread and doHalt()'s. More...

std::shared_ptr< AnnounceState >announce_ = std::make_shared<AnnounceState>()
std::optional< std::string >breakpoint_topic_

The breakpoint topic name read from the port during doWork(). More...

Public Static Functions Index​

static BT::PortsListprovidedPorts ()
static BT::KeyValueVectormetadata ()

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 NamePort TypeObject Type
breakpoint_topicInputstd::string
messageInputstd::string

The optional message port lets the objective author surface a human-readable hint describing why this breakpoint exists. It is published on /breakpoint_encountered alongside the topic name so the UI can display it under the breakpoint prompt.

Left empty, breakpoint_topic resolves to a channel of this breakpoint's own, derived from its position in the tree and its uid, so breakpoints paused at the same time are resumed one at a time rather than all together. That breakpoint also keeps listening on /moveit_pro_breakpoint, which resumes every breakpoint waiting on it. Naming a topic opts out of both, including naming /moveit_pro_breakpoint itself: the breakpoint then listens only there.

info

IMPORTANT: The breakpoint subscriber has QoS settings of reliable so the publisher to continue or abort is required to match those settings.

info

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}" The topic a breakpoint is actually waiting on is logged when it pauses.

Definition at line 58 of file breakpoint_subscriber.hpp.

Public Constructors​

BreakpointSubscriber()​

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

Declaration at line 61 of file breakpoint_subscriber.hpp, definition at line 150 of file breakpoint_subscriber.cpp.

BreakpointSubscriber()​

moveit_pro::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< SubscriberInterface< std_msgs::msg::Bool > > shared_subscriber_interface, std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > > encountered_publisher_interface, std::unique_ptr< PublisherInterfaceBase< moveit_studio_agent_msgs::msg::BreakpointStatus > > resumed_publisher_interface)

Constructor with injected interfaces for testing.

Parameters
name

Name of this Behavior's node in the Behavior Tree.

config

Node configuration, whose path and uid name the derived topic.

shared_resources

Behavior context providing the ROS node and logger.

subscriber_interface

Subscriber for the topic this breakpoint waits on.

shared_subscriber_interface

Subscriber for the shared topic, used only when the breakpoint_topic port is left empty.

encountered_publisher_interface

Publisher announcing that this breakpoint is paused.

resumed_publisher_interface

Publisher announcing that this breakpoint is no longer paused.

Declaration at line 80 of file breakpoint_subscriber.hpp, definition at line 162 of file breakpoint_subscriber.cpp.

Public Destructor​

~BreakpointSubscriber()​

moveit_pro::behaviors::BreakpointSubscriber::~BreakpointSubscriber ()

Waits for an announcement already dispatched by the executor before members are gone.

Declaration at line 67 of file breakpoint_subscriber.hpp, definition at line 410 of file breakpoint_subscriber.cpp.

Private Member Functions​

doHalt()​

tl::expected< void, std::string > moveit_pro::behaviors::BreakpointSubscriber::doHalt ()
virtual

Stops message checking if in progress.

Halts the subscriber interface to interrupt waiting for messages.

Declaration at line 107 of file breakpoint_subscriber.hpp, definition at line 445 of file breakpoint_subscriber.cpp.

doWork()​

tl::expected< bool, std::string > moveit_pro::behaviors::BreakpointSubscriber::doWork ()
virtual

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.

Declaration at line 101 of file breakpoint_subscriber.hpp, definition at line 220 of file breakpoint_subscriber.cpp.

getFuture()​

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::BreakpointSubscriber::getFuture ()
inline virtual

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

Definition at line 140 of file breakpoint_subscriber.hpp.

resolveBreakpointTopic()​

BreakpointSubscriber::ResolvedTopic moveit_pro::behaviors::BreakpointSubscriber::resolveBreakpointTopic (std::string_view configured_topic)

Resolves the breakpoint_topic port into the topic to wait on.

An empty port derives a topic of this breakpoint's own, falling back to the shared topic with a warning when the tree path cannot name a valid one. A named topic is used verbatim.

Declaration at line 123 of file breakpoint_subscriber.hpp, definition at line 196 of file breakpoint_subscriber.cpp.

stopEncounteredTimer()​

void moveit_pro::behaviors::BreakpointSubscriber::stopEncounteredTimer ()

Stops the announcement and releases its timer, if one is running.

Declaration at line 135 of file breakpoint_subscriber.hpp, definition at line 394 of file breakpoint_subscriber.cpp.

waitForResume()​

tl::expected< std_msgs::msg::Bool, std::string > moveit_pro::behaviors::BreakpointSubscriber::waitForResume (bool include_shared_topic)

Blocks until this breakpoint is resumed, or until the Behavior is halted.

Parameters
include_shared_topic

Whether the shared topic's subscriber is also being listened to.

Returns

The resume message, or an error result if the wait ended without one.

Declaration at line 130 of file breakpoint_subscriber.hpp, definition at line 418 of file breakpoint_subscriber.cpp.

Private Member Attributes​

announce_​

std::shared_ptr<AnnounceState> moveit_pro::behaviors::BreakpointSubscriber::announce_ = std::make_shared<AnnounceState>()

Definition at line 206 of file breakpoint_subscriber.hpp.

breakpoint_encountered_publisher_interface_​

std::unique_ptr<PublisherInterfaceBase<moveit_studio_agent_msgs::msg::BreakpointStatus> > moveit_pro::behaviors::BreakpointSubscriber::breakpoint_encountered_publisher_interface_

Publisher interface for broadcasting that a breakpoint has been encountered on a particular subscriber topic.

Definition at line 165 of file breakpoint_subscriber.hpp.

breakpoint_resumed_publisher_interface_​

std::unique_ptr<PublisherInterfaceBase<moveit_studio_agent_msgs::msg::BreakpointStatus> > moveit_pro::behaviors::BreakpointSubscriber::breakpoint_resumed_publisher_interface_

Publisher interface for broadcasting that a breakpoint has been resumed on a particular subscriber topic.

Definition at line 171 of file breakpoint_subscriber.hpp.

breakpoint_timer_​

rclcpp::TimerBase::SharedPtr moveit_pro::behaviors::BreakpointSubscriber::breakpoint_timer_

Wall timer that periodically publishes the breakpoint encountered message while waiting.

Guarded by breakpoint_timer_mutex_: a resume arriving as the node is halted has the async thread and the tick thread tearing this down at the same moment.

Definition at line 178 of file breakpoint_subscriber.hpp.

breakpoint_timer_mutex_​

std::mutex moveit_pro::behaviors::BreakpointSubscriber::breakpoint_timer_mutex_

Serializes access to breakpoint_timer_ between doWork()'s thread and doHalt()'s.

Definition at line 183 of file breakpoint_subscriber.hpp.

breakpoint_topic_​

std::optional<std::string> moveit_pro::behaviors::BreakpointSubscriber::breakpoint_topic_

The breakpoint topic name read from the port during doWork().

Definition at line 211 of file breakpoint_subscriber.hpp.

future_​

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::BreakpointSubscriber::future_

Classes derived from AsyncBehaviorBase must have this shared_future as a class member.

Definition at line 148 of file breakpoint_subscriber.hpp.

shared_subscriber_interface_​

std::unique_ptr<SubscriberInterface<std_msgs::msg::Bool> > moveit_pro::behaviors::BreakpointSubscriber::shared_subscriber_interface_

Subscriber interface for the shared /moveit_pro_breakpoint topic, used only while breakpoint_topic is left at its default. Unused when the author names a topic.

Definition at line 159 of file breakpoint_subscriber.hpp.

subscriber_interface_​

std::unique_ptr<SubscriberInterface<std_msgs::msg::Bool> > moveit_pro::behaviors::BreakpointSubscriber::subscriber_interface_

Subscriber interface used to get messages from the breakpoint topic.

Definition at line 153 of file breakpoint_subscriber.hpp.

Public Static Functions​

metadata()​

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

Declaration at line 91 of file breakpoint_subscriber.hpp, definition at line 190 of file breakpoint_subscriber.cpp.

providedPorts()​

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

Declaration at line 89 of file breakpoint_subscriber.hpp, definition at line 178 of file breakpoint_subscriber.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.