Skip to main content

GetPoseFromUser Class

Sends a prompt request to the UI so that the user can click in the UI and return a pose. More...

Declaration

class moveit_pro::behaviors::GetPoseFromUser { ... }

Included Headers

#include <get_pose_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

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

Constructor for the GetPoseFromUser behavior. More...

Private Member Functions Index

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

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

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

Evaluate the UI response message to determine if the prompt succeeded or failed. 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 so that the user can click in the UI and return a pose.

Data Port NamePort TypeObject Type
view_nameInputstd::string
pose_promptInputstd::string
is_normalInputbool
user_poseOutputgeometry_msgs::msg::PoseStamped

Definition at line 32 of file get_pose_from_user.hpp.

Public Constructors

GetPoseFromUser()

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

Constructor for the GetPoseFromUser behavior.

Parameters
name

See SharedResourcesNode

config

See SharedResourcesNode

shared_resources

See SharedResourcesNode

Declaration at line 42 of file get_pose_from_user.hpp, definition at line 62 of file get_pose_from_user.cpp.

Private Member Functions

createRequest()

tl::expected< GetPoseFromUserSrv::Request, std::string > moveit_pro::behaviors::GetPoseFromUser::createRequest ()

Compose a GetPoseFromUserSrv::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 62 of file get_pose_from_user.hpp, definition at line 107 of file get_pose_from_user.cpp.

doHalt()

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

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

Returns

An empty success result.

Declaration at line 81 of file get_pose_from_user.hpp, definition at line 155 of file get_pose_from_user.cpp.

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::GetPoseFromUser::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 75 of file get_pose_from_user.hpp, definition at line 134 of file get_pose_from_user.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::GetPoseFromUser::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 83 of file get_pose_from_user.hpp.

processResponse()

tl::expected< bool, std::string > moveit_pro::behaviors::GetPoseFromUser::processResponse (const GetPoseFromUserSrv::Response & response)

Evaluate the UI response message to determine if the prompt succeeded or failed.

Parameters
response

The response returned from the UI prompt flow.

Returns

If the prompt succeeded, returns true. If the prompt did not succeed, returns an error message.

Declaration at line 69 of file get_pose_from_user.hpp, definition at line 122 of file get_pose_from_user.cpp.

Private Member Attributes

future_

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

Definition at line 88 of file get_pose_from_user.hpp.

request_client_

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

Definition at line 89 of file get_pose_from_user.hpp.

Public Static Functions

metadata()

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

Returns metadata for this Behavior.

Returns

BT::KeyValueVector The Behavior metadata.

Declaration at line 55 of file get_pose_from_user.hpp, definition at line 81 of file get_pose_from_user.cpp.

providedPorts()

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

Returns list of ports for this Behavior.

Returns

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

Declaration at line 49 of file get_pose_from_user.hpp, definition at line 70 of file get_pose_from_user.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.