Skip to main content

GetRegionFromUser Class

Requests a 2D region (bounding box or polygon) from the user by switching the view and displaying a prompt in the UI. More...

Declaration​

class moveit_pro::behaviors::GetRegionFromUser { ... }

Included Headers​

#include <get_region_from_user.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​

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

Construct a new GetRegionFromUser object. More...

Private Member Functions Index​

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

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

tl::expected< bool, std::string >processResponse (const RequestRegionFromUser::Request &request, const RequestRegionFromUser::Response &response)

Validate the returned region against the request and, on success, write it to the output port. 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

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

Private Member Attributes Index​

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

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. More...

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​

Requests a 2D region (bounding box or polygon) from the user by switching the view and displaying a prompt in the UI.

The user draws either a rectangular bounding box or a polygon on the named camera view. The output is a geometry_msgs/PolygonStamped whose points are normalized image coordinates in [0..1] (z unused). A bounding box returns four axis-aligned corners; a polygon returns the convex hull of the user's clicks. The returned region is validated on the backend, not trusted from the UI. Polygon selection is validated by the backend but is not yet available in the UI.

When initial_region is wired, it is validated and canonicalized like a returned region and sent as a proposal the user can move, resize, or replace; a wired but unreadable or invalid proposal fails the Behavior before the user is prompted.

Data Port NamePort TypeObject Type
view_nameInputstd::string
region_nameInputstd::string
promptInputstd::string
shape_modeInputstd::string
min_verticesInputint
max_verticesInputint
initial_regionInputgeometry_msgs::msg::PolygonStamped
regionOutputgeometry_msgs::msg::PolygonStamped

Definition at line 42 of file get_region_from_user.hpp.

Public Constructors​

GetRegionFromUser()​

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

Construct a new GetRegionFromUser object.

Parameters
name

See SharedResourcesNode

config

See SharedResourcesNode

shared_resources

See SharedResourcesNode

Declaration at line 51 of file get_region_from_user.hpp, definition at line 161 of file get_region_from_user.cpp.

Private Member Functions​

createRequest()​

tl::expected< RequestRegionFromUser::Request, std::string > moveit_pro::behaviors::GetRegionFromUser::createRequest ()
nodiscard

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

Returns

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

Declaration at line 71 of file get_region_from_user.hpp, definition at line 199 of file get_region_from_user.cpp.

doHalt()​

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

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

Returns

An empty success result.

Declaration at line 90 of file get_region_from_user.hpp, definition at line 350 of file get_region_from_user.cpp.

doWork()​

tl::expected< bool, std::string > moveit_pro::behaviors::GetRegionFromUser::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 84 of file get_region_from_user.hpp, definition at line 322 of file get_region_from_user.cpp.

getFuture()​

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

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

Definition at line 93 of file get_region_from_user.hpp.

processResponse()​

tl::expected< bool, std::string > moveit_pro::behaviors::GetRegionFromUser::processResponse (const RequestRegionFromUser::Request & request, const RequestRegionFromUser::Response & response)
nodiscard

Validate the returned region against the request and, on success, write it to the output port.

Returns

If the response succeeded and the region is valid, returns true; otherwise an error message.

Declaration at line 77 of file get_region_from_user.hpp, definition at line 297 of file get_region_from_user.cpp.

Private Member Attributes​

future_​

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

Classes derived from AsyncBehaviorBase must have this shared_future as a class member.

Definition at line 99 of file get_region_from_user.hpp.

request_client_​

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

Definition at line 100 of file get_region_from_user.hpp.

Public Static Functions​

metadata()​

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

Returns metadata for this Behavior.

Returns

BT::KeyValueVector The Behavior metadata.

Declaration at line 64 of file get_region_from_user.hpp, definition at line 194 of file get_region_from_user.cpp.

providedPorts()​

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

Returns list of ports for this Behavior.

Returns

BT::PortsList The list of I/O Ports

Declaration at line 58 of file get_region_from_user.hpp, definition at line 169 of file get_region_from_user.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.15.0.