Skip to content

Commit

Permalink
Merge pull request #106 from inverted-ai/master
Browse files Browse the repository at this point in the history
update docs
  • Loading branch information
AlirezaMorsali committed Jan 6, 2023
2 parents 04996ee + dc8272b commit 4925151
Show file tree
Hide file tree
Showing 5 changed files with 1,754 additions and 5 deletions.
1,726 changes: 1,726 additions & 0 deletions examples/IAI_demo.ipynb

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion invertedai/api/drive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from typing import List, Optional
from typing import List, Optional, Tuple
from pydantic import BaseModel, validate_arguments

import invertedai as iai
Expand Down Expand Up @@ -50,6 +50,8 @@ def drive(
recurrent_states: List[RecurrentState],
traffic_lights_states: Optional[TrafficLightStatesDict] = None,
get_birdview: bool = False,
rendering_center: Optional[Tuple[float, float]] = None,
rendering_fov: Optional[float] = None,
get_infractions: bool = False,
random_seed: Optional[int] = None,
) -> DriveResponse:
Expand Down Expand Up @@ -78,6 +80,12 @@ def drive(
Whether to return an image visualizing the simulation state.
This is very slow and should only be used for debugging.
rendering_center:
Optional center coordinates for the rendered birdview.
rendering_fov:
Optional fov for the rendered birdview.
get_infractions:
Whether to check predicted agent states for infractions.
This introduces some overhead, but it should be relatively small.
Expand Down Expand Up @@ -133,6 +141,8 @@ def _tolist(input_data: List):
get_birdview=get_birdview,
get_infractions=get_infractions,
random_seed=random_seed,
rendering_center=rendering_center,
rendering_fov=rendering_fov
)
start = time.time()
timeout = TIMEOUT
Expand Down
7 changes: 6 additions & 1 deletion invertedai/api/initialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from pydantic import BaseModel, validate_arguments, root_validator
from typing import List, Optional, Dict
from typing import List, Optional, Dict, Tuple

import invertedai as iai
from invertedai.api.config import TIMEOUT, should_use_mock_api
Expand Down Expand Up @@ -51,6 +51,7 @@ def initialize(
List[TrafficLightStatesDict]
] = None,
get_birdview: bool = False,
location_of_interest: Optional[Tuple[float, float]] = None,
get_infractions: bool = False,
agent_count: Optional[int] = None,
random_seed: Optional[int] = None,
Expand Down Expand Up @@ -83,6 +84,9 @@ def initialize(
History of traffic light states - the list is over time, in chronological order.
Traffic light states should be provided for all time steps where agent states are specified.
location_of_interest:
Optional coordinates for spawning agents with the given location as center instead of the default map center
get_birdview:
If True, a birdview image will be returned representing the current world. Note this will significantly
impact on the latency.
Expand Down Expand Up @@ -141,6 +145,7 @@ def initialize(
else [state.tolist() for state in agent_attributes],
traffic_light_state_history=traffic_light_state_history,
get_birdview=get_birdview,
location_of_interest=location_of_interest,
get_infractions=get_infractions,
random_seed=random_seed,
)
Expand Down
12 changes: 10 additions & 2 deletions invertedai/api/location.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from pydantic import BaseModel, validate_arguments
from typing import Optional, List
from typing import Optional, List, Tuple

import invertedai as iai
from invertedai.api.config import TIMEOUT, should_use_mock_api
Expand Down Expand Up @@ -30,6 +30,8 @@ class LocationResponse(BaseModel):
def location_info(
location: str,
include_map_source: bool = False,
rendering_fov: Optional[int] = None,
rendering_center: Optional[Tuple[float, float]] = None,
) -> LocationResponse:
"""
Provides static information about a given location.
Expand All @@ -43,6 +45,11 @@ def location_info(
Whether to return full map specification in Lanelet2 OSM format.
This significantly increases the response size, consuming more network resources.
rendering_fov:
Optional fov for both x and y axis for the rendered birdview in meters.
rendering_center:
Optional center x,y coordinates for the rendered birdview.
See Also
--------
:func:`drive`
Expand All @@ -64,7 +71,8 @@ def location_info(
start = time.time()
timeout = TIMEOUT

params = {"location": location, "include_map_source": include_map_source}
params = {"location": location, "include_map_source": include_map_source, "rendering_fov": rendering_fov,
"rendering_center": ",".join([str(rendering_center[0]), str(rendering_center[1])]) if rendering_center else rendering_center}
while True:
try:
response = iai.session.request(model="location_info", params=params)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "invertedai"
version = "0.0.6post2"
version = "0.0.7"
description = "Client SDK for InvertedAI"
authors = ["Inverted AI <info@inverted.ai>"]
readme = "README.md"
Expand Down

0 comments on commit 4925151

Please sign in to comment.