Skip to main content

AsyncBehaviorBase Class

A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More...

Declaration

class moveit_pro::behaviors::AsyncBehaviorBase { ... }

Included Headers

#include <async_behavior_base.hpp>

Base class

classSharedResourcesNode<BehaviorTreeNodeT>

The SharedResourcesNode class provides a BehaviorContext object when constructing a BehaviorTree.Cpp node. More...

Derived Classes

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classGetMessageFromTopicBehaviorBase<MessageT>

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port. More...

classGetMessageFromTopicBehaviorBase<MessageT>

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port. More...

classGetMessageFromTopicBehaviorBase<MessageT>

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classActionClientBehaviorBase<ActionT>

A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...

classAddCollisionObjectBase

Abstract base for Behaviors that add a CollisionObject to the planning scene. More...

classAdjustPoseWithIMarker

Requests a user to manually adjust a collection of poses using interactive markers in the UI. More...

classAttachObject

Attaches a collision object that is already in the planning scene to a robot link. More...

classBreakpointSubscriber

A behavior that subscribes to a topic that can be used for pausing an objective during execution to allow introspection. This behavior will listen on the configured topic for a True/False message which will cause it to continue or abort from a breakpoint that is included in an objective. More...

classCheckCuboidSimilarity

Check if two GraspableObjects are similar within some tolerance. More...

classComputeInverseKinematics

A Behavior to compute the inverse kinematics for a given set of target poses. More...

classComputeSignedDistanceField

A Behavior to compute a propagation (signed) distance field from a planning scene. More...

classCreateCollisionSpheresAtClosestPoints

This behavior receives point cloud data, filters points inside a cylinder around a reference point, and creates a sphere at each of the closest points within the cylinder. The spheres are returned as a moveit_msgs::msg::CollisionObject message. More...

classCropOrRemovePointsInBox<mode>

Behavior for either cropping or removing points from a box-shaped region of interest. The dimensions and size of the region of interest are defined relative to its centroid. More...

classCropPointsInSphere

Given a point cloud and a sphere-shaped region of interest, create a new point cloud which contains only the points that are inside the region of interest. The dimensions and size of the region of interest are defined relative to its centroid. More...

classCropPosesInBox

Given a vector of poses and a box-shaped region of interest, create a new vector of poses which contains only the poses that are inside the region of interest. The dimensions and size of the region of interest are defined relative to its centroid. More...

classDetachObject

Detaches a collision object from a robot link by id and returns it to the planning scene as a free collision object at its current pose. More...

classDetectAprilTags

Detects AprilTag markers from an image. More...

classDetectCharucoBoard

Detects the interior corners of a ChArUco board in an image and estimates the board pose. More...

classExecuteMTCSolution

Execute each joint trajectory contained in an MTC solution by sending sequential goals to a JTAC or JTC-like controller, depending on the value of execution_pipeline. After each subtrajectory succeeds, apply the corresponding planning scene diff so that scene updates from the MTC task persist. More...

classExecutePolicy

Executes a policy as continuous, collision-checked motion on the arm and optional gripper. More...

classExecuteTrajectory

Accepts a JointTrajectory message via an input data port, and executes it by sending a goal to either a standard FollowJointTrajectory action server (JTC) or a Joint Trajectory Admittance Controller (JTAC) action server, depending on the value of the execution_pipeline input port. More...

classFindMaskedObjects

Finds objects by segmenting a point cloud using a set of 2D mask images. More...

classFitLineSegmentToMask3D

Finds the line segment that best fits a point cloud fragment. More...

classGetContourFromPointCloudSlice

Extracts contours from a point cloud slice. More...

classGetConvexHullPointCloud

Computes a 3D convex hull around an input point cloud and densely resamples the surface to fill holes. More...

classGetGraspableObjectsFromMasks3D

Finds objects in point cloud segments represented by 3D masks. More...

structGetMasks2DAutomask

Segment an image using SAM2 automasking with grid-based point generation. More...

structGetMasks2DFromExemplar

Segment an image using SAM3 with multimodal prompts. More...

structGetMasks2DFromPointQuery

Segment an image using the SAM2 model and point prompts. More...

classGetMasks3DFromMasks2D

Backprojects a number of image masks onto a point cloud with a camera model. More...

classGetMeshNormalPoses

Gets the normal vectors for a given mesh and returns the normal vector poses to the caller. More...

classGetMessageFromTopicBehaviorBase<MessageT>

Base class for Behaviors that get the latest message from a topic specified on an input data port and set that message to an output data port. More...

classGetOrientedBoundingBoxFromPointCloud

Given an input point cloud, finds the oriented bounding box (OBB) using pcl::MomentOfInertiaEstimation and outputs that as a center pose and box dimensions. The OBB orientation is disambiguated by choosing the orientation closest to the reference_pose. More...

