MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_studio::behaviors::GetMasks2DAutomask Struct Referencefinal

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

#include <sam2_automasking.hpp>

Inheritance diagram for moveit_studio::behaviors::GetMasks2DAutomask:
Collaboration diagram for moveit_studio::behaviors::GetMasks2DAutomask:

Classes

struct  InferenceHandle
 Interface for SAM2 automasking inference. More...
 
struct  SAM2AutomaskHandle
 Default implementation using SAM2Automasking. More...
 

Public Member Functions

 GetMasks2DAutomask (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< moveit_studio::behaviors::BehaviorContext > &shared_resources, std::unique_ptr< InferenceHandle > inference_handle=std::make_unique< SAM2AutomaskHandle >())
 Constructor for SAM2 automasking behavior.
 
 ~GetMasks2DAutomask () override
 
- Public Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
 AsyncBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
virtual ~AsyncBehaviorBase ()=default
 
BT::NodeStatus onStart () override
 Required implementation of BT::StatefulActionNode::onStart().
 
BT::NodeStatus onRunning () override
 Required implementation of BT::StatefulActionNode::onRunning().
 
void onHalted () override
 Required implementation of BT::StatefulActionNode::onHalted().
 
void resetStatus ()
 Resets the internal status of this node.
 
- Public Member Functions inherited from moveit_studio::behaviors::SharedResourcesNode< BT::StatefulActionNode >
 SharedResourcesNode (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 Constructor for SharedResourcesNode. Called by BT::BehaviorTreeFactory when creating a new behavior tree containing this node.
 

Static Public Member Functions

static BT::PortsList providedPorts ()
 Provides port definitions for BehaviorTree.
 
static BT::KeyValueVector metadata ()
 Provides behavior metadata for UI.
 

Protected Member Functions

tl::expected< bool, std::string > doWork () override
 Execute automasking.
 
- Protected Member Functions inherited from moveit_studio::behaviors::AsyncBehaviorBase
virtual tl::expected< void, std::string > doHalt ()
 Optionally implement additional work needed to cleanly interrupt the async process.
 
void notifyCanHalt ()
 Called when runAsync() finishes to notify onHalted() that the async process has finished.
 

Additional Inherited Members

- Protected Attributes inherited from moveit_studio::behaviors::SharedResourcesNode< BT::StatefulActionNode >
std::shared_ptr< BehaviorContextshared_resources_
 

Detailed 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
encoder_model_path input std::string
prompt_encoder_model_path input std::string
decoder_model_path input std::string
model_package input std::string
masks2d output std::vector<moveit_studio_vision_msgs::msg::Mask2D>
mask_count output int

Constructor & Destructor Documentation

◆ GetMasks2DAutomask()

moveit_studio::behaviors::GetMasks2DAutomask::GetMasks2DAutomask ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< moveit_studio::behaviors::BehaviorContext > &  shared_resources,
std::unique_ptr< InferenceHandle inference_handle = std::make_unique<SAM2AutomaskHandle>() 
)

Constructor for SAM2 automasking behavior.

Parameters
nameBehavior instance name
configBehavior configuration
shared_resourcesShared behavior resources
inference_handleCustom inference implementation (default uses SAM2AutomaskHandle)

◆ ~GetMasks2DAutomask()

moveit_studio::behaviors::GetMasks2DAutomask::~GetMasks2DAutomask ( )
overridedefault

Member Function Documentation

◆ doWork()

tl::expected< bool, std::string > moveit_studio::behaviors::GetMasks2DAutomask::doWork ( )
overrideprotectedvirtual

Execute automasking.

Returns
Success or error message

Implements moveit_studio::behaviors::AsyncBehaviorBase.

◆ metadata()

BT::KeyValueVector moveit_studio::behaviors::GetMasks2DAutomask::metadata ( )
static

Provides behavior metadata for UI.

Returns
Metadata key-value pairs

◆ providedPorts()

BT::PortsList moveit_studio::behaviors::GetMasks2DAutomask::providedPorts ( )
static

Provides port definitions for BehaviorTree.

Returns
List of input and output ports

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