Ejemplo n.º 1
0
    def _generate(self):
        length = self.config["exit_length"]

        parent_node_path, physics_world = self.engine.worldNP, self.engine.physics_world
        assert len(
            self.road_network.graph
        ) == 0, "These Map is not empty, please create a new map to read config"

        # Build a first-block
        last_block = FirstPGBlock(self.road_network,
                                  self.config[self.LANE_WIDTH],
                                  self.config[self.LANE_NUM],
                                  parent_node_path,
                                  physics_world,
                                  length=length)
        self.blocks.append(last_block)

        # Build Intersection
        InterSection.EXIT_PART_LENGTH = length
        last_block = InterSection(1,
                                  last_block.get_socket(index=0),
                                  self.road_network,
                                  random_seed=1,
                                  ignore_intersection_checking=False)
        last_block.add_u_turn(True)
        last_block.construct_block(parent_node_path, physics_world)
        self.blocks.append(last_block)
Ejemplo n.º 2
0
    def _generate(self):
        length = self.config["exit_length"]

        parent_node_path, physics_world = self.engine.worldNP, self.engine.physics_world
        assert len(
            self.road_network.graph
        ) == 0, "These Map is not empty, please create a new map to read config"

        # Build a first-block
        last_block = FirstPGBlock(self.road_network,
                                  self.config[self.LANE_WIDTH],
                                  self.config[self.LANE_NUM],
                                  parent_node_path,
                                  physics_world,
                                  length=length)
        self.blocks.append(last_block)

        # Build roundabout
        Roundabout.EXIT_PART_LENGTH = length
        last_block = Roundabout(1,
                                last_block.get_socket(index=0),
                                self.road_network,
                                random_seed=1,
                                ignore_intersection_checking=False)
        last_block.construct_block(
            parent_node_path,
            physics_world,
            extra_config={
                "exit_radius": 10,
                "inner_radius": 30,
                "angle": 70,
                # Note: lane_num is set in config.map_config.lane_num
            })
        self.blocks.append(last_block)
Ejemplo n.º 3
0
    def _generate(self):
        length = self.config["exit_length"]

        parent_node_path, physics_world = self.engine.worldNP, self.engine.physics_world
        assert len(
            self.road_network.graph
        ) == 0, "These Map is not empty, please create a new map to read config"

        # Build a first-block
        last_block = FirstPGBlock(self.road_network,
                                  self.config[self.LANE_WIDTH],
                                  self.config[self.LANE_NUM],
                                  parent_node_path,
                                  physics_world,
                                  length=length)
        self.blocks.append(last_block)

        last_block = ParkingLot(1,
                                last_block.get_socket(0),
                                self.road_network,
                                1,
                                ignore_intersection_checking=False)
        last_block.construct_block(parent_node_path, physics_world, {
            "one_side_vehicle_number":
            int(self.config["parking_space_num"] / 2)
        })
        self.blocks.append(last_block)
        self.parking_space = last_block.dest_roads
        self.parking_lot = last_block

        # Build ParkingLot
        TInterSection.EXIT_PART_LENGTH = 10
        last_block = TInterSection(2,
                                   last_block.get_socket(index=0),
                                   self.road_network,
                                   random_seed=1,
                                   ignore_intersection_checking=False)
        last_block.construct_block(
            parent_node_path,
            physics_world,
            extra_config={
                "t_type": 1,
                "change_lane_num": 0
                # Note: lane_num is set in config.map_config.lane_num
            })
        self.blocks.append(last_block)
Ejemplo n.º 4
0
from pgdrive.component.blocks.first_block import FirstPGBlock
from pgdrive.component.blocks.ramp import OutRampOnStraight
from pgdrive.component.road.road_network import RoadNetwork
from pgdrive.engine.asset_loader import initialize_asset_loader
from pgdrive.tests.vis_block.vis_block_base import TestBlock

if __name__ == "__main__":
    test = TestBlock()

    initialize_asset_loader(test)

    global_network = RoadNetwork()
    straight = FirstPGBlock(global_network, 3.0, 1, test.render, test.world, 1)
    for i in range(1, 3):
        straight = OutRampOnStraight(i, straight.get_socket(0), global_network,
                                     i)
        print(straight.construct_block(test.render, test.world))
        print(len(straight.dynamic_nodes))
    test.show_bounding_box(global_network)
    test.run()
Ejemplo n.º 5
0
from pgdrive.component.blocks.bottleneck import Merge, Split
from pgdrive.component.blocks.first_block import FirstPGBlock
from pgdrive.component.road.road_network import RoadNetwork
from pgdrive.engine.asset_loader import initialize_asset_loader
from pgdrive.tests.vis_block.vis_block_base import TestBlock

if __name__ == "__main__":
    test = TestBlock()

    initialize_asset_loader(test)

    global_network = RoadNetwork()
    b = FirstPGBlock(global_network, 3.0, 1, test.render, test.world, 1)
    for i in range(1, 13):
        tp = Merge if i % 3 == 0 else Split
        b = tp(i, b.get_socket(0), global_network, i)
        b.construct_block(test.render, test.world)
    test.show_bounding_box(global_network)
    test.run()
Ejemplo n.º 6
0
from pgdrive.component.blocks.curve import Curve
from pgdrive.component.blocks.first_block import FirstPGBlock
from pgdrive.component.road.road_network import RoadNetwork
from pgdrive.engine.asset_loader import initialize_asset_loader
from pgdrive.tests.vis_block.vis_block_base import TestBlock

if __name__ == "__main__":
    test = TestBlock()

    initialize_asset_loader(test)

    global_network = RoadNetwork()
    curve = FirstPGBlock(global_network, 3.0, 1, test.render, test.world, 1)
    for i in range(1, 13):
        curve = Curve(i, curve.get_socket(0), global_network, i)
        print(i)
        while True:
            success = curve.construct_block(test.render, test.world)
            print(success)
            if success:
                break
            curve.destruct_block(test.world)
    test.show_bounding_box(global_network)
    test.run()
Ejemplo n.º 7
0
from pgdrive.component.blocks.std_intersection import StdInterSection
from pgdrive.component.road.road_network import RoadNetwork
from pgdrive.tests.vis_block.vis_block_base import TestBlock

if __name__ == "__main__":
    StdInterSection.EXIT_PART_LENGTH = 4
    test = TestBlock()
    from pgdrive.engine.asset_loader import initialize_asset_loader

    initialize_asset_loader(test)

    global_network = RoadNetwork()
    last = FirstPGBlock(global_network, 3, 1, test.render, test.world, 1)

    last = StdInterSection(1, last.get_socket(0), global_network, 1)
    last.construct_block(test.render, test.world, dict(radius=4))
    inter_1 = last

    last = ParkingLot(2, last.get_socket(1), global_network, 1)
    last.construct_block(test.render, test.world)

    last = StdInterSection(3, last.get_socket(0), global_network, 1)
    last.construct_block(test.render, test.world, dict(radius=4))
    inter_2 = last

    last = StdInterSection(4, last.get_socket(2), global_network, 1)
    last.construct_block(test.render, test.world, dict(radius=4))
    inter_3 = last

    last = ParkingLot(5, last.get_socket(2), global_network, 1)
    last.construct_block(test.render, test.world)