classGetPointCloudFromMask3D

Gets the fragment of a point cloud for a 3D mask. More...

classGetPoints2DFromGeminiQuery

Queries Google Gemini with a text prompt and a ROS image to locate 2D points in the image. More...

classGetPointsFromUser

Requests a set of named points from the user by switching the view and displaying a sequence of prompts in the UI. More...

classGetPoseFromPixelCoords

Given an ordered point cloud and normalized pixel XY coordinates, outputs a stamped pose corresponding to a point normal to the selected coordinates. More...

classGetPoseFromUser

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

classGetRegionFromUser

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

classGetTextFromUser

Gets text from user by sending a list of prompts with default values for each prompt. More...

classLoadImageFromFile

Loads an image from a file and writes it to an output data port. More...

classLoadPointCloudFromFile

Loads a point cloud from a .pcd or .stl file, optionally recolors it, and writes it to an output data port. More...

classMergePointClouds

Merges a number of input point clouds into a single one. More...

classMoveCollisionObject

Updates the reference pose of an existing CollisionObject in the planning scene. More...

classPlanMTCTask

Takes a shared pointer to an existing MTC Task object via an input data port, plans the Task, and sets the solution with the lowest overall cost as an output data port. A service client sends over all the solutions to the MTC Solution Manager node which can be used for debugging. More...

classRecordJointTrajectory

Record a JointTrajectory message by subscribing to a topic publishing joint states and pushing the joint states to a JointTrajectory message. More...

classRegisterPointClouds

Registers a target point cloud to a base point cloud and outputs the pose of the target point cloud relative to the origin of the base point cloud which aligns the target cloud with the base cloud. More...

classRemoveCollisionObject

Removes a collision object from a planning scene by id. More...

classSaveImageToFile

Save an image to disk as a .png file. The filename will follow the syntax of file_prefix_YYYYMMDD_HHMMSS.png. More...

classSaveMTCTaskInspection

Walks an MTC Task and saves all introspection data (stage tree, statistics, every solution and failure, interface states, per-stage failure explanations) to a JSON file on disk. More...

classSavePointCloudToFile

Save a point cloud .pcd file to disk. The filename will follow the syntax of file_prefix_YYYYMMDD_HHMMSS.pcd. More...

classSendPointCloudToUI

Transform a point cloud to the "world" frame and publish it as PCD to a topic the UI visualizes. More...

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

classSetCollisionRule

Allows or forbids collisions between two entities in the planning scene's Allowed Collision Matrix, without an MTC task. More...

classTransformPointCloud

Transforms a point cloud given an input pose in the same frame as the point cloud. More...

classTransformPointCloudFrame

Transforms a point cloud to a target coordinate frame. More...

classValidateTrajectory

Checks if a joint trajectory is valid, given a PlanningScene. More...

classWaitForUserPathApproval

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

classMPCBehaviorBase

All non-template implementation for the templated MPCBehaviorBase class. More...

Public Constructors Index

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

Public Destructor Index

~AsyncBehaviorBase () override=default

Public Member Functions Index

BT::NodeStatusonStart () override

Required implementation of BT::StatefulActionNode::onStart(). More...

BT::NodeStatusonRunning () override

Required implementation of BT::StatefulActionNode::onRunning(). More...

voidonHalted () override

Required implementation of BT::StatefulActionNode::onHalted(). More...

voidresetStatus ()

Resets the internal status of this node. More...

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

User-implemented function which handles executing the potentially-long-running process. More...

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

Optionally implement additional work needed to cleanly interrupt the async process. More...

std::shared_future< tl::expected< bool, std::string > > &getFuture ()=0

Gets the shared future which is used to monitor the progress of the async process. More...

voidnotifyCanHalt ()

Called when runAsync() finishes to notify onHalted() that the async process has finished. More...

Private Member Functions Index

tl::expected< bool, std::string >runAsync ()

Function which is run asynchronously. More...

Private Member Attributes Index

std::condition_variablecan_halt_cv_

onHalted() waits on this condition variable. More...

std::mutexcan_halt_mutex_

Mutex used by goal_accepted_cv_. More...

std::atomic_boolis_immediate_halt_allowed_ { true }

If true, onHalted() is allowed to cancel the async process without waiting to be notified by the goal_accepted_cv_ condition variable. More...

Description

A base class for behaviors which need to asynchronously run a function that might take a long time to complete.

Definition at line 20 of file async_behavior_base.hpp.

Public Constructors

AsyncBehaviorBase()

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

Declaration at line 23 of file async_behavior_base.hpp, definition at line 12 of file async_behavior_base.cpp.

Public Destructor

~AsyncBehaviorBase()

moveit_pro::behaviors::AsyncBehaviorBase::~AsyncBehaviorBase ()
default

