Skip to content

Commit b1ee5a7

Browse files
10385 Adds examples of using sam2 automask with image from factory setting
1 parent aa853da commit b1ee5a7

File tree

8 files changed

+75
-0
lines changed

8 files changed

+75
-0
lines changed

src/factory_sim/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ install(
99
config
1010
description
1111
launch
12+
models
1213
objectives
1314
waypoints
1415
DESTINATION
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:e11609a8d694f2186f5974cf0d86e1588dbbb126088c4a7849adbc546b284e3a
3+
size 33118447
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:cbdbe1e1ad3b616985d0f9c071a5948f8f8342d8e55e98857159405678b70cec
3+
size 851811319
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:eb2130a99f74bb2f6a430c0f1fe6af291b45ead4bf0beee715330c3def901206
3+
size 36005
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask Camera Iterate Masks">
3+
<BehaviorTree ID="Automask Camera Iterate Masks" _description="Runs automask on bin camera image and visualizes each mask individually using breakpoints. Useful for tuning mask parameters." _favorite="false">
4+
<Control ID="Sequence" name="TopLevelSequence">
5+
<Action ID="GetImage" topic_name="/bin_camera_left/color"/>
6+
<Action ID="GetMasks2DAutomask" grid_size="11" image="{image}" mask_count="{mask_count}" masks2d="{masks2d}" score_threshold="0.800000" decoder_model_path="models/sam2.1_decoder.onnx" encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx" prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx" nms_threshold="0.3" model_package="factory_sim" min_component_area="2000"/>
7+
<Decorator ID="ForEach" index="{index}" out="{mask}" vector_in="{masks2d}">
8+
<Control ID="Sequence">
9+
<Action ID="Script" code="mask_label:=&quot;mask &quot;..index"/>
10+
<SubTree ID="CreateVector" _collapsed="true" vector="{one_mask}"/>
11+
<SubTree ID="AddToVector" _collapsed="false" element="{mask}" input_vector="{one_mask}" output_vector="{one_mask}"/>
12+
<Action ID="PublishMask2D" masks="{one_mask}" masks_visualization_topic="/masks_visualization" image="{image}" opacity="0.500000" bounding_box_labels="{mask_label}"/>
13+
<Action ID="BreakpointSubscriber" breakpoint_topic="/moveit_pro_breakpoint"/>
14+
</Control>
15+
</Decorator>
16+
</Control>
17+
</BehaviorTree>
18+
<TreeNodesModel>
19+
<SubTree ID="Automask Camera Iterate Masks">
20+
<MetadataFields>
21+
<Metadata description="Takes pictures from two different perspectives and runs automask on each using a loop"/>
22+
<Metadata runnable="true"/>
23+
<Metadata subcategory="Perception - ML"/>
24+
</MetadataFields>
25+
</SubTree>
26+
</TreeNodesModel>
27+
</root>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask from Camera">
3+
<BehaviorTree ID="Automask from Camera" _description="Runs automask on image from camera" _favorite="false">
4+
<Control ID="Sequence" name="TopLevelSequence">
5+
<Action ID="GetImage" message_out="{image}" publisher_timeout_sec="5.000000" timeout_sec="5.000000" topic_name="/bin_camera_left/color"/>
6+
<Action ID="GetMasks2DAutomask" grid_size="11" image="{image}" mask_count="{mask_count}" masks2d="{masks2d}" min_component_area="2000" nms_threshold="0.200000" score_threshold="0.8" decoder_model_path="models/sam2.1_decoder.onnx" encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx" prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx" model_package="factory_sim"/>
7+
<Action ID="PublishMask2D" masks="{masks2d}" masks_visualization_topic="/masks_visualization" image="{image}" opacity="0.500000" bounding_box_detection_class="mask"/>
8+
</Control>
9+
</BehaviorTree>
10+
<TreeNodesModel>
11+
<SubTree ID="Automask from Camera">
12+
<MetadataFields>
13+
<Metadata description="Takes pictures from two different perspectives and runs automask on each using a loop"/>
14+
<Metadata runnable="true"/>
15+
<Metadata subcategory="Perception - ML"/>
16+
</MetadataFields>
17+
</SubTree>
18+
</TreeNodesModel>
19+
</root>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask from File">
3+
<BehaviorTree ID="Automask from File" _description="Runs automask on image of coffee cup from file." _favorite="false">
4+
<Control ID="Sequence" name="TopLevelSequence">
5+
<Action ID="LoadImageFromFile" frame_id="camera" image="{image}" file_path="~/user_ws/src/factory_sim/objectives/coffee_cup1.png"/>
6+
<Action ID="GetMasks2DAutomask" grid_size="11" image="{image}" mask_count="{mask_count}" masks2d="{masks2d}" score_threshold="0.500000" decoder_model_path="models/sam2.1_decoder.onnx" encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx" prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx" model_package="factory_sim" nms_threshold="0.3" min_component_area="200"/>
7+
<Action ID="PublishMask2D" masks="{masks2d}" masks_visualization_topic="/masks_visualization" image="{image}" opacity="0.500000" bounding_box_detection_class="mask"/>
8+
</Control>
9+
</BehaviorTree>
10+
<TreeNodesModel>
11+
<SubTree ID="Automask from File">
12+
<MetadataFields>
13+
<Metadata description="Takes pictures from two different perspectives and runs automask on each using a loop"/>
14+
<Metadata runnable="true"/>
15+
<Metadata subcategory="Perception - ML"/>
16+
</MetadataFields>
17+
</SubTree>
18+
</TreeNodesModel>
19+
</root>
161 KB
Loading

0 commit comments

Comments
 (0)