MassageRobot_Dobot/Massage/test_manual.py
2025-05-29 16:47:49 +08:00

41 lines
1.1 KiB
Python
Executable File

import asyncio
import websockets
import json
# WebSocket 连接地址
WEBSOCKET_URL = "ws://localhost:8765"
async def websocket_client():
# 建立 WebSocket 连接
async with websockets.connect(WEBSOCKET_URL) as websocket:
print("Connected to WebSocket server.")
# # 发送初始化命令
# command_1 = "begin:finger:1:back_shoulder:0:manual"
# await websocket.send(command_1)
# print(f"Sent: {command_1}")
# 发送获取图片命令
# command_2 = "get_picture"
# await websocket.send(command_2)
# print(f"Sent: {command_2}")
# 发送带有 JSON 数据的 cal_acu 命令
# x1:y1:x2:y2:x3:y3:x4:y4:x5:y5
# command_3 = f"cal_acu:278:241:400:255:396:301:262:294:341:276"
# await websocket.send(command_3)
# print(f"Sent: {command_3}")
# command_4 = "stop"
# await websocket.send(command_4)
# print(f"Sent: {command_4}")
command_5 = "skip_queue"
await websocket.send(command_5)
print(f"Sent: {command_5}")
# 主入口
if __name__ == "__main__":
asyncio.run(websocket_client())