Definition at line 26 of file async_behavior_base.hpp.

Public Member Functions

doHalt()

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

Optionally implement additional work needed to cleanly interrupt the async process.

The default implementation of this function is a no-op which will not interrupt the async process. This will mean that onHalted will wait until the process finishes before returning.

Returns

Return an empty tl::expected<void, std::string> if the additional work to halt was successful. Return an error message if something failed while doing additional work to halt.

Definition at line 75 of file async_behavior_base.hpp.

doWork()

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

User-implemented function which handles executing the potentially-long-running process.

This function is called within an async process in a separate thread.

Returns

A tl::expected which contains a bool indicating task success if the process completed successfully or was canceled, or an error message if the process failed unexpectedly.

Definition at line 66 of file async_behavior_base.hpp.

getFuture()

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

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 100 of file async_behavior_base.hpp.

notifyCanHalt()

void moveit_pro::behaviors::AsyncBehaviorBase::notifyCanHalt ()

Called when runAsync() finishes to notify onHalted() that the async process has finished.

Behaviors inheriting from AsyncBehaviorBase may also call this function in doWork() to notify onHalted() that doHalt() can be called immediately.

An example of a case where this is needed is when implementing a ROS action client behavior, because in that case onHalted() must block until the action goal response is received and a goal handle is available so that the goal handle can be used to cancel the goal.

Declaration at line 111 of file async_behavior_base.hpp, definition at line 83 of file async_behavior_base.cpp.

onHalted()

void moveit_pro::behaviors::AsyncBehaviorBase::onHalted ()

Required implementation of BT::StatefulActionNode::onHalted().

If an action goal is in-progress, this cancels it and blocks until execute_action_future_ has been set, which indicates that the async process has finished.

Declaration at line 49 of file async_behavior_base.hpp, definition at line 62 of file async_behavior_base.cpp.

onRunning()

BT::NodeStatus moveit_pro::behaviors::AsyncBehaviorBase::onRunning ()

Required implementation of BT::StatefulActionNode::onRunning().

Checks the status of execute_action_future_. If the future has been set, analyze its contents to determine if the behavior has succeeded or failed.

Returns

BT::NodeStatus::RUNNING if the async process is still in-progress. BT::NodeStatus::SUCCESS if the process has finished and succeeded. BT::NodeStatus::FAILURE if the process has finished and failed.

Declaration at line 42 of file async_behavior_base.hpp, definition at line 38 of file async_behavior_base.cpp.

onStart()

BT::NodeStatus moveit_pro::behaviors::AsyncBehaviorBase::onStart ()

Required implementation of BT::StatefulActionNode::onStart().

This runs doWork() within an async process associated with execute_action_future_.

Returns

Always returns BT::NodeStatus::RUNNING.

Declaration at line 33 of file async_behavior_base.hpp, definition at line 18 of file async_behavior_base.cpp.

resetStatus()

void moveit_pro::behaviors::AsyncBehaviorBase::resetStatus ()
inline

Resets the internal status of this node.

Sets the status to IDLE, so that the behavior can be executed again after is has already finished.

Definition at line 55 of file async_behavior_base.hpp.

Private Member Functions

runAsync()

tl::expected< bool, std::string > moveit_pro::behaviors::AsyncBehaviorBase::runAsync ()

Function which is run asynchronously.

Calls doWork(). Calls notifyCanHalt() after doWork() finishes.

Returns

Returns the value returned from doWork().

Declaration at line 119 of file async_behavior_base.hpp, definition at line 92 of file async_behavior_base.cpp.

Private Member Attributes

can_halt_cv_

std::condition_variable moveit_pro::behaviors::AsyncBehaviorBase::can_halt_cv_

onHalted() waits on this condition variable.

The user's implementation of doWork may use this condition variable to notify that it is possible for onHalted() to cancel the in-progress async process before it is finished.

An example of a case where this is needed is when implementing a ROS action client behavior, since the client must receive an affirmative goal response and a goal handle before the in-progress action can be halted.

Definition at line 129 of file async_behavior_base.hpp.

can_halt_mutex_

std::mutex moveit_pro::behaviors::AsyncBehaviorBase::can_halt_mutex_

Mutex used by goal_accepted_cv_.

Definition at line 132 of file async_behavior_base.hpp.

is_immediate_halt_allowed_

std::atomic_bool moveit_pro::behaviors::AsyncBehaviorBase::is_immediate_halt_allowed_ { true }

If true, onHalted() is allowed to cancel the async process without waiting to be notified by the goal_accepted_cv_ condition variable.

This is checked in the predicate of can_halt_cv_.wait(), in case onHalted() tries to wait on can_halt_cv_ after can_halt_cv_ has been notified.

Definition at line 140 of file async_behavior_base.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.