-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgeltip_world.py
More file actions
166 lines (143 loc) · 5.33 KB
/
geltip_world.py
File metadata and controls
166 lines (143 loc) · 5.33 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from yarok import Platform, PlatformMJC, PlatformHW, component, ConfigBlock, Injector
from yarok.comm.worlds.empty_world import EmptyWorld
from yarok.comm.components.robotiq_2f85.robotiq_2f85 import Robotiq2f85
from yarok.comm.components.geltip.geltip import GelTip
from yarok.comm.components.ur5e.ur5e import UR5e
from yarok.comm.components.cam.cam import Cam
from yarok.comm.plugins.cv2_inspector import Cv2Inspector
from yarok.comm.plugins.cv2_waitkey import Cv2WaitKey
from math import pi
import cv2
@component(
extends=EmptyWorld,
components=[
UR5e,
Robotiq2f85,
GelTip,
Cam
],
# language=xml
template="""
<mujoco>
<default>
<default class='marker'>
<geom type="box"
size="0.02 0.02 0.001"
conaffinity='32'
contype='32'/>
</default>
</default>
<worldbody>
<body pos="0.5 0.5 0.4">
<composite type="grid" count="30 1 1" spacing="0.009" offset="0 0 1">
<!-- <skin material="matplane" inflate="0.001" subgrid="3" texcoord="true"/> -->
<joint kind="main" damping="0.001" frictionloss='0.0001'/>
<tendon kind="main" width="0.019" rgba=".8 .2 .1 1"/>
<geom size=".018" rgba=".8 .2 .1 1" mass='0.0001'
friction='0.1 0.005 0.0001'/><!--
-->
<!-- <pin coord="1"/> -->
<!-- <pin coord="39"/> -->
</composite>
</body>
<body>
<geom type="box" size="1.0 1.0 0.05" pos="0 0 0.45"/>
<geom class="marker" pos="0.7 0.7 0.5" rgba='255 0 0 1'/>
<geom class="marker" pos="0.1 0.7 0.5" rgba='0 255 0 1'/>
<geom class="marker" pos="0.1 0.3 0.5" rgba='0 0 255 1'/>
<geom class="marker" pos="0.7 0.3 0.5" rgba='255 0 255 1'/>
<!-- <geom type="box" size=".025 .025 1.0" pos="1.0 1.0 1.0"/> -->
</body>
<body pos='0.9 0.9 1' euler='1.6 2.35619449019 0'>
<body euler='2.35619449019 0 3.14159265359'>
<cam name='vis_cam'/>
</body>
</body>
<body pos='0 0 0.5' xyaxes='0 1 0 -1 0 0'>
<ur5e name="arm">
<robotiq-2f85 name="gripper" parent="ee_link">
<body pos="0.02 -0.017 0.053" xyaxes="0 -1 0 1 0 0" parent="right_tip">
<geltip name="right_geltip" parent="left_tip"/>
</body>
<body pos="-0.02 -0.017 0.053" xyaxes="0 1 0 -1 0 0" parent="left_tip">
<geltip name="left_geltip" parent="right_tip"/>
</body>
</robotiq-2f85>
</ur5e>
</body>
</worldbody>
</mujoco>
"""
)
class GraspRopeWorld:
pass
class GraspRoleBehaviour:
def __init__(self, pl: Platform, injector: Injector):
self.arm: UR5e = injector.get('arm')
self.gripper: Robotiq2f85 = injector.get('gripper')
self.pl = pl
def on_update(self):
# self.pl.wait_seconds(60)
# print('------------------------------------------------------------------------------------------->')
self.gripper.close(0.5)
self.pl.wait(
self.arm.move_xyz(xyz=[0.45, 0.5, 0.2], xyz_angles=[3.11, -1.6e-7, -pi / 2])
)
self.pl.wait(
self.arm.move_xyz(xyz=[0.45, 0.5, 0.17], xyz_angles=[3.11, -1.6e-7, -pi / 2])
)
self.pl.wait_seconds(2)
self.pl.wait(
self.gripper.close(0.75)
)
self.pl.wait_seconds(10)
print('closed gripper')
self.pl.wait(
self.arm.move_xyz(xyz=[0.45, 0.5, 0.4], xyz_angles=[3.11, -1.6e-7, -pi / 2])
)
self.pl.wait(
self.arm.move_xyz(xyz=[0.45, 0.2, 0.4], xyz_angles=[3.11, -1.6e-7, -pi / 2])
)
self.pl.wait(
self.arm.move_xyz(xyz=[0.45, 0.2, 0.25], xyz_angles=[3.11, -1.6e-7, -pi / 2])
)
self.pl.wait(
self.gripper.close(0.5)
)
print('ended.')
self.pl.wait_seconds(100)
conf = {
'world': GraspRopeWorld,
'behaviour': GraspRoleBehaviour,
'defaults': {
'environment': 'sim',
'behaviour': {
},
'components': {
'/gripper': {
'left_tip': False,
'right_tip': False,
},
'/right_geltip': {
'label_color': '255 0 0'
},
'/left_geltip': {
'label_color': '0 255 0'
},
},
},
'environments': {
'sim': {
'platform': {
'class': PlatformMJC,
'width': 800,
'height': 600
},
'plugins': [
(Cv2Inspector, {})
]
}
},
}
if __name__ == '__main__':
Platform.create(conf).run()