Skip to content

feat: custom ros2 interfaces benchmark #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fef6d27
feat: publish message and get interfaces tools mock, test for publish
jmatejcz Mar 27, 2025
16ec2da
refactor: mock tools outputs and throws errors formatted like real tools
jmatejcz Mar 28, 2025
9d854e5
refactor: change from expected to available variables
jmatejcz Mar 28, 2025
9a2ae6e
feat: add call service mock and call service task
jmatejcz Mar 30, 2025
1bd2bca
feat: add action tools mocks
jmatejcz Mar 31, 2025
9fcfb35
feat: start action task
jmatejcz Mar 31, 2025
e71374b
feat: publish message tasks for other messages types
jmatejcz Mar 31, 2025
0cb33fe
fix: import fixes after merge
jmatejcz Mar 31, 2025
398518e
feat: mock new tools
jmatejcz Mar 31, 2025
c77db63
feat: tasks for rest of the service types
jmatejcz Mar 31, 2025
962da6b
feat: GetROS2MessageInterfaceTool now return output as string with al…
jmatejcz Apr 1, 2025
19f918f
refactor: updated mock interfaces output to new tool
jmatejcz Apr 1, 2025
8db2816
feat: separate parent classes for topic, service and actions tasks
jmatejcz Apr 2, 2025
9cac642
feat: enhance destroy_subscribers behavior (#499)
maciejmajek Apr 2, 2025
0a2f854
feat: adjusted service and action tasks to parent classes
jmatejcz Apr 2, 2025
348a557
refactor: update tasks file
jmatejcz Apr 2, 2025
5a08dde
refactor: moved all tasks back into one file
jmatejcz Apr 2, 2025
a70f21a
refactor: actions as pydantic basemodels - for easier validation
MagdalenaKotynia Apr 1, 2025
c875531
feat: add pydantic models for messages
jmatejcz Apr 2, 2025
4a80a84
feat: verify messages based on pydantic models
jmatejcz Apr 3, 2025
7a3f843
feat: adjust HRIMessage mocks to new fields
jmatejcz Apr 3, 2025
12eb88a
refactor: all fields in models are optional now as ros fills the rest…
jmatejcz Apr 3, 2025
6b41cf3
feat: changed task validation to make it more flexible
jmatejcz Apr 3, 2025
4a2e86d
refactor: result file saves task name to make it more readable
jmatejcz Apr 3, 2025
b9323ac
chore: add licenses
jmatejcz Apr 3, 2025
235dd40
feat: add task with varios extra calls values,
jmatejcz Apr 3, 2025
62bfec0
fix: what i see service typo fix
jmatejcz Apr 3, 2025
b676d44
refactor: adjust interfaces for topics and services
jmatejcz Apr 8, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Sequence

from rai_bench.tool_calling_agent_bench.agent_tasks_interfaces import (
ToolCallingAgentTask,
)

# from rai_bench.tool_calling_agent_bench.ros2_agent_tasks import (
# NavigateToPointTask,
# )

# tasks: Sequence[ToolCallingAgentTask] = [
# NavigateToPointTask(),
# # SpinAroundTask()
# ]
197 changes: 119 additions & 78 deletions src/rai_bench/rai_bench/examples/tool_calling_agent_bench_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,85 +18,126 @@
ToolCallingAgentTask,
)
from rai_bench.tool_calling_agent_bench.ros2_agent_tasks import (
GetAllROS2RGBCamerasTask,
GetObjectPositionsTask,
GetROS2DepthCameraTask,
GetROS2MessageTask,
GetROS2RGBCameraTask,
GetROS2TopicsTask,
GetROS2TopicsTask2,
GrabExistingObjectTask,
GrabNotExistingObjectTask,
MoveExistingObjectFrontTask,
MoveExistingObjectLeftTask,
MoveToPointTask,
SwapObjectsTask,
PublishROS2HRIMessageTask3ExtraCalls,
PublishROS2HRIMessageTask0ExtraCalls,
PublishROS2HRIMessageTask1ExtraCall,
PublishROS2AudioMessageTask0ExtraCalls,
PublishROS2AudioMessageTask3ExtraCalls,
PublishROS2AudioMessageTask1ExtraCall,
PublishROS2DetectionArrayTask3ExtraCalls,
PublishROS2DetectionArrayTask1ExtraCall,
PublishROS2DetectionArrayTask0ExtraCalls,
CallROS2ManipulatorMoveToServiceTask3ExtraCalls,
CallROS2ManipulatorMoveToServiceTask1ExtraCall,
CallROS2ManipulatorMoveToServiceTask0ExtraCalls,
CallGroundedSAMSegmentTask3ExtraCalls,
CallGroundedSAMSegmentTask1ExtraCall,
CallGroundedSAMSegmentTask0ExtraCalls,
CallGroundingDinoClassifyTask3ExtraCalls,
CallGroundingDinoClassifyTask1ExtraCall,
CallGroundingDinoClassifyTask0ExtraCalls,
CallGetLogDigestTask3ExtraCalls,
CallGetLogDigestTask1ExtraCall,
CallGetLogDigestTask0ExtraCalls,
CallVectorStoreRetrievalTask3ExtraCalls,
CallVectorStoreRetrievalTask1ExtraCall,
CallVectorStoreRetrievalTask0ExtraCalls,
CallWhatISeeTask3ExtraCalls,
CallWhatISeeTask1ExtraCall,
CallWhatISeeTask0ExtraCalls,
)

