-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_from_json.py
65 lines (49 loc) · 1.58 KB
/
print_from_json.py
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
from compas_rrc import (
AbbClient,
MoveToFrame,
MoveToJoints,
SetDigital,
SetAcceleration,
SetMaxSpeed,
ExternalAxes,
Motion,
Zone,
Stop,
SetTool,
SetWorkObject,
PrintText,
RobotJoints,
)
from compas import json_load
from compas.geometry import Vector, Frame
from compas_fab.backends import RosClient
frames = json_load(
r"frames.json"
)
with RosClient() as ros:
client = AbbClient(ros)
client.send(SetAcceleration(100, 100))
client.send(SetMaxSpeed(100, 250))
client.send(SetTool("tool0"))
client.send(SetWorkObject("wobj1"))
client.send(PrintText("Press play to start"))
client.send(Stop())
client.send(PrintText("Moving to set start"))
start_pos = RobotJoints([0, 20, 20, 0, 30, 0])
client.send(MoveToJoints(start_pos, ExternalAxes(), 100, Zone.FINE))
client.send(PrintText("Press play to run"))
client.send(SetDigital("DO_1", 1))
client.send(Stop())
client.send(MoveToFrame(frames[0], 100, Zone.Z5))
client.send(SetDigital("DO_16", 1))
for frame in frames:
client.send(MoveToFrame(frame, 30, Zone.Z1, motion_type=Motion.LINEAR))
client.send(SetDigital("DO_16", 0))
client.send(SetDigital("DO_1", 0))
above_last_pt = frames[-1].point + Vector(0, 0, 100)
above_last_frame = Frame(
above_last_pt, xaxis=frames[-1].xaxis, yaxis=frames[-1].yaxis
)
client.send(MoveToFrame(above_last_frame, 30, Zone.Z5, motion_type=Motion.LINEAR))
client.send(MoveToJoints(start_pos, ExternalAxes(), 100, Zone.Z10))
client.send(PrintText("Done"))