-
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 #122 from inverted-ai/develop
Develop
- Loading branch information
Showing
13 changed files
with
404 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import argparse | ||
import invertedai as iai | ||
from 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
4 changes: 2 additions & 2 deletions
4
invertedai/simulation/regions.py → examples/simulation/regions.py
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
File renamed without changes.
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 was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
#!/bin/bash | ||
|
||
# Install the package using Poetry | ||
poetry install --without dev,docs | ||
|
||
# Source the .env file for API keys | ||
# source .env | ||
|
||
# Activate the virtual environment | ||
source "$(poetry env info --path)/bin/activate" | ||
|
||
# Run pytest | ||
pytest | ||
|
||
# Deactivate the virtual environment | ||
deactivate | ||
|
||
# Remove the virtual environment | ||
rm -rf "$(poetry env info --path)" |
Oops, something went wrong.