tasks: Sequence[ToolCallingAgentTask] = [
GetROS2RGBCameraTask(),
GetROS2TopicsTask(),
GetROS2DepthCameraTask(),
GetAllROS2RGBCamerasTask(),
GetROS2TopicsTask2(),
GetROS2MessageTask(),
MoveToPointTask(args={"x": 1.0, "y": 2.0, "z": 3.0, "task": "grab"}),
MoveToPointTask(args={"x": 1.2, "y": 2.3, "z": 3.4, "task": "drop"}),
GetObjectPositionsTask(
objects={
"carrot": [{"x": 1.0, "y": 2.0, "z": 3.0}],
"apple": [{"x": 4.0, "y": 5.0, "z": 6.0}],
"banana": [
{"x": 7.0, "y": 8.0, "z": 9.0},
{"x": 10.0, "y": 11.0, "z": 12.0},
],
},
),
GrabExistingObjectTask(
object_to_grab="banana",
objects={
"banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
"apple": [
{"x": 4.0, "y": 5.0, "z": 6.0},
{"x": 10.0, "y": 11.0, "z": 12.0},
],
},
),
GrabNotExistingObjectTask(
object_to_grab="apple",
objects={
"banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
"cube": [
{"x": 4.0, "y": 5.0, "z": 6.0},
{"x": 10.0, "y": 11.0, "z": 12.0},
],
},
),
MoveExistingObjectLeftTask(
object_to_grab="banana",
objects={
"banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
"apple": [
{"x": 4.0, "y": 5.0, "z": 6.0},
{"x": 10.0, "y": 11.0, "z": 12.0},
],
},
),
MoveExistingObjectFrontTask(
object_to_grab="banana",
objects={
"banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
"apple": [
{"x": 4.0, "y": 5.0, "z": 6.0},
{"x": 10.0, "y": 11.0, "z": 12.0},
],
},
),
SwapObjectsTask(
objects={
"banana": [{"x": 1.0, "y": 2.0, "z": 3.0}],
"apple": [{"x": 4.0, "y": 5.0, "z": 6.0}],
},
objects_to_swap=["banana", "apple"],
),
PublishROS2HRIMessageTask3ExtraCalls(),
PublishROS2HRIMessageTask1ExtraCall(),
PublishROS2HRIMessageTask0ExtraCalls(),
PublishROS2AudioMessageTask3ExtraCalls(),
PublishROS2AudioMessageTask1ExtraCall(),
PublishROS2AudioMessageTask0ExtraCalls(),
PublishROS2DetectionArrayTask3ExtraCalls(),
PublishROS2DetectionArrayTask1ExtraCall(),
PublishROS2DetectionArrayTask0ExtraCalls(),
CallROS2ManipulatorMoveToServiceTask3ExtraCalls(),
CallROS2ManipulatorMoveToServiceTask1ExtraCall(),
CallROS2ManipulatorMoveToServiceTask0ExtraCalls(),
CallGroundedSAMSegmentTask3ExtraCalls(),
CallGroundedSAMSegmentTask1ExtraCall(),
CallGroundedSAMSegmentTask0ExtraCalls(),
CallGroundingDinoClassifyTask3ExtraCalls(),
CallGroundingDinoClassifyTask1ExtraCall(),
CallGroundingDinoClassifyTask0ExtraCalls(),
CallGetLogDigestTask3ExtraCalls(),
CallGetLogDigestTask1ExtraCall(),
CallGetLogDigestTask0ExtraCalls(),
CallVectorStoreRetrievalTask3ExtraCalls(),
CallVectorStoreRetrievalTask1ExtraCall(),
CallVectorStoreRetrievalTask0ExtraCalls(),
CallWhatISeeTask3ExtraCalls(),
CallWhatISeeTask1ExtraCall(),
CallWhatISeeTask0ExtraCalls(),
# GetROS2RGBCameraTask(),
# GetROS2TopicsTask(),
# GetROS2DepthCameraTask(),
# GetAllROS2RGBCamerasTask(),
# GetROS2TopicsTask2(),
# GetROS2MessageTask(),
# MoveToPointTask(args={"x": 1.0, "y": 2.0, "z": 3.0, "task": "grab"}),
# MoveToPointTask(args={"x": 1.2, "y": 2.3, "z": 3.4, "task": "drop"}),
# GetObjectPositionsTask(
# objects={
# "carrot": [{"x": 1.0, "y": 2.0, "z": 3.0}],
# "apple": [{"x": 4.0, "y": 5.0, "z": 6.0}],
# "banana": [
# {"x": 7.0, "y": 8.0, "z": 9.0},
# {"x": 10.0, "y": 11.0, "z": 12.0},
# ],
# },
# ),
# GrabExistingObjectTask(
# object_to_grab="banana",
# objects={
# "banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
# "apple": [
# {"x": 4.0, "y": 5.0, "z": 6.0},
# {"x": 10.0, "y": 11.0, "z": 12.0},
# ],
# },
# ),
# GrabNotExistingObjectTask(
# object_to_grab="apple",
# objects={
# "banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
# "cube": [
# {"x": 4.0, "y": 5.0, "z": 6.0},
# {"x": 10.0, "y": 11.0, "z": 12.0},
# ],
# },
# ),
# MoveExistingObjectLeftTask(
# object_to_grab="banana",
# objects={
# "banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
# "apple": [
# {"x": 4.0, "y": 5.0, "z": 6.0},
# {"x": 10.0, "y": 11.0, "z": 12.0},
# ],
# },
# ),
# MoveExistingObjectFrontTask(
# object_to_grab="banana",
# objects={
# "banana": [{"x": 7.0, "y": 8.0, "z": 9.0}],
# "apple": [
# {"x": 4.0, "y": 5.0, "z": 6.0},
# {"x": 10.0, "y": 11.0, "z": 12.0},
# ],
# },
# ),
# SwapObjectsTask(
# objects={
# "banana": [{"x": 1.0, "y": 2.0, "z": 3.0}],
# "apple": [{"x": 4.0, "y": 5.0, "z": 6.0}],
# },
# objects_to_swap=["banana", "apple"],
# ),
]
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
)

