def get_random_maps_squeeze_between_obstacle_in_corridor_on_path(): """ Download (or read from cache) randomly edited real world map with of a robot in a corridor with 3 square obstacles :return: a tuple of 3 elements - original realworld costmap of the corridor with 3 boxes - reference path that human took - tuple of 1000 randomized maps that were obstained by cutting and pasting 3 boxes randomly around their original localization """ key = '413293a9-086b-46e0-83ef-bb09d23c70d5' test_maps_cache = 'test_random_maps_%s.pkl' % key session_tar_key = 'tdwa_paper_' + os.path.splitext( test_maps_cache)[0] + '.tar.xz' session_tar_file = get_cache_key_path(session_tar_key) tar_contents_folder = session_tar_file + '.contents/' if not os.path.exists(session_tar_file): r = requests.get( 'https://s3-us-west-1.amazonaws.com/braincorp-research-public-datasets/' + session_tar_key) with open(session_tar_file, 'wb') as f: f.write(r.content) # remove unzipped cache if redownloaded if os.path.exists(tar_contents_folder): shutil.rmtree(tar_contents_folder) if not os.path.exists(tar_contents_folder): print('Unzipping Tar file "%s"' % session_tar_file) try: decompress_tar_archive(session_tar_file, tar_contents_folder, verbose=True) except Exception as ex: shutil.rmtree(tar_contents_folder) raise ex with open(os.path.join(tar_contents_folder, test_maps_cache), 'rb') as f: if sys.version_info > (3, 0): original_costmap = CostMap2D.from_state( pickle.load(f, encoding='latin1')) # pylint: disable=unexpected-keyword-arg static_path = pickle.load(f, encoding='latin1') # pylint: disable=unexpected-keyword-arg test_maps = tuple([ CostMap2D.from_state(s) for s in pickle.load(f, encoding='latin1') ]) # pylint: disable=unexpected-keyword-arg else: original_costmap = CostMap2D.from_state(pickle.load(f)) static_path = pickle.load(f) test_maps = tuple( [CostMap2D.from_state(s) for s in pickle.load(f)]) return original_costmap, static_path, test_maps
def deserialize(cls, state): ver = state.pop('version') assert ver == cls.VERSION state['costmap'] = CostMap2D.from_state(state['costmap']) reward_provider_state_instance = create_reward_provider_state( state.pop('reward_provider_state_name')) state[ 'reward_provider_state'] = reward_provider_state_instance.deserialize( state['reward_provider_state']) # prepare for robot state deserialization robot_instance = create_standard_robot(state.pop('robot_type_name')) robot_state_type = robot_instance.get_state_type() # deserialize the robot state state['robot_state'] = robot_state_type.deserialize( state['robot_state']) # deserialize robot state queue acc = [] for item in state['robot_state_queue']: acc.append(robot_state_type.deserialize(item)) state['robot_state_queue'] = acc return cls(**state)
def deserialize(cls, state): ver = state.pop('version') assert ver == cls.VERSION state['costmap'] = CostMap2D.from_state(state['costmap']) robot_instance = create_standard_robot(state.pop('robot_type_name')) robot_state_type = robot_instance.get_state_type() # deserialize the robot state state['robot_state'] = robot_state_type.deserialize( state['robot_state']) return cls(**state)
def deserialize(cls, state): ver = state.pop('version') assert ver == cls.VERSION init_costmap = CostMap2D.from_state(state['costmap']) init_path = state['path'] params = EnvParams.deserialize(state['params']) state = State.deserialize(state['state']) instance = cls(init_costmap, init_path, params) instance.set_state(state) return instance