diff --git a/README.md b/README.md index 9d8e4d1..de6e113 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/requirements.txt b/requirements.txt index 7341ac2..4fc9cba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +transforms3d==0.4.2 +cohere==5.15.0 \ No newline at end of file diff --git a/turtlebot3_agent/tools/all_tools.py b/turtlebot3_agent/tools/all_tools.py index 51f20df..8e5adc2 100644 --- a/turtlebot3_agent/tools/all_tools.py +++ b/turtlebot3_agent/tools/all_tools.py @@ -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 @@ -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), ] diff --git a/turtlebot3_agent/tools/motion_tools.py b/turtlebot3_agent/tools/motion_tools.py index f5bdca7..b181a6b 100644 --- a/turtlebot3_agent/tools/motion_tools.py +++ b/turtlebot3_agent/tools/motion_tools.py @@ -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.