Skip to content

Commit 5ee8e5e

Browse files
committed
Remove command controls - they interrupt the agents state machine
1 parent 2972a43 commit 5ee8e5e

File tree

4 files changed

+15
-324
lines changed

4 files changed

+15
-324
lines changed

coffee_ws/src/coffee_voice_agent/coffee_voice_agent/voice_agent_bridge.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ def __init__(self):
112112
callback_group=self.callback_group
113113
)
114114

115-
self.command_sub = self.create_subscription(
116-
String,
117-
'voice_agent/commands',
118-
self.handle_command,
119-
10,
120-
callback_group=self.callback_group
121-
)
122-
123115
# Start WebSocket connection in separate thread
124116
self.websocket_thread = threading.Thread(target=self._run_websocket_client, daemon=True)
125117
self.websocket_thread.start()
@@ -323,36 +315,6 @@ def handle_virtual_request(self, msg: String):
323315
except Exception as e:
324316
self.get_logger().error(f"Error handling virtual request: {e}")
325317

326-
def handle_command(self, msg: String):
327-
"""Handle command from ROS2 and forward to voice agent"""
328-
try:
329-
# Parse the command
330-
command_data = json.loads(msg.data)
331-
332-
# Format for voice agent
333-
command = {
334-
'type': 'COMMAND',
335-
'action': command_data.get('action'),
336-
'parameters': command_data.get('parameters', {}),
337-
'timestamp': command_data.get('timestamp')
338-
}
339-
340-
# Send to voice agent
341-
if self.websocket_loop and not self.websocket_loop.is_closed():
342-
asyncio.run_coroutine_threadsafe(
343-
self._send_to_voice_agent(command),
344-
self.websocket_loop
345-
)
346-
else:
347-
self.get_logger().warn("Cannot send command - WebSocket event loop not available")
348-
349-
self.get_logger().info(f"Forwarded command: {command_data.get('action')}")
350-
351-
except json.JSONDecodeError as e:
352-
self.get_logger().error(f"Invalid JSON in command: {e}")
353-
except Exception as e:
354-
self.get_logger().error(f"Error handling command: {e}")
355-
356318
async def _send_to_voice_agent(self, data: dict):
357319
"""Send data to voice agent via WebSocket"""
358320
if self.websocket and self.connection_active:

coffee_ws/src/coffee_voice_agent_ui/coffee_voice_agent_ui/voice_agent_monitor.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,13 @@ def __init__(self):
7373
10
7474
)
7575

76-
# Publishers for sending commands
76+
# Publisher for sending virtual requests
7777
self.virtual_request_pub = self.create_publisher(
7878
String,
7979
'voice_agent/virtual_requests',
8080
10
8181
)
8282

83-
self.command_pub = self.create_publisher(
84-
String,
85-
'voice_agent/commands',
86-
10
87-
)
88-
8983
self.get_logger().info("Voice Agent Monitor Node initialized")
9084

9185
def status_callback(self, msg):
@@ -179,7 +173,6 @@ def _init_ros(self):
179173

180174
# Connect control widget signals to publishers
181175
self.controls_widget.virtual_request_signal.connect(self._send_virtual_request)
182-
self.controls_widget.command_signal.connect(self._send_command)
183176

184177
# Start ROS spinning in separate thread
185178
self.ros_executor = MultiThreadedExecutor()
@@ -320,14 +313,6 @@ def _send_virtual_request(self, request_json):
320313
msg.data = request_json
321314
self.ros_node.virtual_request_pub.publish(msg)
322315

323-
@pyqtSlot(str)
324-
def _send_command(self, command_json):
325-
"""Send command through ROS2"""
326-
if self.ros_node:
327-
msg = String()
328-
msg.data = command_json
329-
self.ros_node.command_pub.publish(msg)
330-
331316
def _periodic_update(self):
332317
"""Periodic UI updates for real-time elements"""
333318
# Update conversation widget timestamps

coffee_ws/src/coffee_voice_agent_ui/coffee_voice_agent_ui/voice_agent_monitor_app.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,13 @@ def __init__(self, ros_bridge):
110110
10
111111
)
112112

113-
# Publishers for sending commands
113+
# Publisher for sending virtual requests
114114
self.virtual_request_pub = self.create_publisher(
115115
String,
116116
'voice_agent/virtual_requests',
117117
10
118118
)
119119

120-
self.command_pub = self.create_publisher(
121-
String,
122-
'voice_agent/commands',
123-
10
124-
)
125-
126120
self.get_logger().info("Voice Agent Monitor Node initialized")
127121

128122
def status_callback(self, msg):
@@ -235,7 +229,6 @@ def _init_ros(self):
235229

236230
# Connect control widget signals to publishers
237231
self.controls_widget.virtual_request_signal.connect(self._send_virtual_request)
238-
self.controls_widget.command_signal.connect(self._send_command)
239232

240233
# Start ROS spinning in separate thread
241234
self.ros_executor = MultiThreadedExecutor()
@@ -303,14 +296,6 @@ def _send_virtual_request(self, request_json):
303296
msg.data = request_json
304297
self.ros_node.virtual_request_pub.publish(msg)
305298

306-
@pyqtSlot(str)
307-
def _send_command(self, command_json):
308-
"""Send command through ROS2"""
309-
if self.ros_node:
310-
msg = String()
311-
msg.data = command_json
312-
self.ros_node.command_pub.publish(msg)
313-
314299
def _periodic_update(self):
315300
"""Periodic UI updates for real-time elements"""
316301
# Update conversation widget timestamps

0 commit comments

Comments
 (0)