-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_test.py
More file actions
71 lines (56 loc) · 1.9 KB
/
agent_test.py
File metadata and controls
71 lines (56 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# examples/agent_test.py
# Test hiring a robot using the Python RTPClient
import asyncio
import os
from dotenv import load_dotenv
load_dotenv()
from rtp import RTPClient
async def main():
client = RTPClient(
wallet=os.getenv("WALLET_ADDRESS"),
gateway_url="https://gateway.spraay.app"
)
print("\n💧 RTP Agent Test (Python)\n" + "─" * 40)
# Discover robots
print("🔍 Discovering robots with 'pick' capability...")
robots = await client.discover(capability="pick")
if not robots:
print("❌ No robots found")
return
robot = robots[0]
print(f"✅ Found: {robot['name']} ({robot['robot_id']})")
print(f"💰 Price: {robot['price_per_task']} USDC\n")
# Run test sequence
tasks = [
("pick", {"item": "SKU-001", "from_location": "bin_A1"}),
("scan", {"target": "barcode"}),
("place", {"to_location": "conveyor_1"}),
("move", {"angle": 45}),
("move", {"angle": 90}),
]
passed = 0
failed = 0
for task_name, params in tasks:
print(f"▶️ Testing: {task_name}")
try:
result = await client.hire(
robot,
task=task_name,
parameters=params,
timeout_seconds=15
)
if result["status"] == "COMPLETED":
print(f"✅ {task_name} PASSED — {result['result']['output']}")
passed += 1
else:
print(f"❌ {task_name} FAILED — {result['result'].get('error')}")
failed += 1
except Exception as e:
print(f"❌ {task_name} ERROR — {e}")
failed += 1
await asyncio.sleep(1)
print(f"\n📊 Results: {passed} passed, {failed} failed")
if failed == 0:
print("🎉 All tasks completed — robot is RTP ready!\n")
if __name__ == "__main__":
asyncio.run(main())