def episode_restart(self): Scene.episode_restart(self) if self.score_right + self.score_left > 0: sys.stdout.write("%i:%i " % (self.score_left, self.score_right)) sys.stdout.flush() self.mjcf = self.cpp_world.load_mjcf(os.path.join(os.path.dirname(__file__), "models_robot/roboschool_pong.xml")) dump = 0 for r in self.mjcf: if dump: print("ROBOT '%s'" % r.root_part.name) for part in r.parts: if dump: print("\tPART '%s'" % part.name) #if part.name==self.robot_name: for j in r.joints: if j.name=="p0x": self.p0x = j if j.name=="p0y": self.p0y = j if j.name=="p1x": self.p1x = j if j.name=="p1y": self.p1y = j if j.name=="ballx": self.ballx = j if j.name=="bally": self.bally = j self.ballx.set_motor_torque(0.0) self.bally.set_motor_torque(0.0) for r in self.mjcf: r.query_position() fpose = cpp_household.Pose() fpose.set_xyz(0,0,-0.04) self.field = self.cpp_world.load_thingy( os.path.join(os.path.dirname(__file__), "models_outdoor/stadium/pong1.obj"), fpose, 1.0, 0, 0xFFFFFF, True) self.camera = self.cpp_world.new_camera_free_float(self.VIDEO_W, self.VIDEO_H, "video_camera") self.camera_itertia = 0 self.frame = 0 self.jstate_for_frame = -1 self.score_left = 0 self.score_right = 0 self.restart_from_center(self.players_count==1 or self.np_random.randint(2)==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 self.stadium = self.cpp_world.load_thingy( os.path.join(os.path.dirname(__file__), "models_outdoor/stadium/stadium1.obj"), stadium_pose, 1.0, 0, 0xFFFFFF, True) self.ground_plane_mjcf = self.cpp_world.load_mjcf(os.path.join(os.path.dirname(__file__), "mujoco_assets/ground_plane.xml"))
def episode_restart(self): Scene.episode_restart(self) # contains cpp_world.clean_everything() lab_ground_pose = cpp_household.Pose() lab_ground_pose.set_xyz(0, 0, 1) lab_ground_pose.set_rpy(np.pi / 2, 0, 0) # if self.zero_at_running_strip_start_line: # lab_pose.set_xyz(0, 0, 0) # see RUN_STARTLINE, RUN_RAD constants # scale seems not working self.lab_ground = self.cpp_world.load_thingy( os.path.join(os.path.dirname(__file__), "models_indoor/floor.obj"), lab_ground_pose, 1.0, 0, 0xFFFFFF, True) table_pose = cpp_household.Pose() table_pose.set_rpy(0, 0, np.pi / 2) table_pose.set_xyz(0.7, 0, 0.75) self.table = self.cpp_world.load_urdf( os.path.join(os.path.dirname(__file__), "models_indoor/lab/bordered_table.urdf"), table_pose, False, False) slope_pose = cpp_household.Pose() slope_pose.set_rpy(0, 0, np.pi / 2) slope_pose.set_xyz(0.6, -0.4, 0.8) self.slope = self.cpp_world.load_urdf( os.path.join(os.path.dirname(__file__), "models_indoor/lab/slope.urdf"), slope_pose, False, False) ball_pose = cpp_household.Pose() ball_pose.set_xyz(0.6, -0.4, 0.88) self.ball = self.cpp_world.load_urdf( os.path.join(os.path.dirname(__file__), "models_indoor/lab/ball.urdf"), ball_pose, False, False) self.ball_home_pose = ball_pose self.ball_r = 0.025 frame_pose = cpp_household.Pose() frame_pose.set_xyz(.95, 0.4, 0.88) frame_pose.set_rpy(0, 0, np.pi / 2) self.frame = self.cpp_world.load_urdf( os.path.join(os.path.dirname(__file__), "models_indoor/lab/frame.urdf"), frame_pose, False, False) self.frame_home_pose = frame_pose self.frame_width = 0.14 self.frame_height = 0.07 self.ground_plane_mjcf = self.cpp_world.load_mjcf( os.path.join(os.path.dirname(__file__), "mujoco_assets/ground_plane.xml"))
def episode_restart(self): Scene.episode_restart(self) stadium_pose = cpp_household.Pose() if self.zero_at_running_strip_start_line: stadium_pose.set_xyz(27, 21, 0) if self.render: if self.inclined: self.hfield = self.cpp_world.load_thingy( 'assets/incline_grass.obj', stadium_pose, 1.0, 0, 0xFFFFFF, True) else: self.stadium = self.cpp_world.load_thingy( os.path.join(os.path.dirname(roboschool.__file__), "models_outdoor/stadium/stadium1.obj"), stadium_pose, 1.0, 0, 0xFFFFFF, True) if self.inclined: self.ground_plane_mjcf = self.cpp_world.load_mjcf( "assets/incline_plane.mjcf") else: self.ground_plane_mjcf = self.cpp_world.load_mjcf( "assets/level_plane.mjcf")