Skip to main content

GetLaserScan Class

Waits for the next laser scan on a topic. More...

Declaration​

class moveit_pro::behaviors::GetLaserScan { ... }

Included Headers​

#include <get_laser_scan.hpp>

Base class​

classGetMessageFromTopicBehaviorBase<MessageT>

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

Public Constructors Index​

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

Private Member Functions Index​

tl::expected< std::chrono::duration< double >, std::string >getWaitForMessageTimeout () override

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

tl::expected< std::chrono::duration< double >, std::string >getWaitForPublisherTimeout () override

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

std::shared_future< tl::expected< bool, std::string > > &getFuture () override

Gets the shared future which is used to monitor the progress of the async process. More...

Private Member Attributes Index​

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

Public Static Functions Index​

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

Description​

Waits for the next laser scan on a topic.

Data Port NamePort TypeObject Type
topic_nameinputstd::string
message_timeout_secinputdouble
publisher_timeout_secinputdouble
message_outoutputsensor_msgs::msg::LaserScan

Definition at line 25 of file get_laser_scan.hpp.

Public Constructors​

GetLaserScan()​

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

Declaration at line 28 of file get_laser_scan.hpp, definition at line 21 of file get_laser_scan.cpp.

Private Member Functions​

getFuture()​

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

Gets the shared future which is used to monitor the progress of the async process.

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

This exists to prevent destruction of the derived class while the async process is still in-progress. If the derived class is destroyed, the definitions of the functions used within doWork() will be destroyed too, which will result in the virtual functions in the base class being called instead and cause a fault.

This function will force derived classes to add an instance of this type and return a reference to it. The base class can then use this virtual function to access the shared future in functions like onStart.

By adding this virtual function we're properly demonstrating how this future depends on things from the derived class and the natural flow of object lifetimes will do the hard work for us. The std::shared_future destructor will get the value of the future before the derived class is destructed assuming it's the last reference to the shared state. Doing it this way means neither the base nor derived class should need to implement a destructor which is a nice property to have.

Returns

Returns the shared_future, which should be owned by the child class.

Definition at line 40 of file get_laser_scan.hpp.

getWaitForMessageTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::GetLaserScan::getWaitForMessageTimeout ()
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.

Declaration at line 36 of file get_laser_scan.hpp, definition at line 27 of file get_laser_scan.cpp.

getWaitForPublisherTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::GetLaserScan::getWaitForPublisherTimeout ()
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.

Declaration at line 38 of file get_laser_scan.hpp, definition at line 37 of file get_laser_scan.cpp.

Private Member Attributes​

future_​

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

Definition at line 45 of file get_laser_scan.hpp.

Public Static Functions​

metadata()​

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

Declaration at line 33 of file get_laser_scan.hpp, definition at line 59 of file get_laser_scan.cpp.

providedPorts()​

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

Declaration at line 31 of file get_laser_scan.hpp, definition at line 47 of file get_laser_scan.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.