forked from fri-robotlearning-spring2021/Homework-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_env.py
More file actions
37 lines (28 loc) · 949 Bytes
/
my_env.py
File metadata and controls
37 lines (28 loc) · 949 Bytes
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
from robosuite.models import MujocoWorldBase
from robosuite.models.robots import Panda
from robosuite.models.grippers import gripper_factory
from robosuite.models.objects import BallObject
from robosuite.utils.mjcf_utils import new_joint
from mujoco_py import MjSim, MjViewer
world = MujocoWorldBase()
mujoco_robot = Panda()
gripper = gripper_factory('PandaGripper')
gripper.hide_visualization()
mujoco_robot.add_gripper(gripper)
mujoco_robot.set_base_xpos([0, 0, 0])
world.merge(mujoco_robot)
sphere = BallObject(
name="sphere",
size=[0.04],
rgba=[0, 0.5, 0.5, 1]).get_collision()
sphere.append(new_joint(name='sphere_free_joint', type='free'))
sphere.set('pos', '1.0 0 1.0')
world.worldbody.append(sphere)
model = world.get_model(mode="mujoco_py")
sim = MjSim(model)
viewer = MjViewer(sim)
viewer.vopt.geomgroup[0] = 0 # disable visualization of collision mesh
for i in range(10000):
sim.data.ctrl[:] = 0
sim.step()
viewer.render()