本文整理汇总了Python中pybullet.getNumBodies方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.getNumBodies方法的具体用法?Python pybullet.getNumBodies怎么用?Python pybullet.getNumBodies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.getNumBodies方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dumpStateToFile
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [as 别名]
def dumpStateToFile(file):
for i in range (p.getNumBodies()):
pos,orn = p.getBasePositionAndOrientation(i)
linVel,angVel = p.getBaseVelocity(i)
txtPos = "pos="+str(pos)+"\n"
txtOrn = "orn="+str(orn)+"\n"
txtLinVel = "linVel"+str(linVel)+"\n"
txtAngVel = "angVel"+str(angVel)+"\n"
file.write(txtPos)
file.write(txtOrn)
file.write(txtLinVel)
file.write(txtAngVel)
示例2: dumpStateToFile
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [as 别名]
def dumpStateToFile(self, file):
for i in range (p.getNumBodies()):
pos,orn = p.getBasePositionAndOrientation(i)
linVel,angVel = p.getBaseVelocity(i)
txtPos = "pos="+str(pos)+"\n"
txtOrn = "orn="+str(orn)+"\n"
txtLinVel = "linVel"+str(linVel)+"\n"
txtAngVel = "angVel"+str(angVel)+"\n"
file.write(txtPos)
file.write(txtOrn)
file.write(txtLinVel)
file.write(txtAngVel)
示例3: test
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [as 别名]
def test(args):
count = 0
env = gym.make(args.env)
env.env.configure(args)
print("args.render=",args.render)
if (args.render==1):
env.render(mode="human")
env.reset()
if (args.resetbenchmark):
while (1):
env.reset()
print("p.getNumBodies()=",p.getNumBodies())
print("count=",count)
count+=1
print("action space:")
sample = env.action_space.sample()
action = sample*0.0
print("action=")
print(action)
for i in range(args.steps):
obs,rewards,done,_ =env.step(action)
if (args.rgb):
print(env.render(mode="rgb_array"))
print("obs=")
print(obs)
print("rewards")
print (rewards)
print ("done")
print(done)
示例4: robot_specific_reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [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: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [as 别名]
def _reset(self):
assert(self._robot_introduced)
assert(self._scene_introduced)
debugmode = 1
if debugmode:
print("Episode: steps:{} score:{}".format(self.nframe, self.reward))
body_xyz = self.robot.body_xyz
#print("[{}, {}, {}],".format(body_xyz[0], body_xyz[1], body_xyz[2]))
print("Episode count: {}".format(self.eps_count))
self.eps_count += 1
self.nframe = 0
self.eps_reward = 0
BaseEnv._reset(self)
if not self.ground_ids:
self.parts, self.jdict, self.ordered_joints, self.robot_body = self.robot.addToScene(
[])
self.ground_ids = set(self.scene.scene_obj_list)
## Todo: (hzyjerry) this part is not working, robot_tracking_id = -1
for i in range (p.getNumBodies()):
if (p.getBodyInfo(i)[0].decode() == self.robot_body.get_name()):
self.robot_tracking_id=i
#print(p.getBodyInfo(i)[0].decode())
i = 0
eye_pos, eye_quat = self.get_eye_pos_orientation()
pose = [eye_pos, eye_quat]
observations = self.render_observations(pose)
pos = self.robot._get_scaled_position()
orn = self.robot.get_orientation()
pos = (pos[0], pos[1], pos[2] + self.tracking_camera['z_offset'])
p.resetDebugVisualizerCamera(self.tracking_camera['distance'],self.tracking_camera['yaw'], self.tracking_camera['pitch'],pos)
return observations
示例6: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getNumBodies [as 别名]
def _reset(self):
assert(self._robot_introduced)
assert(self._scene_introduced)
debugmode = 1
if debugmode:
print("Episode: steps:{} score:{}".format(self.nframe, self.reward))
body_xyz = self.robot.body_xyz
print("[{}, {}, {}],".format(body_xyz[0], body_xyz[1], body_xyz[2]))
print("Episode count: {}".format(self.eps_count))
self.eps_count += 1
self.nframe = 0
self.eps_reward = 0
BaseEnv._reset(self)
if not self.ground_ids:
self.parts, self.jdict, self.ordered_joints, self.robot_body = self.robot.addToScene(
[])
self.ground_ids = set(self.scene.scene_obj_list)
## Todo: (hzyjerry) this part is not working, robot_tracking_id = -1
for i in range (p.getNumBodies()):
if (p.getBodyInfo(i)[0].decode() == self.robot_body.get_name()):
self.robot_tracking_id=i
#print(p.getBodyInfo(i)[0].decode())
i = 0
eye_pos, eye_quat = self.get_eye_pos_orientation()
pose = [eye_pos, eye_quat]
observations = self.render_observations(pose)
pos = self.robot._get_scaled_position()
orn = self.robot.get_orientation()
pos = (pos[0], pos[1], pos[2] + self.tracking_camera['z_offset'])
p.resetDebugVisualizerCamera(self.tracking_camera['distance'],self.tracking_camera['yaw'], self.tracking_camera['pitch'],pos)
return observations