def __init__(self, attrs, driveOnLeft=False): super().__init__(attrs) self.driveOnLeft = driveOnLeft self.translation = attrs['translation'] pts = [ np.array(webotsToScenicPosition(p + self.translation)) for p in attrs['wayPoints'] ] self.waypoints = tuple(cleanChain(pts, 0.05)) assert len(self.waypoints) > 1, pts self.width = float(attrs.get('width', 7)) self.lanes = int(attrs.get('numberOfLanes', 2)) if self.lanes < 1: raise RuntimeError(f'Road {self.osmID} has fewer than 1 lane!') self.forwardLanes = int(attrs.get('numberOfForwardLanes', 1)) # if self.forwardLanes < 1: # raise RuntimeError(f'Road {self.osmID} has fewer than 1 forward lane!') self.backwardLanes = self.lanes - self.forwardLanes self.hasLeftSidewalk = attrs.get('leftBorder', True) self.hasRightSidewalk = attrs.get('rightBorder', True) self.sidewalkWidths = list(attrs.get('roadBorderWidth', [0.8])) if ((self.hasLeftSidewalk or self.hasRightSidewalk) and len(self.sidewalkWidths) < 1): raise RuntimeError( f'Road {self.osmID} has sidewalk with empty width!') self.startCrossroad = attrs.get('startJunction') self.endCrossroad = attrs.get('endJunction')
def __init__(self, attrs): super().__init__(attrs) self.translation = attrs['translation'] points = list(np.array(webotsToScenicPosition(p + self.translation)) for p in attrs['shape']) if len(points) > 0: self.points = points self.region = PolygonalRegion(self.points) else: verbosePrint(f'WARNING: Crossroad {self.osmID} has empty shape field!') self.region = None
def __init__(self, attrs): self.translation = attrs.get('translation', np.array((0, 0, 0))) pos = np.array(webotsToScenicPosition(self.translation)) name = attrs.get('name', '') self.angle = webotsToScenicRotation(attrs.get('rotation', (0, 1, 0, 0))) if self.angle is None: raise RuntimeError(f'PedestrianCrossing "{name}" is not 2D!') size = attrs.get('size', (20, 8)) self.length, self.width = float(size[0]), float(size[1]) self.length += 0.2 # pad length to intersect sidewalks better # TODO improve? hl, hw = self.length / 2, self.width / 2 self.corners = tuple(pos + rotateVector(vec, -self.angle) for vec in ((hl, hw), (-hl, hw), (-hl, -hw), (hl, -hw))) self.region = PolygonalRegion(self.corners)