Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/rai_core/rai/tools/ros2/manipulation/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,16 @@ def _run(self):
return "Arm successfully reset."
else:
return "Failed to reset the arm."


# GetGrabbingPointTool is only imported for type checking above (to avoid a
# circular import), so Pydantic cannot resolve the "GetGrabbingPointTool"
# annotation on GetObjectPositionsTool by itself. Resolve it here once the real
# class can be imported. If rai_perception is not installed, the tool stays
# unresolved, as before.
try:
from rai_perception.tools import GetGrabbingPointTool # noqa: F811

GetObjectPositionsTool.model_rebuild()
except ImportError:
pass
10 changes: 10 additions & 0 deletions tests/tools/ros2/test_manipulation_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,13 @@ def test_objects_detected(
camera_info_topic="/camera/rgb/camera_info",
object_name="cup",
)


def test_get_object_positions_tool_model_is_fully_defined():
"""Regression test: the forward reference to GetGrabbingPointTool must resolve.

Building the tool with model_construct() skips this check, so look at the
Pydantic completeness flag directly.
"""
pytest.importorskip("rai_perception.tools")
assert GetObjectPositionsTool.__pydantic_complete__
Loading