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["lane_num"], parent_node_path, physics_world, length=length) self.blocks.append(last_block) split = Split(1, last_block.get_socket(index=0), self.road_network, random_seed=1, ignore_intersection_checking=False) split.construct_block( parent_node_path, physics_world, { "length": 2, "lane_num": self.config["toll_lane_num"] - self.config["lane_num"], "bottle_len": self.BOTTLE_LENGTH, }) self.blocks.append(split) toll = TollGate(2, split.get_socket(index=0), self.road_network, random_seed=1, ignore_intersection_checking=False) toll.construct_block(parent_node_path, physics_world, { "length": self.config["toll_length"], }) self.blocks.append(toll) # Build Toll merge = Merge(3, toll.get_socket(index=0), self.road_network, random_seed=1, ignore_intersection_checking=False) merge.construct_from_config( dict( lane_num=self.config["toll_lane_num"] - self.config["lane_num"], length=self.config["exit_length"], bottle_len=self.BOTTLE_LENGTH, ), parent_node_path, physics_world) self.blocks.append(merge)
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)
def __init__( self, lane_num: int, lane_width: float, global_network: RoadNetwork, render_node_path: NodePath, physics_world: PhysicsWorld, # block_type_version: str, exit_length=50, random_seed=None): super(BIG, self).__init__() self._block_sequence = None self.random_seed = random_seed self.np_random = get_np_random(random_seed) # Don't change this right now, since we need to make maps identical to old one self._lane_num = lane_num self._lane_width = lane_width self.block_num = None self._render_node_path = render_node_path self._physics_world = physics_world self._global_network = global_network self.blocks = [] self._exit_length = exit_length first_block = FirstPGBlock(self._global_network, self._lane_width, self._lane_num, self._render_node_path, self._physics_world, length=self._exit_length) self.blocks.append(first_block) self.next_step = NextStep.forward
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)
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)
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()
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()
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()
from pgdrive.component.blocks.curve import Curve from pgdrive.component.blocks.first_block import FirstPGBlock from pgdrive.component.blocks.std_t_intersection import StdTInterSection from pgdrive.component.blocks.straight import Straight from pgdrive.component.road.road_network import RoadNetwork from pgdrive.tests.vis_block.vis_block_base import TestBlock if __name__ == "__main__": test = TestBlock(True) from pgdrive.engine.asset_loader import initialize_asset_loader initialize_asset_loader(test) global_network = RoadNetwork() first = FirstPGBlock(global_network, 3.0, 2, test.render, test.world, 1) curve = Curve(1, first.get_socket(0), global_network, 1) curve.construct_block(test.render, test.world) straight = Straight(2, curve.get_socket(0), global_network, 1) straight.construct_block(test.render, test.world) intersection = StdTInterSection(3, straight.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 = Curve(id, intersection.get_socket(socket_idx), global_network, id + 1) block.construct_block(test.render, test.world) id += 1
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()
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(
from pgdrive.component.blocks.curve import Curve from pgdrive.component.blocks.first_block import FirstPGBlock from pgdrive.component.blocks.roundabout import Roundabout from pgdrive.component.road.road_network import RoadNetwork from pgdrive.tests.vis_block.vis_block_base import TestBlock if __name__ == "__main__": test = TestBlock(False) from pgdrive.engine.asset_loader import initialize_asset_loader initialize_asset_loader(test) global_network = RoadNetwork() straight = FirstPGBlock(global_network, 3.0, 1, test.render, test.world, 1) rd = Roundabout(1, straight.get_socket(0), global_network, 1) print(rd.construct_block(test.render, test.world)) id = 4 for socket_idx in range(rd.SOCKET_NUM): block = Curve(id, rd.get_socket(socket_idx), global_network, id + 1) block.construct_block(test.render, test.world) id += 1 test.show_bounding_box(global_network) test.run()
from pgdrive.component.blocks.first_block import FirstPGBlock from pgdrive.component.blocks.straight import Straight 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 = Straight(i, straight.get_socket(0), global_network, i) straight.construct_block(test.render, test.world) print(len(straight.dynamic_nodes)) test.show_bounding_box(global_network) test.run()
from pgdrive.component.blocks.first_block import FirstPGBlock from pgdrive.component.blocks.parking_lot import ParkingLot 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