-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from inverted-ai/develop
Develop
- Loading branch information
Showing
19 changed files
with
1,224 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import argparse | ||
import invertedai as iai | ||
from invertedai.simulation.simulator import Simulation, SimulationConfig | ||
import pathlib | ||
import pygame | ||
from tqdm import tqdm | ||
from time import perf_counter | ||
path = pathlib.Path(__file__).parent.resolve() | ||
|
||
|
||
parser = argparse.ArgumentParser(description="Simulation Parameters.") | ||
parser.add_argument("--api_key", type=str, default=None) | ||
parser.add_argument("--fov", type=float, default=500) | ||
parser.add_argument("--location", type=str, default="carla:Town10HD") | ||
parser.add_argument("--center", type=str, default="carla:Town10HD") | ||
parser.add_argument("-l", "--episode_length", type=int, default=300) | ||
parser.add_argument("-cap", "--quadtree_capacity", type=int, default=15) | ||
parser.add_argument("-ad", "--agent_density", type=int, default=10) | ||
parser.add_argument("-ri", "--re_initialization", type=int, default=30) | ||
parser.add_argument("-len", "--simulation_length", type=int, default=10000) | ||
args = parser.parse_args() | ||
|
||
|
||
if args.api_key is not None: | ||
iai.add_apikey(args.api_key) | ||
response = iai.location_info(location=args.location) | ||
if response.birdview_image is not None: | ||
rendered_static_map = response.birdview_image.decode() | ||
|
||
cfg = SimulationConfig(location=args.location, map_center=(response.map_center.x, response.map_center.y), | ||
map_fov=response.map_fov, rendered_static_map=rendered_static_map, | ||
map_width=response.map_fov+200, map_height=response.map_fov+200, agent_density=args.agent_density, | ||
initialize_stride=50, quadtree_capacity=args.quadtree_capacity, | ||
re_initialization_period=args.re_initialization) | ||
simulation = Simulation(cfg=cfg) | ||
|
||
fps = 100 | ||
clock = pygame.time.Clock() | ||
run = True | ||
start = perf_counter() | ||
fram_counter = 0 | ||
for _ in tqdm(range(args.simulation_length)): | ||
# ----- HANDLE EVENTS ------ | ||
for event in pygame.event.get(): | ||
if event.type == pygame.QUIT: | ||
run = False | ||
if event.type == pygame.KEYUP: | ||
if event.key in [pygame.K_q, pygame.K_ESCAPE]: | ||
run = False | ||
if event.key == pygame.K_t: | ||
simulation.show_quadtree = not simulation.show_quadtree | ||
if event.key == pygame.K_l: | ||
for npc in simulation.npcs: | ||
npc.show_agent_neighbors = not npc.show_agent_neighbors | ||
if not run: | ||
break | ||
# ----------------------------- | ||
simulation.drive() | ||
clock.tick(fps) | ||
|
||
pygame.quit() | ||
print(f"Speed: {(perf_counter()-start)/simulation.timer} secs/frame") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from invertedai.api.location import LocationResponse, location_info | ||
from invertedai.api.initialize import InitializeResponse, initialize | ||
from invertedai.api.drive import DriveResponse, drive | ||
from invertedai.api.initialize import InitializeResponse, initialize, async_initialize | ||
from invertedai.api.drive import DriveResponse, drive, async_drive | ||
from invertedai.api.light import light, LightResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.