示例#1
0
    def test_curved_road(self):
        params = ParameterServer()
        world = World(params)

        xodr_map = MakeXodrMapCurved(50, 0.1)

        map_interface = MapInterface()
        map_interface.SetOpenDriveMap(xodr_map)
        world.SetMap(map_interface)

        roads = [100]
        driving_direction = XodrDrivingDirection.forward
        map_interface.GenerateRoadCorridor(roads, driving_direction)
        road_corr = map_interface.GetRoadCorridor(roads, driving_direction)

        viewer = MPViewer(params=params, use_world_bounds=True)
        viewer.drawWorld(world)
        viewer.drawRoadCorridor(road_corr)
        #viewer.show(block=True)

        # if this is not here, the second unit test is not executed (maybe parsing takes too long?)
        time.sleep(1)
示例#2
0
    polygon = Polygon2d(
        [0, 0, 0],
        [Point2d(-1, -1),
         Point2d(-1, 1),
         Point2d(1, 1),
         Point2d(1, -1)])
    start_polygon = polygon.Translate(start_p)
    goal_polygon = polygon.Translate(end_p)
    rc = map_interface.GenerateRoadCorridor(start_p, goal_polygon)
    if rc:
        roads = rc.roads
        road_ids = list(roads.keys())
        print(road_ids, rc.road_ids)

        viewer.drawWorld(world)
        viewer.drawRoadCorridor(rc, "blue")
        viewer.saveFig(output_dir + "/" + "roadcorridor_" + str(cnt) + ".png")
        viewer.show()
        viewer.clear()

        for idx, lane_corridor in enumerate(rc.lane_corridors):
            viewer.drawWorld(world)
            viewer.drawLaneCorridor(lane_corridor, "green")
            viewer.drawLine2d(lane_corridor.left_boundary, color="red")
            viewer.drawLine2d(lane_corridor.right_boundary, color="green")
            viewer.drawLine2d(lane_corridor.center_line, color="green")
            viewer.drawPolygon2d(start_polygon,
                                 color="green",
                                 facecolor="green",
                                 alpha=1.)
            viewer.drawPolygon2d(goal_polygon,