def test_world(self):
    road_graph = Roadgraph()
    lane1 = XodrLane()
    lane2 = XodrLane()
    road_id = 0

    # add vertices and connect edges
    u = road_graph.AddLane(road_id, lane1)
    v = road_graph.AddLane(road_id, lane2)
    road_graph.AddInnerNeighbor(u, v)
    road_graph.AddOuterNeighbor(u, v)

    vertices = road_graph.GetVertices()
    for vertex_descr in vertices:
      vertex = road_graph.GetVertex(vertex_descr)
      print(vertex.lane_id)

    GetEdges = road_graph.GetEdges()
    for edge_descr in GetEdges:
      edge = road_graph.GetEdge(edge_descr)
      print(edge.edge_type)
Exemple #2
0
    def test_world(self):
        # create agent
        params = ParameterServer()
        behavior = BehaviorConstantAcceleration(params)
        execution = ExecutionModelInterpolate(params)
        dynamic = SingleTrackModel(params)
        shape = Polygon2d([1.25, 1, 0], [
            Point2d(0, 0),
            Point2d(0, 2),
            Point2d(4, 2),
            Point2d(4, 0),
            Point2d(0, 0)
        ])
        init_state = np.array([0, 0, 0, 0, 5])
        agent = Agent(init_state, behavior, dynamic, execution, shape,
                      params.AddChild("agent"))
        road_map = OpenDriveMap()
        newXodrRoad = XodrRoad()
        newXodrRoad.id = 1
        newXodrRoad.name = "Autobahn A9"
        newPlanView = PlanView()
        newPlanView.AddLine(Point2d(0, 0), 1.57079632679, 10)
        newXodrRoad.plan_view = newPlanView
        line = newXodrRoad.plan_view.GetReferenceLine().ToArray()
        p = Point2d(line[-1][0], line[-1][1])
        newXodrRoad.plan_view.AddSpiral(p, 1.57079632679, 50.0, 0.0, 0.3, 0.4)
        line = newXodrRoad.plan_view.GetReferenceLine()
        lane_section = XodrLaneSection(0)
        lane = XodrLane()
        lane.line = line
        lane_section.AddLane(lane)
        newXodrRoad.AddLaneSection(lane_section)
        road_map.AddRoad(newXodrRoad)

        r = Roadgraph()
        map_interface = MapInterface()
        map_interface.SetOpenDriveMap(road_map)
        map_interface.SetRoadgraph(r)
        world = World(params)
        world.AddAgent(agent)