From 4daeb0fd6fc35973ed23f5276c1e38817f957639 Mon Sep 17 00:00:00 2001 From: lesh Date: Sat, 31 May 2025 18:54:11 +0300 Subject: [PATCH] move threading fix --- dimos/robot/unitree_webrtc/connection.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dimos/robot/unitree_webrtc/connection.py b/dimos/robot/unitree_webrtc/connection.py index 7b9595b696..dd1359a68b 100644 --- a/dimos/robot/unitree_webrtc/connection.py +++ b/dimos/robot/unitree_webrtc/connection.py @@ -61,10 +61,17 @@ def start_background_loop(): self.connection_ready.wait() def move(self, vector: Vector): - self.conn.datachannel.pub_sub.publish_without_callback( - RTC_TOPIC["WIRELESS_CONTROLLER"], - data={"lx": vector.x, "ly": vector.y, "rx": vector.z, "ry": 0}, - ) + # x - Positive right, negative left + # y - positive forward, negative backwards + # z - Positive rotate right, negative rotate left + async def async_move(): + self.conn.datachannel.pub_sub.publish_without_callback( + RTC_TOPIC["WIRELESS_CONTROLLER"], + data={"lx": vector.x, "ly": vector.y, "rx": vector.z, "ry": 0}, + ) + + future = asyncio.run_coroutine_threadsafe(async_move(), self.loop) + return future.result() # Generic conversion of unitree subscription to Subject (used for all subs) def unitree_sub_stream(self, topic_name: str):