def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart( self, bullet_client) # contains cpp_world.clean_everything() if (self.stadiumLoaded == 0): self.stadiumLoaded = 1 # 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(pybullet_data.getDataPath(), "plane_stadium.sdf") self.ground_plane_mjcf = self._p.loadSDF(filename) #filename = os.path.join(pybullet_data.getDataPath(),"stadium_no_collision.sdf") #self.ground_plane_mjcf = self._p.loadSDF(filename) # for i in self.ground_plane_mjcf: self._p.changeDynamics(i, -1, lateralFriction=0.8, restitution=0.5) self._p.changeVisualShape(i, -1, rgbaColor=[1, 1, 1, 0.8]) self._p.configureDebugVisualizer( pybullet.COV_ENABLE_PLANAR_REFLECTION, 1)
def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart( self, bullet_client) # contains cpp_world.clean_everything() if self.stadiumLoaded == 0: self.stadiumLoaded = 1 # stadium_pose = cpp_household.Pose() # if self.zero_at_running_strip_start_line:([(self.parts[f].bodies[self.parts[f].bodyIndex], self.parts[f].bodyPartIndex) for f in self.foot_ground_object_names]) # stadium_pose.set_xyz(27, 21, 0) # see RUN_STARTLINE, RUN_RAD constants filename = os.path.join(pybullet_data.getDataPath(), "plane_stadium.sdf") self.ground_plane_mjcf = self._p.loadSDF(filename) ''' filename = os.path.expanduser("~/data/mar-saba-monastery-rawscan/source/MarSaba/MarSaba.obj") collisionShapeId = self._p.createCollisionShape(pybullet.GEOM_MESH, fileName=filename, flags=pybullet.GEOM_FORCE_CONCAVE_TRIMESH) visualShapeIds = self._p.createVisualShape(pybullet.GEOM_MESH, fileName=filename) orn = self._p.getQuaternionFromEuler([math.pi / 2, 0, 0]) self.ground_plane_mjcf = [self._p.createMultiBody(0, baseCollisionShapeIndex=collisionShapeId, baseVisualShapeIndex=visualShapeIds, baseOrientation=orn)] startHeight = 0 linearDamping = 0.1 ''' for i in self.ground_plane_mjcf: self._p.changeDynamics(i, -1, lateralFriction=0.8, restitution=0.5)
def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart( self, bullet_client) # contains cpp_world.clean_everything() if (self.stadiumLoaded == 0): self.stadiumLoaded = 1 # Add stadium floor filename = os.path.join(os.path.dirname(__file__), "assets/plane_normal.sdf") self.ground_plane_mjcf = self._p.loadSDF(filename) self._p.changeDynamics(0, -1, lateralFriction=.8, restitution=0.5, rollingFriction=0.005) # self._p.changeVisualShape(i, -1, rgbaColor=[1, 1, 1, 1]) # self._p.configureDebugVisualizer(pybullet.COV_ENABLE_PLANAR_REFLECTION,i) # Add ball filename = os.path.join(os.path.dirname(__file__), "assets/ball_blue.urdf") ball_body = self._p.loadURDF(filename, self.ball_pos) self._p.changeDynamics(ball_body, -1, restitution=1, mass=5.) #,rollingFriction=0.001) # Add Obstacle to scene # self.obstacle = get_cube(self._p, 3.25, 0, 0.25) self.ground_plane_mjcf += (ball_body, )
def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart( self, bullet_client ) # contains cpp_world.clean_everything() # Generate tinggi floor for j in range(int(self.numHeightfieldColumns / 2)): for i in range(int(self.numHeightfieldRows / 2)): height = random.uniform(0, 0.05) * 10 self.heightfieldData[2 * i + 2 * j * self.numHeightfieldRows] = height self.heightfieldData[2 * i + 1 + 2 * j * self.numHeightfieldRows] = height self.heightfieldData[2 * i + (2 * j + 1) * self.numHeightfieldRows] = height self.heightfieldData[ 2 * i + 1 + (2 * j + 1) * self.numHeightfieldRows ] = height baseHeight = 0 for j in [63, 64]: for i in [63, 64]: self.heightfieldData[2 * i + 2 * j * self.numHeightfieldRows] = baseHeight self.heightfieldData[2 * i + 1 + 2 * j * self.numHeightfieldRows] = baseHeight self.heightfieldData[2 * i + (2 * j + 1) * self.numHeightfieldRows] = baseHeight self.heightfieldData[ 2 * i + 1 + (2 * j + 1) * self.numHeightfieldRows ] = baseHeight self.terrainShape = self._p.createCollisionShape( shapeType=pybullet.GEOM_HEIGHTFIELD, meshScale=[1, 1, 1], heightfieldTextureScaling=256, heightfieldData=self.heightfieldData, numHeightfieldRows=self.numHeightfieldRows, numHeightfieldColumns=self.numHeightfieldColumns, replaceHeightfieldIndex = self.terrainShape ) if not self.sceneLoaded: self.sceneLoaded = True self.terrain = self._p.createMultiBody(0, self.terrainShape) self._p.resetBasePositionAndOrientation( self.terrain, [0, 0, 0.25], [0, 0, 0, 1] ) # terrainShape = self._p.createCollisionShape(shapeType = pybullet.GEOM_HEIGHTFIELD, meshScale=[.1,.1,24],fileName = "./wm_height_out.png") # textureId = self._p.loadTexture("./gimp_overlay_out.png") # self.terrain = self._p.createMultiBody(0, terrainShape) # self._p.changeVisualShape(self.terrain, -1, textureUniqueId = textureId) self._p.changeVisualShape(self.terrain, -1, rgbaColor=[1, 1, 1, 0.8]) self._p.changeDynamics( self.terrain, -1, lateralFriction=0.8, restitution=0.5 ) self._p.configureDebugVisualizer( pybullet.COV_ENABLE_PLANAR_REFLECTION, self.terrain )
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 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: p.changeVisualShape(i,-1,rgbaColor=[0,0,0,0])
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 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: p.changeVisualShape(i, -1, rgbaColor=[0, 0, 0, 0])
def episode_restart(self): Scene.episode_restart(self) # contains cpp_world.clean_everything() if (self.stadiumLoaded==0): self.stadiumLoaded=1 # 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(pybullet_data.getDataPath(),"stadium_no_collision.sdf") self.ground_plane_mjcf = p.loadSDF(filename) for i in self.ground_plane_mjcf: p.changeDynamics(i,-1,lateralFriction=0.8, restitution=0.5) for j in range(p.getNumJoints(i)): p.changeDynamics(i,j,lateralFriction=0)
def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart(self, bullet_client) # contains cpp_world.clean_everything() if (self.stadiumLoaded == 0): self.stadiumLoaded = 1 # 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(pybullet_data.getDataPath(), "plane_stadium.sdf") self.ground_plane_mjcf = self._p.loadSDF(filename) #filename = os.path.join(pybullet_data.getDataPath(),"stadium_no_collision.sdf") #self.ground_plane_mjcf = self._p.loadSDF(filename) # for i in self.ground_plane_mjcf: self._p.changeDynamics(i, -1, lateralFriction=0.8, restitution=0.5) self._p.changeVisualShape(i, -1, rgbaColor=[1, 1, 1, 0.8]) self._p.configureDebugVisualizer(pybullet.COV_ENABLE_PLANAR_REFLECTION, 1)
def episode_restart(self, bullet_client): self._p = bullet_client Scene.episode_restart(self, bullet_client) if not self.loaded: self.loaded = True self.ground_plane_mjcf += [ self._p.loadURDF(join(assets_dir, 'plane.xml'), (0 + self.center[0], 0 + self.center[1], 0)) ] self.ground_plane_mjcf += [ self._p.loadURDF( join(assets_dir, 'wall.xml'), (self.center[0], self.size[1] / 2 + self.center[1], 2.5)) ] self.ground_plane_mjcf += [ self._p.loadURDF( join(assets_dir, 'wall.xml'), (self.center[0], -self.size[1] / 2 + self.center[1], 2.5)) ] self.ground_plane_mjcf += [ self._p.loadURDF( join(assets_dir, 'wall.xml'), (self.size[0] / 2 + self.center[0], 0 + self.center[1], 2.5), pybullet.getQuaternionFromEuler((0, 0, np.pi / 2))) ] self.ground_plane_mjcf += [ self._p.loadURDF( join(assets_dir, 'wall.xml'), (-self.size[0] / 2 + self.center[0], 0 + self.center[1], 2.5), pybullet.getQuaternionFromEuler((0, 0, np.pi / 2))) ] for i in self.ground_plane_mjcf: self._p.changeDynamics(i, -1, lateralFriction=0.8, restitution=0.5) self._p.configureDebugVisualizer( pybullet.COV_ENABLE_PLANAR_REFLECTION, i)