Skip to content

Commit 5c62bff

Browse files
committed
avoid spinning the node in open-set vision tools
1 parent d91204b commit 5c62bff

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/rai_extensions/rai_open_set_vision/rai_open_set_vision/tools/segmentation_tools.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from rai.node import RaiBaseNode
3030
from rai.tools.ros import Ros2BaseInput, Ros2BaseTool
3131
from rai.tools.ros.utils import convert_ros_img_to_base64, convert_ros_img_to_ndarray
32+
from rai.utils.ros_async import get_future_result
3233
from rai_interfaces.srv import RAIGroundedSam, RAIGroundingDino
3334

3435
# --------------------- Inputs ---------------------
@@ -77,30 +78,10 @@ class GetSegmentationTool(Ros2BaseTool):
7778
def _get_gdino_response(
7879
self, future: Future
7980
) -> Optional[RAIGroundingDino.Response]:
80-
rclpy.spin_once(self.node)
81-
if future.done():
82-
try:
83-
response = future.result()
84-
except Exception as e:
85-
self.node.get_logger().info("Service call failed %r" % (e,))
86-
raise Exception("Service call failed %r" % (e,))
87-
else:
88-
assert response is not None
89-
return response
90-
return None
81+
return get_future_result(future)
9182

9283
def _get_gsam_response(self, future: Future) -> Optional[RAIGroundedSam.Response]:
93-
rclpy.spin_once(self.node)
94-
if future.done():
95-
try:
96-
response = future.result()
97-
except Exception as e:
98-
self.node.get_logger().info("Service call failed %r" % (e,))
99-
raise Exception("Service call failed %r" % (e,))
100-
else:
101-
assert response is not None
102-
return response
103-
return None
84+
return get_future_result(future)
10485

10586
def _get_image_message(self, topic: str) -> sensor_msgs.msg.Image:
10687
msg = self.node.get_raw_message_from_topic(topic)

0 commit comments

Comments
 (0)