Skip to content

Commit

Permalink
move simulators and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaMorsali committed Oct 18, 2022
1 parent 21cd047 commit c25fd7c
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 227 deletions.
21 changes: 0 additions & 21 deletions docs/source/.modules/invertedai_carlasim.rst

This file was deleted.

21 changes: 0 additions & 21 deletions docs/source/.modules/invertedai_drive.rst

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/.modules/modules.rst

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/carlasim.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# CARLA Integration

## Carla Env

```{eval-rst}
.. automodule:: invertedai.simulators.carla_simulator
:members:
:undoc-members:
:show-inheritance:
```
2 changes: 1 addition & 1 deletion docs/source/getstarted/gs-drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This model can drive all the agents with only the current state of the environment, i.e., one step observations (which could be obtained from **{ref}`INITIALIZE`**) or with multiple past observations.
```python
response = iai.drive(
location="CARLA:Town03:Roundabout",
location="iai:ubc_roundabout",
agent_attributes=response["attributes"],
states=response["states"],
recurrent_states=response["recurrent_states"],
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getstarted/gs-initialize.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Inverted AI provides the {ref}`INITIALIZE`, a state-of-the-art model trained wit
generates initial conditions (position and speed) for all the agents including the ego vehicle
```python
response = iai.initialize(
location="CARLA:Town03:Roundabout",
location="iai:ubc_roundabout",
agent_count=10,
)
```
Expand Down
11 changes: 2 additions & 9 deletions docs/source/getstarted/gs-mapinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

Inverted AI provides an assortment of diverse road configurations and geometries, including real-world locations and maps from simulators (CARLA, Huawei SMARTS, ...).

## AVAILABLE-LOCATIONS
To search the catalog for available maps to your account (API key) use **{ref}`AVAILABLE-LOCATIONS`** method by providing keywords
```python
iai.available_locations("roundabout", "carla")
```

## LOCATION_INFO
To get information about a scene use **{ref}`LOCATION_INFO`**.
```python
iai.location_info("CARLA:Town03:Roundabout")
iai.location_info("iai:ubc_roundabout")
```
The scene information include the map in [Lanelet2](https://github.com/fzi-forschungszentrum-informatik/Lanelet2) format, map in JPEG format, maximum number of allowed (driveable) vehicles, latitude longitude coordinates (for real-world locations), id and list of traffic light and signs (if any exist in the map), etc.


---
{ref}`LOCATION_INFO`, {ref}`AVAILABLE-LOCATIONS`: more information about the python SDK.\
{ref}`LOCATION_INFO`: more information about the python SDK.\
{ref}`REST API`: more information about the REST API and other programming languages.


Expand Down
12 changes: 5 additions & 7 deletions docs/source/getstarted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ iai.add_apikey("XXXXXXXXXXXXXX")
Initialize the agents:
```python
response = iai.initialize(
location="CARLA:Town03:Roundabout",
location="iai:ubc_roundabout",
agent_count=10,
)
```
Drive the agents:
```python
response = iai.drive(
location="CARLA:Town03:Roundabout",
agent_attributes=response["attributes"],
states=response["states"],
recurrent_states=response["recurrent_states"],
traffic_states_id=response["traffic_states_id"],
steps=1,
location="iai:ubc_roundabout",
agent_attributes=agent_attributes,
agent_states=response.agent_states,
recurrent_states=response.recurrent_states,
get_birdviews=True,
get_infractions=True,
)
Expand Down
1 change: 0 additions & 1 deletion docs/source/pythonapi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
sdk-drive
sdk-initialize
sdk-available-locations
sdk-location-info
sdk-dataclasses
```
Expand Down
7 changes: 0 additions & 7 deletions docs/source/pythonapi/sdk-available-locations.md

This file was deleted.

12 changes: 5 additions & 7 deletions examples/Demo_Drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,23 @@

parser = argparse.ArgumentParser(description="Simulation Parameters.")
parser.add_argument("--api_key", type=str, default="")
parser.add_argument("--location", type=str, default="CARLA:Town03:Roundabout")
parser.add_argument("--location", type=str, default="iai:ubc_roundabout")
args = parser.parse_args()

iai.add_apikey("")

response = iai.available_locations("carla", "roundabout")
response = iai.location_info(location=args.location)

file_name = args.location.replace(":", "_")
if response.lanelet_map_source is not None:
if response.osm_map is not None:
file_path = f"{file_name}.osm"
with open(file_path, "w") as f:
f.write(response.lanelet_map_source)
if response.rendered_map is not None:
f.write(response.osm_map[0])
if response.birdview_image is not None:
file_path = f"{file_name}.jpg"
rendered_map = np.array(response.rendered_map, dtype=np.uint8)
rendered_map = np.array(response.birdview_image, dtype=np.uint8)
image = cv2.imdecode(rendered_map, cv2.IMREAD_COLOR)
cv2.imwrite(file_path, image)

response = iai.initialize(
location=args.location,
agent_count=10,
Expand Down
Binary file modified examples/iai-drive.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions invertedai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
drive,
initialize,
location_info,
available_locations,
)
from invertedai.utils import Jupyter_Render, IAILogger, Session

Expand All @@ -27,16 +26,6 @@
"location_info": ("get", "/location_info"),
"available_locations": ("get", "/available_locations"),
}
try:
from invertedai.simulators import CarlaEnv, CarlaSimulationConfig
except:
logger.warning(
"Cannot import CarlaEnv\n"
+ "Carla Python API is not installed\n"
+ "Ignore these warnings if you are not running Carla"
)


__all__ = [
"drive",
"initialize",
Expand All @@ -46,5 +35,4 @@
"session",
"add_apikey",
"location_info",
"available_locations",
]

0 comments on commit c25fd7c

Please sign in to comment.