Skip to content
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

refactor: internal ros communication #335

Merged
merged 31 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c236a6f
fix(`GetTransform`): add missing `args_schema`
boczekbartek Dec 5, 2024
96e0a6c
refactor(`RaiNode`): executors and subscribers
boczekbartek Dec 5, 2024
6b7a2a9
improve logging of tool calls
boczekbartek Dec 5, 2024
6ced00c
remove RaiAsctionToolsNode
boczekbartek Dec 5, 2024
7d96e5e
refactor: executors and actions calling
boczekbartek Dec 5, 2024
2c2fc34
further refactoring of `RaiNode`
boczekbartek Dec 6, 2024
b933eb9
revert(`config.toml`):
boczekbartek Dec 19, 2024
003a55f
revert: executor to standard `rclpy.MultiThreadedExecutor`
boczekbartek Dec 19, 2024
40ebdcf
chore: remove unnecessary log
boczekbartek Dec 23, 2024
e6e347c
fix: import
boczekbartek Dec 23, 2024
bb35e0d
feat: add function to get rclpy.Future result using callback
boczekbartek Dec 24, 2024
bc5ed80
chore: add licence note
boczekbartek Dec 24, 2024
0224821
Update src/rai/rai/utils/ros.py
boczekbartek Jan 2, 2025
fd823c3
fix(`rosbot_xl_demo`): revert detection removal and fix it
boczekbartek Jan 7, 2025
399003a
improve ros discovery
boczekbartek Jan 7, 2025
c6e721c
Apply suggestions from code review
boczekbartek Jan 8, 2025
baa01f8
fix(`GetTransformTool`): make default values consistent
boczekbartek Jan 8, 2025
92fca44
fix(`NodeDiscovery`): repeated argument setting
boczekbartek Jan 8, 2025
81a98a8
refactor: ros2 action error code parsing
boczekbartek Jan 8, 2025
c14114c
fix deprecated way of spinning the node in open-set vision
boczekbartek Jan 8, 2025
ab3a7b3
get transform synchronously
boczekbartek Jan 8, 2025
c36f1ac
rollback to fixed executor
boczekbartek Jan 8, 2025
89663ef
add missing executor file
boczekbartek Jan 8, 2025
0c06db3
fix(`text_hmi`): `TaskAction` attribute is named `report`
boczekbartek Jan 8, 2025
d881e17
chore: add missing licence header
boczekbartek Jan 8, 2025
bf40cec
avoid spinning the node in open-set vision tools
boczekbartek Jan 9, 2025
a877f7f
chore: pre-commit
boczekbartek Jan 10, 2025
e65dde9
test(`transport`): spin RaiBaseNode in test
boczekbartek Jan 10, 2025
13935b9
don't shutdown rclpy in rai node
boczekbartek Jan 10, 2025
91b0401
rename Ros2*Helper to Ros2*Api and move to a separate file
boczekbartek Jan 14, 2025
0943f26
add copyright notice
boczekbartek Jan 14, 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
15 changes: 9 additions & 6 deletions examples/rosbot-xl-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@

from rai.node import RaiStateBasedLlmNode
from rai.tools.ros.native import (
GetCameraImage,
GetMsgFromTopic,
Ros2GetRobotInterfaces,
Ros2PubMessageTool,
Ros2ShowMsgInterfaceTool,
)
from rai.tools.ros.native_actions import (
GetTransformTool,
Ros2CancelAction,
Ros2GetActionResult,
Ros2GetLastActionFeedback,
Ros2IsActionComplete,
Ros2RunActionAsync,
)
from rai.tools.ros.tools import GetCurrentPositionTool
from rai.tools.time import WaitForSecondsTool

p = argparse.ArgumentParser()
Expand Down Expand Up @@ -62,11 +61,14 @@ def main(allowlist: Optional[Path] = None):
rclpy.logging.get_logger("rosbot_xl_demo").error(
f"Failed to read allowlist: {e}"
)
else:
ros2_allowlist = None

SYSTEM_PROMPT = """You are an autonomous robot connected to ros2 environment. Your main goal is to fulfill the user's requests.
Do not make assumptions about the environment you are currently in.
You can use ros2 topics, services and actions to operate.

<rule> As a first step check transforms by getting 1 message from /tf topic </rule>
<rule> use /cmd_vel topic very carefully. Obstacle detection works only with nav2 stack, so be careful when it is not used. </rule>>
<rule> be patient with running ros2 actions. usually the take some time to run. </rule>
<rule> Always check your transform before and after you perform ros2 actions, so that you can verify if it worked. </rule>
Expand All @@ -88,6 +90,7 @@ def main(allowlist: Optional[Path] = None):
- to find some object navigate around and check the surrounding area
- when the goal is accomplished please make sure to cancel running actions
- when you reach the navigation goal - double check if you reached it by checking the current position
- if you detect collision, please stop operation

- you will be given your camera image description. Based on this information you can reason about positions of objects.
- be careful and aboid obstacles
Expand Down Expand Up @@ -118,21 +121,21 @@ def main(allowlist: Optional[Path] = None):
allowlist=ros2_allowlist,
system_prompt=SYSTEM_PROMPT,
tools=[
Ros2GetRobotInterfaces,
Ros2PubMessageTool,
Ros2RunActionAsync,
Ros2IsActionComplete,
Ros2CancelAction,
Ros2GetActionResult,
Ros2GetLastActionFeedback,
Ros2ShowMsgInterfaceTool,
GetCurrentPositionTool,
GetTransformTool,
WaitForSecondsTool,
GetMsgFromTopic,
GetCameraImage,
GetDetectionTool,
GetDistanceToObjectsTool,
],
)
node.declare_parameter("conversion_ratio", 1.0)

node.spin()
rclpy.shutdown()
Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/agents/tool_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _func(self, input: dict[str, Any], config: RunnableConfig) -> Any:
raise ValueError("Last message is not an AIMessage")

def run_one(call: ToolCall):
self.logger.info(f"Running tool: {call['name']}")
self.logger.info(f"Running tool: {call['name']}, args: {call['args']}")
artifact = None

try:
Expand Down
Loading