in interaction_exploration/tools/calculate_max_interactions.py [0:0]
def run(self, G, T=1024):
self.G = G
step_infos = []
while len(self.interaction_candidates)>0 and self.t<T:
path = None
while path is None:
target_obj = self.select_next_obj()
if target_obj is None:
break
path = self.get_path_to_obj(target_obj)
if path is None:
print ('DONE')
break
self.t += len(path) - 1
step_infos += [{'action':'move', 'target':None, 'success':True, 'reward':0}]*(len(path) - 1)
if self.t >= T:
print ('Timeout')
break
for interaction in target_obj['ints']:
if interaction != 'put':
self.step_info = {'action':interaction, 'target':{'objectId': target_obj['objectId']}, 'success':True}
elif interaction == 'put':
if target_obj['parentReceptacles'] is None:
continue
self.step_info = {'action':interaction, 'target':{'objectId': target_obj['parentReceptacles'][0]}, 'success':True}
self.step_info['reward'] = self.get_reward(None)
step_infos.append(self.step_info)
self.t += 1
if self.t >= T:
print ('Timeout')
break
end_pos = path[-1]
self.controller.step(dict(action='TeleportFull', x=end_pos[0], y=end_pos[1], z=end_pos[2], rotation=end_pos[3], horizon=end_pos[4]))
# padding
step_infos = step_infos[:T]
step_infos += [{'action':None, 'target':None, 'success':None, 'reward':0}]*(T - len(step_infos))
return step_infos