def step(self, actions, last_obs=None, world_states=None): ''' Take action (same interface as makeActions) ''' if self.action_space == 6: self.env.makeActions(actions) all_states = self.env.getStates() else: if world_states is None: for i, (sim, action, last_ob) in enumerate( zip(self.env.sims, actions, last_obs)): loc_attr = last_ob['adj_loc_list'][action] _navigate_to_location(sim, loc_attr['nextViewpointId'], loc_attr['absViewIndex']) all_states = self.env.getStates() else: # beamed all_states = [] for t in zip(self.env.sims_view(), world_states, actions, last_obs): beam_states = [] for sim, state, action, last_ob in zip(*t): sim.newEpisode(*state) loc_attr = last_ob['adj_loc_list'][action] _navigate_to_location(sim, loc_attr['nextViewpointId'], loc_attr['absViewIndex']) new_state = sim.getState() feature = self.env.feature.rollout( new_state.scanId, new_state.location.viewpointId, new_state.viewIndex) world_state = WorldState( scanId=new_state.scanId, viewpointId=new_state.location.viewpointId, heading=new_state.heading, elevation=new_state.elevation) beam_states.append((feature, world_state)) all_states.append(beam_states) return all_states
def get_world_state(sim): state = sim.getState() return WorldState( scanId=state.scanId, viewpointId=state.location.viewpointId, heading=state.heading, elevation=state.elevation, )
def newEpisodes(self, scanIds, viewpointIds, headings): feature_states = [] for i, (scanId, viewpointId, heading) in enumerate(zip(scanIds, viewpointIds, headings)): if isinstance(self.sims[i], list): # beamed world_state = WorldState(scanId, viewpointId, heading, 0) self.sims[i][0].newEpisode(*world_state) # self.sims[i][0].newEpisode(scanId, viewpointId, heading, 0) state = self.sims[i][0].getState() feature = self.feature.rollout(state.scanId, state.location.viewpointId, state.viewIndex) feature_states.append([(feature, world_state)]) else: self.sims[i].newEpisode(scanId, viewpointId, heading, 0) state = self.sims[i].getState() feature = self.feature.rollout(state.scanId, state.location.viewpointId, state.viewIndex) feature_states.append((feature, state, self.sims[i])) return feature_states