def _get_intersection_traffic_signs(self) -> List[TrafficSign]: signs = [] if self.turn == Intersection.LEFT: # sign "turn left" in south signs.append( TrafficSign( TrafficSign.TURN_LEFT, *self.cp_sign_south(Config.get_turn_sign_dist()).xy, )) if self.rule != Intersection.YIELD: # sign "turn right" in west signs.append( TrafficSign( TrafficSign.TURN_RIGHT, *self.cp_sign_west(Config.get_turn_sign_dist()).xy, angle=self._alpha - 0.5 * math.pi, visible=False, )) elif self.turn == Intersection.RIGHT: # sign "turn right" in south signs.append( TrafficSign( TrafficSign.TURN_RIGHT, *self.cp_sign_south(Config.get_turn_sign_dist()).xy, )) if self.rule != Intersection.YIELD: # sign "turn left" in east signs.append( TrafficSign( TrafficSign.TURN_LEFT, *self.cp_sign_east(Config.get_turn_sign_dist()).xy, angle=self._alpha + 0.5 * math.pi, visible=False, )) type_map = { Intersection.PRIORITY_YIELD: TrafficSign.PRIORITY, Intersection.PRIORITY_STOP: TrafficSign.PRIORITY, Intersection.YIELD: TrafficSign.YIELD, Intersection.STOP: TrafficSign.STOP, } if self.rule in type_map: signs.append( TrafficSign( type_map[self.rule], *self.cp_sign_south(Config.get_prio_sign_dist(1)).xy, )) signs.append( TrafficSign( type_map[self.rule], *self.cp_sign_north(Config.get_prio_sign_dist(1)).xy, angle=math.pi, visible=False, )) # stvo-206: Stoppschild, # stvo-306: Vorfahrtsstraße # todo: also add turning signal if we are not on the outer turn lane # on the opposite side type_map_opposite = { Intersection.PRIORITY_YIELD: TrafficSign.YIELD, Intersection.PRIORITY_STOP: TrafficSign.STOP, Intersection.YIELD: TrafficSign.PRIORITY, Intersection.STOP: TrafficSign.PRIORITY, } if self.rule in type_map_opposite: signs.append( TrafficSign( type_map_opposite[self.rule], *self.cp_sign_west(Config.get_prio_sign_dist(1)).xy, angle=self._alpha - 0.5 * math.pi, visible=False, )) signs.append( TrafficSign( type_map_opposite[self.rule], *self.cp_sign_east(Config.get_prio_sign_dist(1)).xy, angle=self._alpha + 0.5 * math.pi, visible=False, )) for sign in signs: sign.normalize_x = False sign.set_transform(self.transform) return signs
def cp_sign_east(self, sign_dist): return ( Vector(self.z + self.x + self.u) + Vector( (0.1 + sign_dist) * 1 / abs(self.u) * self.u) + Vector(Config.get_sign_road_padding() * 1 / abs(self.v) * self.v))
def cp_surface_east(self): return (Vector(self.z + 0.5 * self.x + self.u) + Vector( (Config.get_surface_mark_dist() + Config.TURN_SF_MARK_LENGTH / 2) * 1 / abs(self.u) * self.u) + Vector( Config.TURN_SF_MARK_WIDTH / 2 * 1 / abs(self.v) * self.v))
def cp_sign_north(self, sign_dist): return Vector(self.z + self.x - self.u) + Vector( 0.1 + sign_dist, Config.get_sign_road_padding())
def cp_sign_west(self, sign_dist): return ( Vector(self.z - self.x - self.u) - Vector( (0.1 + sign_dist) * 1 / abs(self.u) * self.u) - Vector(Config.get_sign_road_padding() * 1 / abs(self.v) * self.v))
def cp_surface_south(self): return Vector(self.z - self.x + 0.5 * self.u) - Vector( Config.get_surface_mark_dist() + Config.TURN_SF_MARK_LENGTH / 2, 0)
def cp_sign_south(self, sign_dist): return Vector(self.z - self.x + self.u) - Vector( 0.1 + sign_dist, Config.get_sign_road_padding())
def cp_surface_east(self): return ( Vector(self.z + 0.5 * self.x + self.u) + Vector(Config.get_surface_mark_dist() * 1 / self.u.norm * self.u) + Vector(Config.TURN_SF_MARK_WIDTH / 2 * 1 / self.v.norm * self.v))