WaitForUserPathApproval Class
Sends a prompt request to the UI to accept or reject a visualized nav_msgs::msg::Path. More...
Declaration
Included Headers
Base class
| class | AsyncBehaviorBase |
|
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... | |
| bool | processResponse (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::PortsList | providedPorts () |
|
Returns list of ports for this Behavior. More... | |
| static BT::KeyValueVector | metadata () |
|
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 Name | Port Type | Object Type |
|---|---|---|
| path | Input | nav_msgs::msg::Path |
Definition at line 27 of file wait_for_user_path_approval.hpp.
Public Constructors
WaitForUserPathApproval()
| explicit |
Constructor for the WaitForUserPathApproval behavior.
- Parameters
-
name config shared_resources
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()
|
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()
| 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()
| 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()
| 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()
|
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_
|
Definition at line 81 of file wait_for_user_path_approval.hpp.
request_client_
|
Definition at line 82 of file wait_for_user_path_approval.hpp.
Public Static Functions
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()
| 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.