22
22
The demo app and rivz2 need to be started before running the test. The test will fail if the gripping points are not found.
23
23
24
24
Usage:
25
- pytest tests/tools/ros2/test_gripping_points.py::test_gripping_points_manipulation_demo -m "" -s -v
25
+ pytest tests/tools/ros2/test_gripping_points.py::test_gripping_points_manipulation_demo -m "manual " -s -v --strategy <strategy>
26
26
"""
27
27
28
28
import time
@@ -246,14 +246,9 @@ def save_annotated_image(
246
246
cv2 .imwrite (filename , annotated_image )
247
247
248
248
249
- def main (config_name : str = "manipulation-demo " , test_object : str = "cube" ):
249
+ def main (config : dict , test_object : str = "cube " , strategy : str = None ):
250
250
"""Enhanced test with visualization and better error handling."""
251
251
252
- # Get test configuration
253
- config = TEST_CONFIGS [config_name ]
254
-
255
- print (f"Config: { config_name } " )
256
-
257
252
# Initialize ROS2
258
253
rclpy .init ()
259
254
connector = ROS2Connector (executor_type = "single_threaded" )
@@ -273,7 +268,9 @@ def main(config_name: str = "manipulation-demo", test_object: str = "cube"):
273
268
algo_config = config ["algorithms" ]
274
269
275
270
# Create gripping estimator with strategy-specific parameters
276
- estimator_config = algo_config ["estimator" ]
271
+ estimator_config = algo_config ["estimator" ].copy ()
272
+ if strategy :
273
+ estimator_config ["strategy" ] = strategy
277
274
gripping_estimator = GrippingPointEstimator (** estimator_config )
278
275
279
276
# Create point cloud filter
@@ -297,7 +294,9 @@ def main(config_name: str = "manipulation-demo", test_object: str = "cube"):
297
294
print (f"elapsed time: { time .time () - start_time } seconds" )
298
295
299
296
# Test the tool directly
300
- print (f"\n Testing GetGrippingPointTool with object '{ test_object } '" )
297
+ print (
298
+ f"\n Testing GetGrippingPointTool with object '{ test_object } ', strategy '{ strategy } '"
299
+ )
301
300
302
301
result = gripping_tool ._run (test_object )
303
302
gripping_points = extract_gripping_points (result )
@@ -321,7 +320,7 @@ def main(config_name: str = "manipulation-demo", test_object: str = "cube"):
321
320
)
322
321
print ("✅ Debug data published" )
323
322
324
- annotated_image_path = f"{ test_object } _gripping_points.jpg"
323
+ annotated_image_path = f"{ test_object } _ { strategy } _gripping_points.jpg"
325
324
save_annotated_image (
326
325
connector , gripping_points , config , annotated_image_path
327
326
)
@@ -340,12 +339,14 @@ def main(config_name: str = "manipulation-demo", test_object: str = "cube"):
340
339
341
340
342
341
@pytest .mark .manual
343
- def test_gripping_points_manipulation_demo ():
342
+ def test_gripping_points_manipulation_demo (strategy ):
344
343
"""Manual test requiring manipulation-demo app to be started."""
345
- main ("manipulation-demo" , "apple" )
344
+ config = TEST_CONFIGS ["manipulation-demo" ]
345
+ main (config , "cube" , strategy )
346
346
347
347
348
348
@pytest .mark .manual
349
- def test_gripping_points_maciej_demo ():
349
+ def test_gripping_points_maciej_demo (strategy ):
350
350
"""Manual test requiring demo app to be started."""
351
- main ("maciej-test-demo" , "box" )
351
+ config = TEST_CONFIGS ["maciej-test-demo" ]
352
+ main (config , "box" , strategy )
0 commit comments