diff --git a/node.py b/node.py index cbfa356..6c36ab9 100644 --- a/node.py +++ b/node.py @@ -7,6 +7,7 @@ from sensor_msgs.msg import JointState from utils import RobotClient import time from main import config, HOST, PORT +import asyncio class RobotControllerNode(Node): @@ -39,6 +40,12 @@ class RobotControllerNode(Node): self.last_js = msg def send_gripper_command(self, target_pose: float, tolerance: float = 0.01, timeout: float = 3.0): + # Создаем и запускаем асинхронную задачу + return asyncio.get_event_loop().run_until_complete( + self.send_gripper_command_async(target_pose, tolerance, timeout) + ) + + async def send_gripper_command_async(self, target_pose: float, tolerance: float = 0.01, timeout: float = 3.0): msg = Float64MultiArray() msg.data = [target_pose] self.pub.publish(msg)