Skip to content
Merged
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
## Project Overview
`TurtleBot3 Agent` enables intuitive control of a TurtleBot3 robot using natural language. It interprets user instructions and uses tools to perform tasks such as moving, accessing sensor data, and navigating.

## TurtleBot3 Agent Demo
## TurtleBot3 Agent Demo in the Real World
##### Prompt used
> Please move to (2.0, 2.0). Then, check for any obstacles around you there. If you find an obstacle, show me an image and come back to your staring point.
> I want you to move in square. Each length should be 0.5 meters long.



https://github.com/user-attachments/assets/5eb21ea0-ab1f-4d9c-b051-ef4c97e58262


https://github.com/user-attachments/assets/c2d56318-65da-46f3-aa2e-d7952b805cc3




Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ numpy==1.26.4
opencv-python==4.11.0.86
pillow==9.0.1
pydantic==2.11.3
rclpy==3.3.16
transforms3d==0.4.2
transforms3d==0.4.2
cohere==5.15.0
18 changes: 3 additions & 15 deletions turtlebot3_agent/tools/all_tools.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
# from turtlebot3_agent.tools.api_tools import get_information_from_internet
from turtlebot3_agent.tools.motion_tools import (
make_navigate_to_pose_tool,
make_transform_odom_to_map_tool,
)

# from turtlebot3_agent.tools.navigation_tools import make_navigate_to_goal_tool
from turtlebot3_agent.tools.sensor_tools import (
make_get_lidar_scan_tool,
make_start_camera_display_tool,
)
from turtlebot3_agent.tools.motion_tools import make_move_linear_tool, make_rotate_tool
from turtlebot3_agent.tools.status_tools import make_get_turtle_pose_tool


Expand All @@ -23,9 +13,7 @@ def make_all_tools(node) -> list:
list: List of tools available to the agent
"""
return [
make_transform_odom_to_map_tool(node),
make_start_camera_display_tool(node),
make_navigate_to_pose_tool(node),
make_move_linear_tool(node),
make_rotate_tool(node),
make_get_turtle_pose_tool(node),
make_get_lidar_scan_tool(node),
]
52 changes: 0 additions & 52 deletions turtlebot3_agent/tools/motion_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,58 +132,6 @@ def inner(inputs: MoveCurveInput) -> str:
)


def make_navigate_to_pose_tool(node):
"""
Create a tool that uses Nav2 NavigateToPose action to navigate to a goal position.

Args:
node: The TB3Agent node instance

Returns:
StructuredTool: A LangChain tool for navigation
"""

class NavigateInput(BaseModel):
x: float = Field(description="Goal X coordinate in meters (map frame)")
y: float = Field(description="Goal Y coordinate in meters (map frame)")
yaw: float = Field(description="Goal yaw angle in radians")

def inner(inputs: NavigateInput) -> str:
success = node.navigate_to_pose(x=inputs.x, y=inputs.y, yaw=inputs.yaw)

if success:
if not node.wait_for_pose(timeout=0.5):
return "Navigation completed, but pose data not received yet."
else:
map_x, map_y, map_yaw = node.transform_odom_to_map(
odom_x=node.x, odom_y=node.y, odom_yaw=node.yaw
)
return (
f"Navigation completed successfully! "
f"You are now at position ({round(map_x, 2)}, {round(map_y, 2)}) in the map frame"
f"with a yaw angle of {round(map_yaw, 3)} radians."
)
else:
return "Navigation failed. The goal may be unreachable or the action server is not available."

return StructuredTool.from_function(
func=inner,
name="navigate_to_pose",
description="""
Navigate to a specific goal position using Nav2 path planning and obstacle avoidance.

Args:
- x (float): Goal X coordinate in meters (map frame)
- y (float): Goal Y coordinate in meters (map frame)
- yaw (float): Goal yaw angle in radians

This tool uses the Nav2 navigation stack to plan a path and navigate to the goal
while avoiding obstacles. It's more robust than direct movement commands for
navigating in complex environments with obstacles.
""",
)


def make_transform_odom_to_map_tool(node):
"""
Create a tool that transforms coordinates from odom frame to map frame.
Expand Down