WaitForUserMapApproval Class
Shows a live preview of an occupancy grid that is being built in the MoveIt Pro Desktop App and waits for the user to approve or reject it. 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
| WaitForUserMapApproval (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
|
Constructor for the WaitForUserMapApproval Behavior. More... | |
Private Member Functions Index
| tl::expected< bool, std::string > | doWork () override |
|
Publish the map preview request and wait for the user's answer. More... | |
| tl::expected< void, std::string > | doHalt () override |
|
Cancel the in-flight request when the Behavior is halted, which closes the preview. 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
Shows a live preview of an occupancy grid that is being built in the MoveIt Pro Desktop App and waits for the user to approve or reject it.
The Desktop App opens a Map Preview pane that draws the latest nav_msgs::msg::OccupancyGrid on map_topic with robot_frame's position on it, and shows the prompt with two buttons. The approve_label button returns SUCCESS. The reject_label button returns FAILURE and logs the answer at INFO level, so a Sequence or Fallback can branch on it without an error in the Alert Sidebar. The Behavior does not save the map itself: run it in a Parallel beside the teleoperation or exploration that builds the map, and save the map after it succeeds. The Behavior logs an error and fails when a port value is invalid, when no Desktop App is connected or it reports an error, or when nobody answers within timeout_sec seconds. Halting the Behavior closes the preview in the Desktop App.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| prompt | input | std::string |
| map_topic | input | std::string |
| robot_frame | input | std::string |
| approve_label | input | std::string |
| reject_label | input | std::string |
| timeout_sec | input | double |
Definition at line 37 of file wait_for_user_map_approval.hpp.
Public Constructors
WaitForUserMapApproval()
| explicit |
Constructor for the WaitForUserMapApproval Behavior.
- Parameters
-
name config shared_resources
Declaration at line 47 of file wait_for_user_map_approval.hpp, definition at line 91 of file wait_for_user_map_approval.cpp.
Private Member Functions
doHalt()
| virtual |
Cancel the in-flight request when the Behavior is halted, which closes the preview.
- Returns
An empty success result.
Declaration at line 74 of file wait_for_user_map_approval.hpp, definition at line 168 of file wait_for_user_map_approval.cpp.
doWork()
| virtual |
Publish the map preview request and wait for the user's answer.
- Returns
true when the user approves, false when the user rejects, or an error message. The tree discards the result of a halted Behavior.
Declaration at line 68 of file wait_for_user_map_approval.hpp, definition at line 125 of file wait_for_user_map_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_map_approval.hpp.
Private Member Attributes
future_
|
Definition at line 81 of file wait_for_user_map_approval.hpp.
request_client_
|
Definition at line 82 of file wait_for_user_map_approval.hpp.
Public Static Functions
metadata()
| static |
Returns metadata for this Behavior.
- Returns
BT::KeyValueVector The Behavior metadata.
Declaration at line 60 of file wait_for_user_map_approval.hpp, definition at line 118 of file wait_for_user_map_approval.cpp.
providedPorts()
| static |
Returns list of ports for this Behavior.
- Returns
BT::PortsList The list of I/O Ports.
Declaration at line 54 of file wait_for_user_map_approval.hpp, definition at line 99 of file wait_for_user_map_approval.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.15.0.