本文整理匯總了Python中pybullet.loadMJCF方法的典型用法代碼示例。如果您正苦於以下問題:Python pybullet.loadMJCF方法的具體用法?Python pybullet.loadMJCF怎麽用?Python pybullet.loadMJCF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybullet
的用法示例。
在下文中一共展示了pybullet.loadMJCF方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _reset
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def _reset(self):
if self.scene is None:
self.scene = self.create_single_player_scene()
if not self.scene.multiplayer:
self.scene.episode_restart()
self.ordered_joints = []
self.frame = 0
self.done = 0
self.reward = 0
dump = 0
if self.self_collision:
self.parts, self.jdict, self.ordered_joints, self.robot_body = self.addToScene(p.loadMJCF(os.path.join(os.path.dirname(__file__), "mujoco_assets", self.model_xml), flags = p.URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS))
else:
self.parts, self.jdict, self.ordered_joints, self.robot_body = self.addToScene(p.loadMJCF(os.path.join(os.path.dirname(__file__), "mujoco_assets", self.model_xml)))
self.robot_specific_reset()
s = self.calc_state() # optimization: calc_state() can calculate something in self.* for calc_potential() to use
self.potential = self.calc_potential()
return s
示例2: __init__
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def __init__(self, model_xml, robot_name, timestep, frame_skip, action_dim, obs_dim, repeats):
self.action_space = gym.spaces.Box(-1.0, 1.0, shape=(action_dim,))
float_max = np.finfo(np.float32).max
# obs space for problem is (R, obs_dim)
# R = number of repeats
# obs_dim d tuple
self.state_shape = (repeats, obs_dim)
self.observation_space = gym.spaces.Box(-float_max, float_max, shape=self.state_shape)
# no state until reset.
self.state = np.empty(self.state_shape, dtype=np.float32)
self.frame_skip = frame_skip
self.timestep = timestep
self.model_xml = model_xml
self.parts, self.joints, = self.getScene(p.loadMJCF(model_xml))
self.robot_name = robot_name
self.dt = timestep * frame_skip
self.metadata = {
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second': int(np.round(1.0 / timestep / frame_skip))
}
self._seed()
示例3: test
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def test(args):
p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
fileName = os.path.join("mjcf", args.mjcf)
print("fileName")
print(fileName)
p.loadMJCF(fileName)
while (1):
p.stepSimulation()
p.getCameraImage(320,240)
time.sleep(0.01)
示例4: robot_specific_reset
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def robot_specific_reset(self):
WalkerBase.robot_specific_reset(self)
humanoidId = -1
numBodies = p.getNumBodies()
for i in range (numBodies):
bodyInfo = p.getBodyInfo(i)
if bodyInfo[1].decode("ascii") == 'humanoid':
humanoidId = i
## Spherical radiance/glass shield to protect the robot's camera
if self.glass_id is None:
glass_id = p.loadMJCF(os.path.join(self.physics_model_dir, "glass.xml"))[0]
#print("setting up glass", glass_id, humanoidId)
p.changeVisualShape(glass_id, -1, rgbaColor=[0, 0, 0, 0])
cid = p.createConstraint(humanoidId, -1, glass_id,-1,p.JOINT_FIXED,[0,0,0],[0,0,1.4],[0,0,1])
self.motor_names = ["abdomen_z", "abdomen_y", "abdomen_x"]
self.motor_power = [100, 100, 100]
self.motor_names += ["right_hip_x", "right_hip_z", "right_hip_y", "right_knee"]
self.motor_power += [100, 100, 300, 200]
self.motor_names += ["left_hip_x", "left_hip_z", "left_hip_y", "left_knee"]
self.motor_power += [100, 100, 300, 200]
self.motor_names += ["right_shoulder1", "right_shoulder2", "right_elbow"]
self.motor_power += [75, 75, 75]
self.motor_names += ["left_shoulder1", "left_shoulder2", "left_elbow"]
self.motor_power += [75, 75, 75]
self.motors = [self.jdict[n] for n in self.motor_names]
示例5: _load_model
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def _load_model(self):
if self.model_type == "MJCF":
self.robot_ids = p.loadMJCF(os.path.join(self.physics_model_dir, self.model_file), flags=p.URDF_USE_SELF_COLLISION+p.URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS)
if self.model_type == "URDF":
self.robot_ids = (p.loadURDF(os.path.join(self.physics_model_dir, self.model_file), globalScaling = self.scale), )
self.parts, self.jdict, self.ordered_joints, self.robot_body = self.addToScene(self.robot_ids)
示例6: __init__
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def __init__(self, robot, gravity, timestep, frame_skip, env=None):
Scene.__init__(self, gravity, timestep, frame_skip, env)
filename = os.path.join(pybullet_data.getDataPath(), "stadium_no_collision.sdf")
self.stadium = p.loadSDF(filename)
planeName = os.path.join(pybullet_data.getDataPath(), "mjcf/ground_plane.xml")
self.ground_plane_mjcf = p.loadMJCF(planeName)
for i in self.ground_plane_mjcf:
pos, orn = p.getBasePositionAndOrientation(i)
p.resetBasePositionAndOrientation(i, [pos[0], pos[1], pos[2] - 0.005], orn)
for i in self.ground_plane_mjcf:
p.changeVisualShape(i, -1, rgbaColor=[1, 1, 1, 0.5])
self.scene_obj_list = self.stadium
示例7: episode_restart
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def episode_restart(self):
Scene.episode_restart(self) # contains cpp_world.clean_everything()
# stadium_pose = cpp_household.Pose()
# if self.zero_at_running_strip_start_line:
# stadium_pose.set_xyz(27, 21, 0) # see RUN_STARTLINE, RUN_RAD constants
self.stadium = p.loadSDF(os.path.join(os.path.dirname(__file__), "other_assets", "stadium.sdf"))
self.ground_plane_mjcf = p.loadMJCF(os.path.join(os.path.dirname(__file__), "mujoco_assets", "ground_plane.xml"))
示例8: _spawnGroundPlane
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def _spawnGroundPlane(self, physics_client):
"""
INTERNAL METHOD, Loads a ground plane
Parameters:
physics_client - The id of the simulated instance in which the
ground plane is supposed to be spawned
"""
pybullet.setAdditionalSearchPath(pybullet_data.getDataPath())
pybullet.loadMJCF(
"mjcf/ground_plane.xml",
physicsClientId=physics_client)
示例9: __init__
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import loadMJCF [as 別名]
def __init__(self, robot, model_id, gravity, timestep, frame_skip, env = None):
Scene.__init__(self, gravity, timestep, frame_skip, env)
# contains cpp_world.clean_everything()
# stadium_pose = cpp_household.Pose()
# if self.zero_at_running_strip_start_line:
# stadium_pose.set_xyz(27, 21, 0) # see RUN_STARTLINE, RUN_RAD constants
filename = os.path.join(get_model_path(model_id), "mesh_z_up.obj")
#filename = os.path.join(get_model_path(model_id), "3d", "blender.obj")
#textureID = p.loadTexture(os.path.join(get_model_path(model_id), "3d", "rgb.mtl"))
if robot.model_type == "MJCF":
MJCF_SCALING = robot.mjcf_scaling
scaling = [1.0/MJCF_SCALING, 1.0/MJCF_SCALING, 0.6/MJCF_SCALING]
else:
scaling = [1, 1, 1]
magnified = [2, 2, 2]
collisionId = p.createCollisionShape(p.GEOM_MESH, fileName=filename, meshScale=scaling, flags=p.GEOM_FORCE_CONCAVE_TRIMESH)
view_only_mesh = os.path.join(get_model_path(model_id), "mesh_view_only_z_up.obj")
if os.path.exists(view_only_mesh):
visualId = p.createVisualShape(p.GEOM_MESH,
fileName=view_only_mesh,
meshScale=scaling, flags=p.GEOM_FORCE_CONCAVE_TRIMESH)
else:
visualId = -1
boundaryUid = p.createMultiBody(baseCollisionShapeIndex = collisionId, baseVisualShapeIndex = visualId)
p.changeDynamics(boundaryUid, -1, lateralFriction=1)
#print(p.getDynamicsInfo(boundaryUid, -1))
self.scene_obj_list = [(boundaryUid, -1)] # baselink index -1
planeName = os.path.join(pybullet_data.getDataPath(), "mjcf/ground_plane.xml")
self.ground_plane_mjcf = p.loadMJCF(planeName)
if "z_offset" in self.env.config:
z_offset = self.env.config["z_offset"]
else:
z_offset = -10 #with hole filling, we don't need ground plane to be the same height as actual floors
p.resetBasePositionAndOrientation(self.ground_plane_mjcf[0], posObj = [0,0,z_offset], ornObj = [0,0,0,1])
p.changeVisualShape(boundaryUid, -1, rgbaColor=[168 / 255.0, 164 / 255.0, 92 / 255.0, 1.0],
specularColor=[0.5, 0.5, 0.5])