2026-02-03 13:36:52 +08:00
|
|
|
from clients._path_setup import ensure_paths
|
|
|
|
|
|
|
|
|
|
ensure_paths()
|
2025-11-13 03:01:00 +08:00
|
|
|
|
2026-02-03 13:36:52 +08:00
|
|
|
from google.protobuf import timestamp_pb2
|
2025-11-13 03:01:00 +08:00
|
|
|
|
|
|
|
|
from clients.base_client import RobotClientBase
|
2026-02-03 13:36:52 +08:00
|
|
|
from cmvr.api import common_pb2
|
2026-06-24 15:49:54 +08:00
|
|
|
from cmvr.api import arm_command_pb2 as pb
|
|
|
|
|
from cmvr.api import arm_service_pb2_grpc as rpc
|
2025-11-13 03:01:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TorqueOnClient(RobotClientBase):
|
|
|
|
|
"""发送 TorqueOn 指令客户端"""
|
|
|
|
|
|
2026-06-24 15:49:54 +08:00
|
|
|
def send(self, device_id="right_arm"):
|
2025-11-13 03:01:00 +08:00
|
|
|
# 构造请求头
|
|
|
|
|
req = common_pb2.CommandHeader.Request()
|
|
|
|
|
req.device_id = device_id
|
|
|
|
|
ts = timestamp_pb2.Timestamp()
|
|
|
|
|
ts.GetCurrentTime()
|
|
|
|
|
req.timestamp.CopyFrom(ts)
|
|
|
|
|
|
|
|
|
|
# 调用 RPC
|
|
|
|
|
try:
|
|
|
|
|
resp = self.stub.torqueOn(req, timeout=10)
|
|
|
|
|
print("✅ TorqueOn RPC 调用成功")
|
|
|
|
|
print(f"Success: {resp.success}")
|
|
|
|
|
print(f"Error message: {resp.error_message}")
|
|
|
|
|
print(f"Timestamp: {resp.timestamp.seconds}")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("❌ TorqueOn RPC 调用失败:", e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
# 初始化客户端
|
|
|
|
|
client = TorqueOnClient()
|
|
|
|
|
|
|
|
|
|
# 发送 TorqueOn 指令
|
2026-06-24 15:49:54 +08:00
|
|
|
client.send(device_id="right_arm")
|
2025-11-13 03:01:00 +08:00
|
|
|
|
|
|
|
|
# 关闭客户端
|
|
|
|
|
client.close()
|