forked from vincentzhang/gen3-mujoco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen3.py
63 lines (59 loc) · 2.23 KB
/
gen3.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
#!/usr/bin/env python3
"""
Displays Kinova Gen3 robotic arm with Robotiq gripper
"""
from mujoco_py import load_model_from_path, MjSim, MjViewer
# from mujoco_py.modder import TextureModder
import os
xml_path = "models/Gen3Robotiq.xml"
class gen3_env(object):
def __init__(self):
#super(lab_env, self).__init__(env)
# The real-world simulator
self.model = load_model_from_path(xml_path)
self.sim = MjSim(self.model)
self.viewer = MjViewer(self.sim)
def step(self):
self.sim.step()
self.viewer.render()
print(self.sim.data.qpos)
# self.sim.data.ctrl[:] = 0.0
for i in range(len(self.sim.data.qvel)):
self.sim.data.qvel[i] = 0.1
# self.sim.forward()
if __name__ == '__main__':
env = gen3_env()
t = 0
while True:
env.step()
t += 1
if t > 100 and os.getenv('TESTING') is not None:
# if t > 1000:
break
# env = create_env('Goal_LfD', None)
# angles, state, images = env.reset(0)
# print(state)
# state, images = env.step([0.2, -0.2, 0.4, -1])
#imshow(images[0])
#imshow(images[1])
# fig1 = env.sim.render(width = 960, height = 720, camera_name = 'workbench_camera')
# fig1 = env.sim.render(width = 960, height = 720, camera_name = 'workbench_camera')
# #imshow(fig1)
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# imshow(fig2)
# state, images = env.step([0.2, -0.2, 0.4, 1])
# print(state)
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# imshow(fig2)
# state, images = env.step([0.2, 0, -0.2, 1])
# print(state)
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# imshow(fig2)
# state, images = env.step([0.2, 0, -0.2, 0.9])
# print(state)
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# fig2 = env.sim.render(width = 960, height = 720, camera_name = 'upper_camera')
# imshow(fig2)