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)

        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.º 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["bottle_lane_num"],
                                  parent_node_path,
                                  physics_world,
                                  length=length)
        self.blocks.append(last_block)

        # Build Bottleneck
        merge = Merge(1,
                      last_block.get_socket(index=0),
                      self.road_network,
                      random_seed=1,
                      ignore_intersection_checking=False)
        merge.construct_from_config(
            dict(lane_num=self.config["bottle_lane_num"] -
                 self.config["neck_lane_num"],
                 length=self.config["neck_length"]), parent_node_path,
            physics_world)
        self.blocks.append(merge)
        split = Split(2,
                      merge.get_socket(index=0),
                      self.road_network,
                      random_seed=1,
                      ignore_intersection_checking=False)
        split.construct_from_config(
            {
                "length":
                self.config["exit_length"],
                "lane_num":
                self.config["bottle_lane_num"] - self.config["neck_lane_num"]
            }, parent_node_path, physics_world)
        self.blocks.append(split)
Ejemplo n.º 3
0
from pgdrive.component.blocks.first_block import FirstPGBlock
from pgdrive.component.blocks.std_intersection import StdInterSection
from pgdrive.component.blocks.std_t_intersection import StdTInterSection
from pgdrive.component.road.road_network import RoadNetwork
from pgdrive.tests.vis_block.vis_block_base import TestBlock

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

    initialize_asset_loader(test)

    global_network = RoadNetwork()
    first = FirstPGBlock(global_network, 3.0, 1, test.render, test.world, 1)

    intersection = StdInterSection(3, first.get_socket(0), global_network, 1)
    print(intersection.construct_block(test.render, test.world))

    id = 4
    for socket_idx in range(intersection.SOCKET_NUM):
        block = StdTInterSection(id, intersection.get_socket(socket_idx),
                                 global_network, id)
        block.construct_block(test.render, test.world)
        id += 1
    test.show_bounding_box(global_network)
    test.run()
Ejemplo n.º 4
0
from pgdrive.component.blocks.first_block import FirstPGBlock
from pgdrive.component.blocks.roundabout import Roundabout
from pgdrive.component.blocks.std_intersection import StdInterSection
from pgdrive.component.blocks.straight import Straight
from pgdrive.component.blocks.t_intersection import TInterSection
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
from pgdrive.utils.space import Parameter

if __name__ == "__main__":
    test = TestBlock(False)
    initialize_asset_loader(test)
    global_network = RoadNetwork()
    blocks = []
    init_block = FirstPGBlock(global_network, 3.0, 3, test.render, test.world,
                              1)

    block = StdInterSection(1, init_block.get_socket(0), global_network, 1)
    block.construct_from_config(
        {
            Parameter.radius: 10,
            Parameter.change_lane_num: 0,
            Parameter.decrease_increase: 0
        }, test.render, test.world)

    block = Straight(2, block.get_socket(1), global_network, 1)
    block.construct_from_config({Parameter.length: 388}, test.render,
                                test.world)

    block = StdInterSection(3, block.get_socket(0), global_network, 1)
    block.construct_from_config(