Skip to content

Commit 57c5380

Browse files
committed
feat: husarion the descriptor wip
1 parent e60f086 commit 57c5380

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

examples/explore_and_describe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ def main():
7979
SystemMessage(
8080
content="You are an autonomous agent. Your main goal is to fulfill the user's requests. "
8181
"Do not make assumptions about the environment you are currently in. "
82-
"Use the tooling provided to gather information about the environment."
82+
"Use the tooling provided to gather information about the environment. Remember to list available topics. "
8383
),
8484
HumanMultimodalMessage(
8585
content="Describe your surroundings and gather more information as needed. "
8686
"Move to explore further, aiming for clear areas near the robot (red arrow). Make sure to describe the area during movement."
8787
"Utilize available methods to obtain the map and identify relevant data streams. "
88-
"Before starting the exploration, find out what kind of tooling is available and based on that plan your exploration."
88+
"Before starting the exploration, find out what kind of tooling is available and based on that plan your exploration. For description, use the available tooling."
8989
),
90-
AgentLoop(stop_action=FinishTool().__class__.__name__, stop_iters=10),
90+
AgentLoop(stop_action=FinishTool().__class__.__name__, stop_iters=50),
9191
]
9292

93-
llm = ChatBedrock(model_id="anthropic.claude-3-5-sonnet-20240620-v1:0", region_name="us-west-2") # type: ignore
93+
llm = ChatBedrock(model_id="anthropic.claude-3-5-sonnet-20240620-v1:0", region_name="us-east-1") # type: ignore
9494
runner = ScenarioRunner(scenario, llm=llm, tools=tools, llm_type="bedrock")
9595
runner.run()
9696
runner.save_to_html()

src/rai/communication/ros_communication.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
import rclpy
88
import rclpy.qos
99
from cv_bridge import CvBridge
10+
from rclpy.duration import Duration
1011
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
1112
from rclpy.node import Node
12-
from rclpy.qos import QoSProfile
13+
from rclpy.qos import (
14+
QoSDurabilityPolicy,
15+
QoSHistoryPolicy,
16+
QoSLivelinessPolicy,
17+
QoSProfile,
18+
QoSReliabilityPolicy,
19+
)
1320
from rclpy.signals import SignalHandlerGuardCondition
1421
from rclpy.utilities import timeout_sec_to_nsec
1522
from sensor_msgs.msg import Image
@@ -92,7 +99,16 @@ def grab_message(self) -> Any:
9299

93100
node = rclpy.create_node(self.__class__.__name__ + "_node") # type: ignore
94101
qos_profile = rclpy.qos.qos_profile_sensor_data
95-
102+
if self.topic == "/map":
103+
qos_profile = QoSProfile(
104+
reliability=QoSReliabilityPolicy.RELIABLE,
105+
history=QoSHistoryPolicy.KEEP_ALL,
106+
durability=QoSDurabilityPolicy.TRANSIENT_LOCAL,
107+
lifespan=Duration(seconds=0),
108+
deadline=Duration(seconds=0),
109+
liveliness=QoSLivelinessPolicy.AUTOMATIC,
110+
liveliness_lease_duration=Duration(seconds=0),
111+
)
96112
success, msg = wait_for_message(
97113
self.message_type,
98114
node,

src/rai/scenario_engine/scenario_engine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ def _run(self, scenario: ScenarioType):
151151
f"Looping agent actions until {msg.stop_action}. Max {msg.stop_iters} loops."
152152
)
153153
for _ in range(msg.stop_iters):
154+
if self.history[-1].type == "ai":
155+
self.history.append(
156+
HumanMessage(
157+
content="Thank you. Please continue your mision with tools."
158+
)
159+
)
154160
ai_msg = cast(
155161
AIMessage,
156162
self.llm_with_tools.invoke(

src/rai/tools/ros/cli_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Ros2TopicTool(BaseTool):
4343
def _run(self, command: str):
4444
"""Executes the specified ROS2 topic command."""
4545
result = subprocess.run(
46-
f"ros2 topic {command}", shell=True, capture_output=True
46+
f"ros2 topic {command} -v", shell=True, capture_output=True
4747
)
4848
return result
4949

@@ -139,9 +139,9 @@ class SetGoalPoseTool(BaseTool):
139139
def _run(self, topic: str, x: float, y: float):
140140
"""Sets the goal pose for the robot."""
141141

142-
cmd = (
142+
_ = (
143143
f"ros2 topic pub {topic} geometry_msgs/PoseStamped "
144144
f'\'{{header: {{stamp: {{sec: 0, nanosec: 0}}, frame_id: "map"}}, '
145145
f"pose: {{position: {{x: {x}, y: {y}, z: {0.0}}}}}}}' --once"
146146
)
147-
return subprocess.run(cmd, shell=True)
147+
return "done" # subprocess.run(cmd, shell=True)

src/rai/tools/ros/tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class GetOccupancyGridTool(BaseTool):
103103

104104
name: str = "GetOccupancyGridTool"
105105
description: str = (
106-
"A tool for getting the current map as an image with the robot's position marked on it."
106+
"A tool for getting the current map as an image with the robot's position marked on it. The coordinates are written at the edges of the image. Make sure to read them correctly if you are planning on using the coordinates to set a new goal pose."
107107
)
108108

109109
args_schema: Type[GetOccupancyGridToolInput] = GetOccupancyGridToolInput
@@ -119,7 +119,7 @@ def _postprocess_msg(self, map_msg: OccupancyGrid, transform: TransformStamped):
119119

120120
# Convert the OccupancyGrid values to grayscale image (0-255)
121121
# the final image shape should be at most (1000x1000), scale to fit
122-
scale = 1000 / max(width, height)
122+
scale = 1500 / max(width, height)
123123
width = int(width * scale)
124124
height = int(height * scale)
125125
data = cv2.resize(data, (width, height), interpolation=cv2.INTER_NEAREST)
@@ -164,7 +164,7 @@ def _postprocess_msg(self, map_msg: OccupancyGrid, transform: TransformStamped):
164164
)
165165

166166
robot_y = cast(
167-
float, (transform.transform.translation.y - origin_position.y / resolution)
167+
float, (transform.transform.translation.y - origin_position.y) / resolution
168168
)
169169

170170
_, _, yaw = euler_from_quaternion(
@@ -193,7 +193,7 @@ def _postprocess_msg(self, map_msg: OccupancyGrid, transform: TransformStamped):
193193
transform.transform.rotation.w, # type: ignore
194194
]
195195
)
196-
arrow_length = 10
196+
arrow_length = 20
197197
arrow_end_x = int(robot_x + arrow_length * np.cos(yaw))
198198
arrow_end_y = int(robot_y + arrow_length * np.sin(yaw))
199199
cv2.arrowedLine(

0 commit comments

Comments
 (0)