Skip to content

Commit 4ec0f06

Browse files
Merge pull request #458 from PickNikRobotics/10385-automask-example-main
10385 Adds examples of using sam2 automask with image from factory setting
2 parents fad243e + 40c8f32 commit 4ec0f06

File tree

8 files changed

+178
-0
lines changed

8 files changed

+178
-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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask Camera Iterate Masks">
3+
<BehaviorTree
4+
ID="Automask Camera Iterate Masks"
5+
_description="Runs automask on bin camera image and visualizes each mask individually using breakpoints. Useful for tuning mask parameters."
6+
_favorite="false"
7+
>
8+
<Control ID="Sequence" name="TopLevelSequence">
9+
<Action ID="GetImage" topic_name="/bin_camera_left/color" />
10+
<Action
11+
ID="GetMasks2DAutomask"
12+
grid_size="11"
13+
image="{image}"
14+
mask_count="{mask_count}"
15+
masks2d="{masks2d}"
16+
score_threshold="0.800000"
17+
decoder_model_path="models/sam2.1_decoder.onnx"
18+
encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx"
19+
prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx"
20+
nms_threshold="0.3"
21+
model_package="factory_sim"
22+
min_component_area="2000"
23+
/>
24+
<Decorator
25+
ID="ForEach"
26+
index="{index}"
27+
out="{mask}"
28+
vector_in="{masks2d}"
29+
>
30+
<Control ID="Sequence">
31+
<Action ID="Script" code="mask_label:=&quot;mask &quot;..index" />
32+
<SubTree ID="CreateVector" _collapsed="true" vector="{one_mask}" />
33+
<SubTree
34+
ID="AddToVector"
35+
_collapsed="false"
36+
element="{mask}"
37+
input_vector="{one_mask}"
38+
output_vector="{one_mask}"
39+
/>
40+
<Action
41+
ID="PublishMask2D"
42+
masks="{one_mask}"
43+
masks_visualization_topic="/masks_visualization"
44+
image="{image}"
45+
opacity="0.500000"
46+
bounding_box_labels="{mask_label}"
47+
/>
48+
<Action
49+
ID="BreakpointSubscriber"
50+
breakpoint_topic="/moveit_pro_breakpoint"
51+
/>
52+
</Control>
53+
</Decorator>
54+
</Control>
55+
</BehaviorTree>
56+
<TreeNodesModel>
57+
<SubTree ID="Automask Camera Iterate Masks">
58+
<MetadataFields>
59+
<Metadata
60+
description="Takes pictures from two different perspectives and runs automask on each using a loop"
61+
/>
62+
<Metadata runnable="true" />
63+
<Metadata subcategory="Perception - ML" />
64+
</MetadataFields>
65+
</SubTree>
66+
</TreeNodesModel>
67+
</root>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask from Camera">
3+
<BehaviorTree
4+
ID="Automask from Camera"
5+
_description="Runs automask on image from camera"
6+
_favorite="false"
7+
>
8+
<Control ID="Sequence" name="TopLevelSequence">
9+
<Action
10+
ID="GetImage"
11+
message_out="{image}"
12+
publisher_timeout_sec="5.000000"
13+
timeout_sec="5.000000"
14+
topic_name="/bin_camera_left/color"
15+
/>
16+
<Action
17+
ID="GetMasks2DAutomask"
18+
grid_size="11"
19+
image="{image}"
20+
mask_count="{mask_count}"
21+
masks2d="{masks2d}"
22+
min_component_area="2000"
23+
nms_threshold="0.200000"
24+
score_threshold="0.8"
25+
decoder_model_path="models/sam2.1_decoder.onnx"
26+
encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx"
27+
prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx"
28+
model_package="factory_sim"
29+
/>
30+
<Action
31+
ID="PublishMask2D"
32+
masks="{masks2d}"
33+
masks_visualization_topic="/masks_visualization"
34+
image="{image}"
35+
opacity="0.500000"
36+
bounding_box_detection_class="mask"
37+
/>
38+
</Control>
39+
</BehaviorTree>
40+
<TreeNodesModel>
41+
<SubTree ID="Automask from Camera">
42+
<MetadataFields>
43+
<Metadata
44+
description="Takes pictures from two different perspectives and runs automask on each using a loop"
45+
/>
46+
<Metadata runnable="true" />
47+
<Metadata subcategory="Perception - ML" />
48+
</MetadataFields>
49+
</SubTree>
50+
</TreeNodesModel>
51+
</root>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<root BTCPP_format="4" main_tree_to_execute="Automask from File">
3+
<BehaviorTree
4+
ID="Automask from File"
5+
_description="Runs automask on image of coffee cup from file."
6+
_favorite="false"
7+
>
8+
<Control ID="Sequence" name="TopLevelSequence">
9+
<Action
10+
ID="LoadImageFromFile"
11+
frame_id="camera"
12+
image="{image}"
13+
file_path="~/user_ws/src/factory_sim/objectives/coffee_cup1.png"
14+
/>
15+
<Action
16+
ID="GetMasks2DAutomask"
17+
grid_size="11"
18+
image="{image}"
19+
mask_count="{mask_count}"
20+
masks2d="{masks2d}"
21+
score_threshold="0.500000"
22+
decoder_model_path="models/sam2.1_decoder.onnx"
23+
encoder_model_path="models/sam2.1_hiera_l_image_encoder.onnx"
24+
prompt_encoder_model_path="models/sam2.1_prompt_encoder.onnx"
25+
model_package="factory_sim"
26+
nms_threshold="0.3"
27+
min_component_area="200"
28+
/>
29+
<Action
30+
ID="PublishMask2D"
31+
masks="{masks2d}"
32+
masks_visualization_topic="/masks_visualization"
33+
image="{image}"
34+
opacity="0.500000"
35+
bounding_box_detection_class="mask"
36+
/>
37+
</Control>
38+
</BehaviorTree>
39+
<TreeNodesModel>
40+
<SubTree ID="Automask from File">
41+
<MetadataFields>
42+
<Metadata
43+
description="Takes pictures from two different perspectives and runs automask on each using a loop"
44+
/>
45+
<Metadata runnable="true" />
46+
<Metadata subcategory="Perception - ML" />
47+
</MetadataFields>
48+
</SubTree>
49+
</TreeNodesModel>
50+
</root>
161 KB
Loading

0 commit comments

Comments
 (0)