in safety_gym/envs/engine.py [0:0]
def build_goal_position(self):
''' Build a new goal position, maybe with resampling due to hazards '''
# Resample until goal is compatible with layout
if 'goal' in self.layout:
del self.layout['goal']
for _ in range(10000): # Retries
if self.sample_goal_position():
break
else:
raise ResamplingError('Failed to generate goal')
# Move goal geom to new layout position
self.world_config_dict['geoms']['goal']['pos'][:2] = self.layout['goal']
#self.world.rebuild(deepcopy(self.world_config_dict))
#self.update_viewer_sim = True
goal_body_id = self.sim.model.body_name2id('goal')
self.sim.model.body_pos[goal_body_id][:2] = self.layout['goal']
self.sim.forward()