def set_dest(self): exits = self._tunnel.exits[:] dest = None while dest is None and len(exits) > 0: nearest_exit = utils.find_nearest_segment(self._position, exits) exit_dest = nearest_exit.start \ + utils.vmiddle(nearest_exit.end - nearest_exit.start) if self._check_exit_blockage(exit_dest): exits.remove(nearest_exit) else: dest = exit_dest if len(exits) == 0 and dest is None: nearest_exit = utils.find_nearest_segment(self._position, self._tunnel.exits) dest = nearest_exit.start + utils.vmiddle(nearest_exit.end - nearest_exit.start) dest_vec = utils.vnormalize(dest - self._position) self._dest = dest + dest_vec * self.DEST_GAP self._find_nearest_end() self._find_checkpoint()
def _find_checkpoint(self): if self._nearest_end is None: return None end_vector = self._nearest_end - self.position end_dir = utils.vnormalize(end_vector) self._checkpoint = self._nearest_end + self.CHECKPOINT_GAP \ * end_dir
def _calculate_wall_rep_potential(self, closest): target_vector = closest - self._agent.position dist = utils.vlen(target_vector) target_dir = utils.vnormalize(target_vector) target_dir = self._rotate_direction_vetor(target_dir, closest) return np.exp(-dist / self._agent.radius) * target_dir
def _calculate_soc_rep_potential(self, agent): target_vector = agent.position - self._agent.position dist = utils.vlen(target_vector) target_dir = utils.vnormalize(target_vector) target_dir = self._rotate_direction_vetor(target_dir, agent.position) return np.exp(agent.radius + self._agent.radius - dist / self.SOCIAL_DIST_COEFF) * target_dir
def _calculate_desired_direction(self): """ """ if self._agent.checkpoint is not None: destination = self._agent.checkpoint else: destination = self._agent.dest dest_vector = destination - self._agent.position return utils.vnormalize(dest_vector)