GetMasks2DAutomask Struct
Segment an image using SAM2 automasking with grid-based point generation. More...
Declaration
Included Headers
Base struct
| 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
| GetMasks2DAutomask (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< moveit_pro::behaviors::BehaviorContext > &shared_resources, std::unique_ptr< InferenceHandle > inference_handle=std::make_unique< SAM2AutomaskHandle >()) | |
|
Constructor for SAM2 automasking behavior. More... | |
Public Destructor Index
| ~GetMasks2DAutomask () override | |
Private Member Functions Index
| tl::expected< bool, std::string > | doWork () override |
|
Execute automasking. More... | |
| tl::expected< void, std::string > | doHalt () override |
|
Cancel an in-flight SAM2 automasking inference via the inference handle. More... | |
| std::shared_future< tl::expected< bool, std::string > > & | getFuture () override |
|
Classes derived from AsyncBehaviorBase must implement getFuture() More... | |
Private Member Attributes Index
| std::unique_ptr< InferenceHandle > | inference_handle_ |
| std::optional< internal::Sam2AutomaskModelPorts > | latched_ports_ |
| bool | cpu_fallback_warning_published_ { false } |
| std::shared_future< tl::expected< bool, std::string > > | future_ |
|
Classes derived from AsyncBehaviorBase must have this shared_future as a class member. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
|
Provides port definitions for BehaviorTree. More... | |
| static BT::KeyValueVector | metadata () |
|
Provides behavior metadata for UI. More... | |
Description
Segment an image using SAM2 automasking with grid-based point generation.
This behavior automatically segments an image by generating a uniform grid of points and running SAM2 inference on each point. Applies NMS to remove overlapping masks and splits disconnected components.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| image | input | sensor_msgs::msg::Image |
| grid_size | input | int |
| score_threshold | input | float |
| nms_threshold | input | float |
| min_component_area | input | int |
| model_bundle_manifest | input | std::string |
| runtime_id | input | std::string |
| model_package | input | std::string |
| masks2d | output | std::vector<moveit_studio_vision_msgs::msg::Mask2D> |
| mask_count | output | int |
Definition at line 87 of file sam2_automasking.hpp.
Public Constructors
GetMasks2DAutomask()
|
Constructor for SAM2 automasking behavior.
- Parameters
-
name Behavior instance name
config Behavior configuration
shared_resources Shared behavior resources
inference_handle Custom inference implementation (default uses SAM2AutomaskHandle)
Declaration at line 190 of file sam2_automasking.hpp, definition at line 216 of file sam2_automasking.cpp.
Public Destructor
~GetMasks2DAutomask()
|
Definition at line 194 of file sam2_automasking.hpp.
Private Member Functions
doHalt()
| virtual |
Cancel an in-flight SAM2 automasking inference via the inference handle.
Forwards to InferenceHandle::requestTerminate(), which cancels the pipeline at the next per-graph boundary. doWork() is responsible for calling clearTerminate() and notifyCanHalt() before invoking predict() so this halt is observable.
Declaration at line 221 of file sam2_automasking.hpp, definition at line 419 of file sam2_automasking.cpp.
doWork()
| virtual |
Execute automasking.
- Returns
Success or error message
Declaration at line 213 of file sam2_automasking.hpp, definition at line 269 of file sam2_automasking.cpp.
getFuture()
| inline virtual |
Classes derived from AsyncBehaviorBase must implement getFuture()
Definition at line 235 of file sam2_automasking.hpp.
Private Member Attributes
cpu_fallback_warning_published_
|
True once the CPU-inference warning has been published, so it fires once per behavior instance rather than on every tick (load() is idempotent and called from every doWork()); the model latches at first load, so the served device cannot change afterwards.
Definition at line 232 of file sam2_automasking.hpp.
future_
|
Classes derived from AsyncBehaviorBase must have this shared_future as a class member.
Definition at line 241 of file sam2_automasking.hpp.
inference_handle_
|
Definition at line 222 of file sam2_automasking.hpp.
latched_ports_
|
The model-selecting port values this instance loaded with, empty until the first load. The model latches: a later tick naming different values fails the Behavior rather than swapping models mid-run.
Definition at line 227 of file sam2_automasking.hpp.
Public Static Functions
metadata()
| static |
Provides behavior metadata for UI.
- Returns
Metadata key-value pairs
Declaration at line 206 of file sam2_automasking.hpp, definition at line 260 of file sam2_automasking.cpp.
providedPorts()
| static |
Provides port definitions for BehaviorTree.
- Returns
List of input and output ports
Declaration at line 200 of file sam2_automasking.hpp, definition at line 226 of file sam2_automasking.cpp.
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.