AsyncBehaviorBase Class
A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More...
Declaration
Included Headers
Base class
| class | SharedResourcesNode<BehaviorTreeNodeT> |
|
The SharedResourcesNode class provides a BehaviorContext object when constructing a BehaviorTree.Cpp node. More... | |
Derived Classes
| class | ActionClientBehaviorBase<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... | |
| class | ActionClientBehaviorBase<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... | |
| class | ActionClientBehaviorBase<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... | |
| class | ActionClientBehaviorBase<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... | |
| class | ActionClientBehaviorBase<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... | |
| class | ActionClientBehaviorBase<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... | |
| class | GetMessageFromTopicBehaviorBase<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... | |
| class | GetMessageFromTopicBehaviorBase<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... | |
| class | GetMessageFromTopicBehaviorBase<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... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | ActionClientBehaviorBase<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... | |
| class | AddCollisionObjectBase |
|
Abstract base for Behaviors that add a CollisionObject to the planning scene. More... | |
| class | AdjustPoseWithIMarker |
|
Requests a user to manually adjust a collection of poses using interactive markers in the UI. More... | |
| class | AttachObject |
|
Attaches a collision object that is already in the planning scene to a robot link. More... | |
| class | BreakpointSubscriber |
|
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... | |
| class | CheckCuboidSimilarity |
|
Check if two GraspableObjects are similar within some tolerance. More... | |
| class | ComputeInverseKinematics |
|
A Behavior to compute the inverse kinematics for a given set of target poses. More... | |
| class | ComputeSignedDistanceField |
|
A Behavior to compute a propagation (signed) distance field from a planning scene. More... | |
| class | CreateCollisionSpheresAtClosestPoints |
|
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... | |
| class | CropOrRemovePointsInBox<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... | |
| class | CropPointsInSphere |
|
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... | |
| class | CropPosesInBox |
|
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... | |
| class | DetachObject |
|
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... | |
| class | DetectAprilTags |
|
Detects AprilTag markers from an image. More... | |
| class | DetectCharucoBoard |
|
Detects the interior corners of a ChArUco board in an image and estimates the board pose. More... | |
| class | ExecuteMTCSolution |
|
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... | |
| class | ExecutePolicy |
|
Executes a policy as continuous, collision-checked motion on the arm and optional gripper. More... | |
| class | ExecuteTrajectory |
|
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... | |
| class | FindMaskedObjects |
|
Finds objects by segmenting a point cloud using a set of 2D mask images. More... | |
| class | FitLineSegmentToMask3D |
|
Finds the line segment that best fits a point cloud fragment. More... | |
| class | GetContourFromPointCloudSlice |
|
Extracts contours from a point cloud slice. More... | |
| class | GetConvexHullPointCloud |
|
Computes a 3D convex hull around an input point cloud and densely resamples the surface to fill holes. More... | |
| class | GetGraspableObjectsFromMasks3D |
|
Finds objects in point cloud segments represented by 3D masks. More... | |
| struct | GetMasks2DAutomask |
|
Segment an image using SAM2 automasking with grid-based point generation. More... | |
| struct | GetMasks2DFromExemplar |
|
Segment an image using SAM3 with multimodal prompts. More... | |
| struct | GetMasks2DFromPointQuery |
|
Segment an image using the SAM2 model and point prompts. More... | |
| class | GetMasks3DFromMasks2D |
|
Backprojects a number of image masks onto a point cloud with a camera model. More... | |
| class | GetMeshNormalPoses |
|
Gets the normal vectors for a given mesh and returns the normal vector poses to the caller. More... | |
| class | GetMessageFromTopicBehaviorBase<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... | |
| class | GetOrientedBoundingBoxFromPointCloud |
|
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... | |
| class | GetPointCloudFromMask3D |
|
Gets the fragment of a point cloud for a 3D mask. More... | |
| class | GetPoints2DFromGeminiQuery |
|
Queries Google Gemini with a text prompt and a ROS image to locate 2D points in the image. More... | |
| class | GetPointsFromUser |
|
Requests a set of named points from the user by switching the view and displaying a sequence of prompts in the UI. More... | |
| class | GetPoseFromPixelCoords |
|
Given an ordered point cloud and normalized pixel XY coordinates, outputs a stamped pose corresponding to a point normal to the selected coordinates. More... | |
| class | GetPoseFromUser |
|
Sends a prompt request to the UI so that the user can click in the UI and return a pose. More... | |
| class | GetRegionFromUser |
|
Requests a 2D region (bounding box or polygon) from the user by switching the view and displaying a prompt in the UI. More... | |
| class | GetTextFromUser |
|
Gets text from user by sending a list of prompts with default values for each prompt. More... | |
| class | LoadImageFromFile |
|
Loads an image from a file and writes it to an output data port. More... | |
| class | LoadPointCloudFromFile |
|
Loads a point cloud from a .pcd or .stl file, optionally recolors it, and writes it to an output data port. More... | |
| class | MergePointClouds |
|
Merges a number of input point clouds into a single one. More... | |
| class | MoveCollisionObject |
|
Updates the reference pose of an existing CollisionObject in the planning scene. More... | |
| class | PlanMTCTask |
|
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... | |
| class | RecordJointTrajectory |
|
Record a JointTrajectory message by subscribing to a topic publishing joint states and pushing the joint states to a JointTrajectory message. More... | |
| class | RegisterPointClouds |
|
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... | |
| class | RemoveCollisionObject |
|
Removes a collision object from a planning scene by id. More... | |
| class | SaveImageToFile |
|
Save an image to disk as a .png file. The filename will follow the syntax of file_prefix_YYYYMMDD_HHMMSS.png. More... | |
| class | SaveMTCTaskInspection |
|
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... | |
| class | SavePointCloudToFile |
|
Save a point cloud .pcd file to disk. The filename will follow the syntax of file_prefix_YYYYMMDD_HHMMSS.pcd. More... | |
| class | SendPointCloudToUI |
|
Transform a point cloud to the "world" frame and publish it as PCD to a topic the UI visualizes. More... | |
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
| class | SetCollisionRule |
|
Allows or forbids collisions between two entities in the planning scene's Allowed Collision Matrix, without an MTC task. More... | |
| class | TransformPointCloud |
|
Transforms a point cloud given an input pose in the same frame as the point cloud. More... | |
| class | TransformPointCloudFrame |
|
Transforms a point cloud to a target coordinate frame. More... | |
| class | ValidateTrajectory |
|
Checks if a joint trajectory is valid, given a PlanningScene. More... | |
| class | WaitForUserPathApproval |
|
Sends a prompt request to the UI to accept or reject a visualized nav_msgs::msg::Path. More... | |
| class | MPCBehaviorBase |
|
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::NodeStatus | onStart () override |
|
Required implementation of BT::StatefulActionNode::onStart(). More... | |
| BT::NodeStatus | onRunning () override |
|
Required implementation of BT::StatefulActionNode::onRunning(). More... | |
| void | onHalted () override |
|
Required implementation of BT::StatefulActionNode::onHalted(). More... | |
| void | resetStatus () |
|
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... | |
| void | notifyCanHalt () |
|
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_variable | can_halt_cv_ |
|
onHalted() waits on this condition variable. More... | |
| std::mutex | can_halt_mutex_ |
|
Mutex used by goal_accepted_cv_. More... | |
| std::atomic_bool | 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. 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()
|
Declaration at line 23 of file async_behavior_base.hpp, definition at line 12 of file async_behavior_base.cpp.
Public Destructor
~AsyncBehaviorBase()
| default |
Definition at line 26 of file async_behavior_base.hpp.
Public Member Functions
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()
|
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()
|
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()
|
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()
|
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()
|
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()
|
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()
| 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()
|
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_
|
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_
|
Mutex used by goal_accepted_cv_.
Definition at line 132 of file async_behavior_base.hpp.
is_immediate_halt_allowed_
|
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.