async gripper command sender
This commit is contained in:
parent
2165c48415
commit
d506f35cf4
1 changed files with 7 additions and 0 deletions
7
node.py
7
node.py
|
@ -7,6 +7,7 @@ from sensor_msgs.msg import JointState
|
||||||
from utils import RobotClient
|
from utils import RobotClient
|
||||||
import time
|
import time
|
||||||
from main import config, HOST, PORT
|
from main import config, HOST, PORT
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
class RobotControllerNode(Node):
|
class RobotControllerNode(Node):
|
||||||
|
@ -39,6 +40,12 @@ class RobotControllerNode(Node):
|
||||||
self.last_js = msg
|
self.last_js = msg
|
||||||
|
|
||||||
def send_gripper_command(self, target_pose: float, tolerance: float = 0.01, timeout: float = 3.0):
|
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 = Float64MultiArray()
|
||||||
msg.data = [target_pose]
|
msg.data = [target_pose]
|
||||||
self.pub.publish(msg)
|
self.pub.publish(msg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue