Example #1
0
    def __init__(self,
                 config,
                 tracking_camera,
                 scene_type="building",
                 gpu_idx=0):
        BaseEnv.__init__(self, config, scene_type, tracking_camera)

        self.camera_x = 0
        self.walk_target_x = 1e3  # kilometer away
        self.walk_target_y = 0
        self.k = 5
        self.robot_tracking_id = -1

        self.scale_up = 4
        self.dataset = None
        self.ground_ids = None
        if self.gui:
            assert (self.tracking_camera is not None)
        self.gpu_idx = gpu_idx
        self.assign_ports()
        self.nframe = 0
        self.eps_reward = 0

        self.reward = 0
        self.eps_count = 0

        self._robot_introduced = False
        self._scene_introduced = False
Example #2
0
    def __init__(self, config, tracking_camera, scene_type="building", gpu_count=0):
        BaseEnv.__init__(self, config, scene_type, tracking_camera)

        self.camera_x = 0
        self.walk_target_x = 1e3  # kilometer away
        self.walk_target_y = 0
        self.k = 5
        self.robot_tracking_id = -1

        self.scale_up  = 4
        self.dataset  = ViewDataSet3D(
            transform = np.array,
            mist_transform = np.array,
            seqlen = 2,
            off_3d = False,
            train = False,
            overwrite_fofn=True, env = self)
        self.ground_ids = None
        if self.gui:
            assert(self.tracking_camera is not None)
        self.gpu_count = gpu_count
        self.nframe = 0
        self.eps_reward = 0

        self.reward = 0
        self.eps_count = 0

        self._robot_introduced = False
        self._scene_introduced = False
Example #3
0
    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
Example #4
0
    def __init__(self, config, scene_type="building", gpu_count=0):
        BaseEnv.__init__(self, config, scene_type)
        ## The following properties are already instantiated inside xxx_env.py:
        #   @self.timestep
        #   @self.frame_skip

        self.camera_x = 0
        self.walk_target_x = 1e3  # kilometer away
        self.walk_target_y = 0
        self.temp_target_x = 0  # added randomness
        self.temp_target_y = 0  # added randomness

        self.k = 5
        self.robot_tracking_id = -1

        self.scale_up = 4
        self.dataset = ViewDataSet3D(transform=np.array,
                                     mist_transform=np.array,
                                     seqlen=2,
                                     off_3d=False,
                                     train=False,
                                     overwrite_fofn=True,
                                     env=self)
        self.ground_ids = None
        if self.gui:
            assert (self.tracking_camera is not None)
        self.gpu_count = gpu_count
        self.nframe = 0
        self.eps_reward = 0

        self.reward = 0
        self.eps_count = 0

        self._robot_introduced = False
        self._scene_introduced = False
Example #5
0
    def _close(self):
        BaseEnv._close(self)

        if not self._require_camera_input or self.test_env:
            return
        self.r_camera_mul.terminate()
        self.r_camera_rgb._close()

        if self.r_camera_dep is not None:
            self.r_camera_dep.terminate()
        if self._require_normal:
            self.r_camera_norm.terminate()
        if self._require_semantics:
            self.r_camera_semt.terminate()
Example #6
0
    def _close(self):
        BaseEnv._close(self)

        if self._require_camera_input:
            self.r_camera_mul.terminate()
            self.r_camera_rgb._close()

            if self.r_camera_dep is not None:
                self.r_camera_dep.terminate()
            if self._require_normal:
                self.r_camera_norm.terminate()
            if self._require_semantics:
                self.r_camera_semt.terminate()

        if self.config["display_ui"]:
            self.UI._close()
    def _reset(self):
        assert (self._robot_introduced)
        assert (self._scene_introduced)
        self.eps_count += 1

        #print("Episode count: {}/50".format((self.eps_count%50)) + " -------- "
        #     + "Score: {:.3g}".format(self.reward))

        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)

        # (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'])
        if self.config["mode"]=="gui":
            p.resetDebugVisualizerCamera(self.tracking_camera['distance'], self.tracking_camera['yaw'],
                                         self.tracking_camera['pitch'], pos)
        return observations