from rai_bench.examples.tool_calling_agent_bench_tasks import tasks

# from rai_bench.examples.tool_calling_agent_bench_navigation_tasks import tasks
from rai_bench.tool_calling_agent_bench.agent_bench import ToolCallingAgentBenchmark

if __name__ == "__main__":
Expand Down Expand Up @@ -60,7 +62,7 @@
tasks=tasks, logger=bench_logger, results_filename=results_filename
)

model_type = "simple_model"
model_type = "complex_model"
model_config = get_llm_model_config_and_vendor(model_type=model_type)[0]
model_name = getattr(model_config, model_type)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .action_base_model import ActionBaseModel
from .navigate_to_pose import NavigateToPoseAction
from .spin import SpinAction

__all__ = [
"ActionBaseModel",
"NavigateToPoseAction",
"SpinAction",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any

from pydantic import BaseModel


class ActionBaseModel(BaseModel):
action_name: str
action_type: str
goal: Any
result: Any
feedback: Any
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional

from pydantic import BaseModel

from rai_bench.tool_calling_agent_bench.actions.action_base_model import ActionBaseModel


class Time(BaseModel):
sec: Optional[int] = 0
nanosec: Optional[int] = 0


class Header(BaseModel):
stamp: Optional[Time] = Time()
frame_id: str


class Position(BaseModel):
x: float
y: float
z: float


class Orientation(BaseModel):
x: Optional[float] = 0.0
y: Optional[float] = 0.0
z: Optional[float] = 0.0
w: Optional[float] = 1.0


class Pose(BaseModel):
position: Position
orientation: Optional[Orientation] = Orientation()


class PoseStamped(BaseModel):
header: Header
pose: Pose


class Goal(BaseModel):
pose: PoseStamped
behavior_tree: Optional[str] = ""


class Result(BaseModel):
result: dict


class Feedback(BaseModel):
current_pose: PoseStamped
navigation_time: Time
estimated_time_remaining: Time
number_of_recoveries: int
distance_remaining: float


class NavigateToPoseAction(ActionBaseModel):
action_name: str = "/navigate_to_pose"
action_type: str = "nav2_msgs/action/NavigateToPose"
goal: Goal
result: Result
feedback: Feedback


# TODO (mkotynia): create init for actions
Loading
Loading