Skip to main content

GetMessageFromTopicBehaviorBase Class Template

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port. More...

Declaration

template <typename MessageT>
class moveit_pro::behaviors::GetMessageFromTopicBehaviorBase<MessageT> { ... }

Included Headers

#include <get_message_from_topic.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

template <typename MessageT>
GetMessageFromTopicBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)

Constructs GetMessageFromTopicBehaviorBase using the RclcppSubscriberInterface. More...

template <typename MessageT>
GetMessageFromTopicBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< SubscriberInterface< MessageT > > subscriber_interface)

Constructs GetMessageFromTopicBehaviorBase using a user-provided implementation of SubscriberInterface. More...

Public Destructor Index

template <typename MessageT>
~GetMessageFromTopicBehaviorBase () override=default

Public Member Functions Index

template <typename MessageT>
auto getWaitForMessageTimeout () -> tl::expected< std::chrono::duration< double >, std::string >

Optional user-provided function to set the timeout used when waiting for a message to be received on the topic. More...

template <typename MessageT>
auto getWaitForPublisherTimeout () -> tl::expected< std::chrono::duration< double >, std::string >

Optional user-provided function to set the timeout used when waiting for a publisher to advertise a topic. More...

Private Member Functions Index

template <typename MessageT>
auto doWork () override -> tl::expected< bool, std::string >

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

template <typename MessageT>
auto doHalt () override -> tl::expected< void, std::string >

Stops message checking if in progress. More...

Private Member Attributes Index

template <typename MessageT>
std::unique_ptr< SubscriberInterface< MessageT > >subscriber_interface_

Subscriber interface used by the behavior to get the latest message from a topic. More...

Public Static Attributes Index

template <typename MessageT>
static constexpr autokPortIDTopicName = "topic_name"

Port names. More...

template <typename MessageT>
static constexpr autokPortIDMessageOut = "message_out"
template <typename MessageT>
static constexpr autokPortIDTimeoutDuration = "message_timeout_sec"
template <typename MessageT>
static constexpr autokPortIDPublisherTimeoutDuration = "publisher_timeout_sec"

Description

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port.

Template Parameters
MessageT

ROS message type used to specialize this class.

Definition at line 31 of file get_message_from_topic.hpp.

Public Constructors

GetMessageFromTopicBehaviorBase()

template <typename MessageT>
moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::GetMessageFromTopicBehaviorBase (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources)

Constructs GetMessageFromTopicBehaviorBase using the RclcppSubscriberInterface.

Declaration at line 41 of file get_message_from_topic.hpp, definition at line 22 of file get_message_from_topic_impl.hpp.

GetMessageFromTopicBehaviorBase()

template <typename MessageT>
moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::GetMessageFromTopicBehaviorBase (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< SubscriberInterface< MessageT > > subscriber_interface)

Constructs GetMessageFromTopicBehaviorBase using a user-provided implementation of SubscriberInterface.

Declaration at line 45 of file get_message_from_topic.hpp, definition at line 31 of file get_message_from_topic_impl.hpp.

Public Destructor

~GetMessageFromTopicBehaviorBase()

template <typename MessageT>
moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::~GetMessageFromTopicBehaviorBase ()
default

Definition at line 49 of file get_message_from_topic.hpp.

Public Member Functions

getWaitForMessageTimeout()

template <typename MessageT>
virtual tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::getWaitForMessageTimeout ()
inline virtual

Optional user-provided function to set the timeout used when waiting for a message to be received on the topic.

If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the subscriber to wait for the result without timing out.

Returns

Returns the message timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Definition at line 58 of file get_message_from_topic.hpp.

getWaitForPublisherTimeout()

template <typename MessageT>
virtual tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::getWaitForPublisherTimeout ()
inline virtual

Optional user-provided function to set the timeout used when waiting for a publisher to advertise a topic.

If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the subscriber to wait for the result without timing out.

Returns

Returns the message timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Definition at line 70 of file get_message_from_topic.hpp.

Private Member Functions

doHalt()

template <typename MessageT>
tl::expected< void, std::string > moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::doHalt ()
virtual

Stops message checking if in progress.

Returns

Declaration at line 89 of file get_message_from_topic.hpp, definition at line 82 of file get_message_from_topic_impl.hpp.

doWork()

template <typename MessageT>
tl::expected< bool, std::string > moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::doWork ()
virtual

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

Retrieves required values from input data ports, initializes the subscriber, blocks waiting until a message is received (or the timeout duration is reached), and sets the message that was received to the output data port.

Returns

True if all initialization steps succeeded and a message was received. Returns an error result if initialization did not succeed or no message was received before the timeout.

Declaration at line 83 of file get_message_from_topic.hpp, definition at line 40 of file get_message_from_topic_impl.hpp.

Private Member Attributes

subscriber_interface_

template <typename MessageT>
std::unique_ptr<SubscriberInterface<MessageT> > moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::subscriber_interface_

Subscriber interface used by the behavior to get the latest message from a topic.

Definition at line 92 of file get_message_from_topic.hpp.

Public Static Attributes

kPortIDMessageOut

template <typename MessageT>
constexpr auto moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::kPortIDMessageOut = "message_out"
constexpr static

Definition at line 36 of file get_message_from_topic.hpp.

kPortIDPublisherTimeoutDuration

template <typename MessageT>
constexpr auto moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::kPortIDPublisherTimeoutDuration = "publisher_timeout_sec"
constexpr static

Definition at line 38 of file get_message_from_topic.hpp.

kPortIDTimeoutDuration

template <typename MessageT>
constexpr auto moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::kPortIDTimeoutDuration = "message_timeout_sec"
constexpr static

Definition at line 37 of file get_message_from_topic.hpp.

kPortIDTopicName

template <typename MessageT>
constexpr auto moveit_pro::behaviors::GetMessageFromTopicBehaviorBase< MessageT >::kPortIDTopicName = "topic_name"
constexpr static

Port names.

Definition at line 35 of file get_message_from_topic.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.