Skip to main content

WaitForUserPathApproval Class

Sends a prompt request to the UI to accept or reject a visualized nav_msgs::msg::Path. More...

Declaration

class moveit_pro::behaviors::WaitForUserPathApproval { ... }

Included Headers

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

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

Constructor for the WaitForUserPathApproval behavior. More...

Private Member Functions Index

tl::expected< WaitForUserPathApprovalSrv::Request, std::string >createRequest () const

Compose a WaitForUserPathApprovalSrv::Request message from the input port values specified. More...

boolprocessResponse (const WaitForUserPathApprovalSrv::Response &response) const

Returns whether the user approved the visualized path. More...

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

Publish the UI prompt request and wait for the correlated response. More...

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

Cancel the in-flight UI prompt request when the Behavior is halted. 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_
std::shared_ptr< utils::UIRequestResponseClient >request_client_

Public Static Functions Index

static BT::PortsListprovidedPorts ()

Returns list of ports for this Behavior. More...

static BT::KeyValueVectormetadata ()

Returns metadata for this Behavior. More...

Description

Sends a prompt request to the UI to accept or reject a visualized nav_msgs::msg::Path.

Data Port NamePort TypeObject Type
pathInputnav_msgs::msg::Path

Definition at line 27 of file wait_for_user_path_approval.hpp.

Public Constructors

WaitForUserPathApproval()

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

Constructor for the WaitForUserPathApproval behavior.

Parameters
name

See SharedResourcesNode

config

See SharedResourcesNode

shared_resources

See SharedResourcesNode

Declaration at line 37 of file wait_for_user_path_approval.hpp, definition at line 47 of file wait_for_user_path_approval.cpp.

Private Member Functions

createRequest()

tl::expected< WaitForUserPathApprovalSrv::Request, std::string > moveit_pro::behaviors::WaitForUserPathApproval::createRequest ()

Compose a WaitForUserPathApprovalSrv::Request message from the input port values specified.

Returns

Returns the request message if successful. If not successful, returns an error message.

Declaration at line 57 of file wait_for_user_path_approval.hpp, definition at line 65 of file wait_for_user_path_approval.cpp.

doHalt()

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

Cancel the in-flight UI prompt request when the Behavior is halted.

Returns

An empty success result.

Declaration at line 74 of file wait_for_user_path_approval.hpp, definition at line 101 of file wait_for_user_path_approval.cpp.

doWork()

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

Publish the UI prompt request and wait for the correlated response.

Returns

If the prompt flow succeeded, returns true. If it failed, returns an error message.

Declaration at line 68 of file wait_for_user_path_approval.hpp, definition at line 87 of file wait_for_user_path_approval.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::WaitForUserPathApproval::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 76 of file wait_for_user_path_approval.hpp.

processResponse()

bool moveit_pro::behaviors::WaitForUserPathApproval::processResponse (const WaitForUserPathApprovalSrv::Response & response)

Returns whether the user approved the visualized path.

Declaration at line 62 of file wait_for_user_path_approval.hpp, definition at line 82 of file wait_for_user_path_approval.cpp.

Private Member Attributes

future_

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

Definition at line 81 of file wait_for_user_path_approval.hpp.

request_client_

std::shared_ptr<utils::UIRequestResponseClient> moveit_pro::behaviors::WaitForUserPathApproval::request_client_

Definition at line 82 of file wait_for_user_path_approval.hpp.

Public Static Functions

metadata()

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

Returns metadata for this Behavior.

Returns

BT::KeyValueVector The Behavior metadata.

Declaration at line 50 of file wait_for_user_path_approval.hpp, definition at line 60 of file wait_for_user_path_approval.cpp.

providedPorts()

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

Returns list of ports for this Behavior.

Returns

BT::PortsList The list of I/O Ports.

Declaration at line 44 of file wait_for_user_path_approval.hpp, definition at line 55 of file wait_for_user_path_approval.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.