Skip to content

Commit 1a0edcb

Browse files
authored
Add vehicle configuration (#2130)
* Update truck urdf. * Update truck * Move assets from ``smarts.core.models` to `smarts.assets` * Renamed vehicle.urdf to sedan.urdf * Fix sedan vehicle urdf reference. * Update substitution configuration loading. * Allow vehicle composition. * Add missing scenario_definitions_filepath property * Add missing glb files. * Fix trajectory controller test. * Fix collision test. * Fix types test. * Include smarts/assets in manifest. * Add default truck definition. * Update test with truck. * Remove unused files. * Change [resources] to [assets]. * Retype moving_truck definitions to truck. * Rename vehicle_filepath -> vehicle_dynamics_filepath * Move MACOS gui BulletClient. * Remove color dependency on VEHICLE_CONFIGS. * Add visual_model_filepath argument to vehicle creation. * Fix missing argument. * Fix plan frame generation. * Update changelog. * Add type checking improvements. * Clean up vehicle methods. * Use PyYAML cast. * Update configuration with `SMARTS_ASSETS_DEFAULT_VEHICLE_DEFINITIONS_LIST` * Attempt typing test fix. * Attempt to fix typing test. * Add missing docstring. * Update AgentInterface with vehicle class. * Fix pytype types test. * Move all vehicle related assets to `smarts.assets.vehicles`. * Update truck urdf. * Fix base-tests. * Make format. * Fix types test. * Add moving truck to options. * Add trucks to tests. * Add pickup truck urdf. * Fix test that broke. * Update to final vehicle set. * Update documention. * Update engine configuration documentation. * Add information on creating a new vehicle configuration. * Lessen redirects in test-docs links stage. * Remove accidental method regression.
1 parent eafda3e commit 1a0edcb

File tree

85 files changed

+1743
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1743
-538
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Copy and pasting the git commit messages is __NOT__ enough.
1212
### Added
1313
- Added a utility method `SMARTS.prepare_observe_from()` which allows safely adding sensors to vehicles.
1414
- The following methods now exist explicitly `Vehicle.{add_sensor|detach_sensor|subscribed_to|sensor_property|}`.
15+
- Resources loaded with `load_yaml_config_with_substitution()` now substitute in SMARTS configuration with single squiggle bracket `${}` syntax. This is currently restricted to environment variable names prefixed with `"SMARTS_"`. This extends to benchmark configuration and vehicle configuration.
16+
- Default vehicle definitions can be now modified using `assets:default_vehicle_definitions_list`/`SMARTS_ASSSETS_DEFAULT_VEHICLE_DEFINITIONS_LIST` or by providing a `vehicle_definitions_list.yaml` in the scenario. These vehicle types are related to the `AgentInterface.vehicle_type` attribute.
1517
### Changed
1618
- `VehicleIndex.build_agent_vehicle()` no longer has `filename` and `surface_patches` parameters.
1719
- The following modules have been renamed: `envision.types` -> `envision.etypes`, `smarts.core.utils.logging` -> `smarts.core.utils.core_logging`, `smarts.core.utils.math` -> `smarts.core.utils.core_math`, `smarts.sstudio.types` -> `smarts.sstudio.sstypes`. For compatibility reasons they can still be imported by their original module name.
@@ -20,10 +22,21 @@ Copy and pasting the git commit messages is __NOT__ enough.
2022
- The `examples/e12_rllib` training examples `{pg_example|pg_pbt_example}.py` have been changed to `{ppo_example|ppo_pbt_example}.py`. `Policy Gradients (PG)` has been dropped in favor of the more well documented `Proximal Policy Optimization (PPO)`.
2123
- Vehicles can now have sensors added to, overwritten, or replaced outright.
2224
- Logging is now improved to give information about sensor changes in the sensor manager.
25+
- - Renamed `vehicle.urdf` to `sedan.urdf`.
26+
- Environment prefix is now configurable for custom `smarts.core.config()` calls.
27+
- `Vehicle.build_agent_vehicle()` argument `vehicle_filepath` now renamed to `vehicle_dynamics_filepath`.
28+
- Renamed `MACOS` `pybullet` gui utility from `smarts.core.utils.bullet.BulletClient` to `smarts.core.utils.pybullet.BulletClientMACOS`.
29+
- `Vehicle.build_agent_vehicle()` and `Vehicle.build_social_vehicle()` moved to `VehicleIndex`.
30+
- `smarts.core.configuration.Configuration.get_settings()` now uses the `PyYAML` default instead of forcefully casting to `str`.
31+
- Added `AgentInterface.vehicle_class` which allows selection of a dynamics vehicle from the vehicle definitions list file.
2332
### Deprecated
33+
- Module `smarts.core.models` is now deprecated in favour of `smarts.assets`.
34+
- Deprecated a few things related to vehicles in the `Scenario` class, including the `vehicle_filepath`, `tire_parameters_filepath`, and `controller_parameters_filepath`. The functionality is now handled through the vehicle definitions.
35+
- `AgentInterface.vehicle_type` is now deprecated with potential to be restored.
2436
### Fixed
2537
- `SumoTrafficSimulation` gives clearer reasons as to why it failed to connect to the TraCI server.
2638
- Suppressed an issue where `pybullet_utils.pybullet.BulletClient` would cause an error because it was catching a non `BaseException` type.
39+
- Fixed a bug where `smarts.core.vehicle_index.VehicleIndex.attach_sensors_to_vehicle()` would pass a method instead of a `PlanFrame` to the generated vehicle `SensorState`.
2740
- Fixed an issue where `AgentInterface.vehicle_type` would not affect agent vehicles when attempting to take over an existing vehicle.
2841
- Fixed a case where newly created agent vehicles would have a constant `"sedan"` size instead of the size of `AgentInterface.vehicle_type`.
2942
- Fixed a case where if vehicles are replaced they would not respect controller and vehicle parameters.

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
include smarts/core/glsl/*.vert smarts/core/glsl/*.frag
2-
include smarts/core/models/*.glb smarts/core/models/*.urdf
3-
include smarts/core/models/controller_parameters.yaml
42
include envision/web/dist/*
53
include smarts/*.ini
4+
recursive-include smarts/assets *.glb *.urdf *.yaml *.yml
65
recursive-include smarts/benchmark *.yaml *.yml
76
recursive-include smarts/ros/src *.launch *.msg *.srv package.xml CMakeLists.txt *.py
87
recursive-include smarts/scenarios *.xml *.py

docs/benchmarks/benchmark.rst

+1-14
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,5 @@ The benchmark listing file is organized as below.
108108
params: # Additional values to pass into the entrypoint as named keyword arguments.
109109
benchmark_config: ${{smarts.benchmark.driving_smarts.v2022}}/config.yaml
110110
111-
.. note::
112-
113-
Resolving module directories.
114111
115-
The benchmark configuration directory can be dynamically found through
116-
python using an evaluation syntax ``${{}}``. This is experimental and
117-
open to change but the following resolves the python module location in
118-
loaded configuration files:
119-
120-
.. code:: yaml
121-
122-
somewhere_path: ${{module.to.resolve}}/file.txt # resolves to <path>/module/to/resolve/file.txt
123-
124-
This avoids loading the module into python but resolves to the first
125-
path that matches the module.
112+
See :ref:`engine_configuration` for more details.

docs/conf.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@
4747
]
4848

4949
extlinks = {
50+
"assets": (
51+
"https://github.com/huawei-noah/SMARTS/tree/master/smarts/assets/%s",
52+
"%s",
53+
),
5054
"examples": (
51-
"https://github.com/huawei-noah/SMARTS/blob/master/examples/%s",
55+
"https://github.com/huawei-noah/SMARTS/tree/master/examples/%s",
5256
"%s",
5357
),
5458
"scenarios": (
55-
"https://github.com/huawei-noah/SMARTS/blob/master/scenarios/%s",
59+
"https://github.com/huawei-noah/SMARTS/tree/master/scenarios/%s",
5660
"%s",
5761
),
5862
}

docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ If you use SMARTS in your research, please cite the `paper <https://arxiv.org/ab
4646
sim/simulator.rst
4747
sim/scenario_studio.rst
4848
sim/bubbles.rst
49-
sim/configuration.rst
49+
sim/engine_configuration.rst
50+
sim/vehicle.rst
5051

5152
.. toctree::
5253
:hidden:

docs/sim/configuration.rst

-27
This file was deleted.

docs/sim/engine_configuration.rst

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.. _engine_configuration:
2+
3+
Configuration
4+
=============
5+
6+
7+
SMARTS
8+
------
9+
10+
You can change the behavior of the underlying SMARTS engine.
11+
12+
Configuration of the engine can come from several sources. These locations take precedence as noted:
13+
14+
1. Individual ``SMARTS_`` prefixed environment variables (e.g. ``SMARTS_SENSOR_WORKER_COUNT``)
15+
2. Local directory engine configuration (``./smarts_engine.ini``)
16+
3. Local user engine configuration, ``~/.smarts/engine.ini``, if local directory configuration is not found.
17+
4. Global engine configuration, ``/etc/smarts/engine.ini``, if local configuration is not found.
18+
5. Package default configuration, ``$PYTHON_PATH/smarts/engine.ini``, if global configuration is not found.
19+
20+
Note that configuration files resolve all settings at the first found configuration file (they do not layer.)
21+
22+
23+
Options
24+
-------
25+
26+
All settings demonstrated as environment variables are formatted to ``UPPERCASE`` and prefixed with ``SMARTS_`` (e.g. ``[core] logging`` can be configured with ``SMARTS_CORE_LOGGING``)
27+
28+
These settings are as follows:
29+
30+
.. todo::
31+
32+
List engine settings
33+
34+
35+
YAML resources
36+
--------------
37+
38+
YAML files resolve as `PyYAML.safe_load() <https://pyyaml.org/wiki/PyYAMLDocumentation>` allows with a few extensions.
39+
40+
Dynamic module resolution
41+
^^^^^^^^^^^^^^^^^^^^^^^^^
42+
43+
The benchmark configuration directory can be dynamically found through
44+
python using an evaluation syntax ``${{}}``. This is experimental and
45+
open to change but the following resolves the python module location in
46+
loaded configuration files:
47+
48+
.. code:: yaml
49+
50+
somewhere_path: ${{module.to.resolve}}/file.txt # resolves to <path>/module/to/resolve/file.txt
51+
52+
53+
This avoids loading the module into python but resolves to the first
54+
path that matches the module.
55+
56+
Environment variable resolution
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
Resolving SMARTS engine configuration.
60+
61+
The engine configuration resolves by referencing the setting through
62+
the evaluation syntax ``${}``. This is restricted to ``"SMARTS_"``
63+
prefixed environment variables.
64+
65+
.. code:: yaml
66+
67+
is_debug: ${SMARTS_CORE_DEBUG} # literal environment variable or engine setting `[core] debug`
68+

docs/sim/vehicle.rst

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
.. _vehicle_defaults:
2+
3+
4+
Vehicle defaults
5+
================
6+
7+
``SMARTS`` provides vehicle configuration for agent control.
8+
9+
10+
Default agent vehicle details
11+
-----------------------------
12+
13+
.. list-table::
14+
:header-rows: 1
15+
16+
* - **Vehicle**
17+
- Sedan (Default)
18+
- Bus (class 4)
19+
- Pickup truck (class 2a)
20+
- Empty moving truck (class 5)
21+
- Loaded moving truck (class 5)
22+
* - **Resource**
23+
- "sedan" | "generic_sedan"
24+
- "bus" | "generic_bus"
25+
- "pickup" | "generic_pickup_truck"
26+
- "moving_truck_empty"
27+
- "moving_truck_loaded"
28+
* - **Dimensions** (LWH)
29+
- 3.68 1.47 1.30
30+
- 7.00 2.20 2.40
31+
- 5.00 1.91 1.89
32+
- 7.10 2.40 2.40
33+
- 7.10 2.40 2.40
34+
* - **Mass** (kg)
35+
- 2356.00
36+
- 6000.00
37+
- 2600.00
38+
- 6500.00
39+
- 8700.00
40+
41+
42+
Note that the dimensions do not take into account elevation due to the wheels.
43+
44+
.. note::
45+
46+
See also :assets:`vehicles/vehicle_definitions_list.yaml` and `truck classifications <https://en.wikipedia.org/wiki/Truck_classification>`.
47+
48+
49+
Specifying vehicle definitions
50+
------------------------------
51+
52+
Vehicles can be configured in a few different ways.
53+
54+
55+
Configuration file
56+
^^^^^^^^^^^^^^^^^^
57+
58+
.. code-block:: ini
59+
60+
[assets]
61+
default_vehicle_definitions_list = path/to/file.yaml
62+
63+
.. note::
64+
65+
See also :ref:`engine_configuration`.
66+
67+
68+
Environment variable
69+
^^^^^^^^^^^^^^^^^^^^
70+
71+
Setting ``SMARTS_ASSETS_DEFAULT_VEHICLE_DEFINITIONS_LIST`` will cause ``SMARTS`` to use the given vehicle definitions file as the default vehicle definitions.
72+
73+
.. note::
74+
75+
See also :ref:`engine_configuration`.
76+
77+
78+
Scenario
79+
^^^^^^^^
80+
81+
Including a ``vehicle_definitions_list.yaml`` in your scenario will cause ``SMARTS`` to use those vehicle definitions for the duration of the scenario.
82+
83+
.. code-block:: bash
84+
85+
$ tree scenarios/sumo/loop
86+
scenarios/sumo/loop
87+
├── build
88+
│ └── ...
89+
├── map.net.xml
90+
├── rerouter.add.xml
91+
├── scenario.py
92+
└── vehicle_definitions_list.yaml # <---
93+
94+
95+
Usage
96+
-----
97+
98+
Agent interface
99+
^^^^^^^^^^^^^^^
100+
101+
.. code-block:: python
102+
103+
from smarts.core.agent_interface import AgentInterface
104+
from smarts.core.controllers import ActionSpaceType
105+
106+
agent_interface = AgentInterface(
107+
max_episode_steps=1000,
108+
waypoint_paths=True,
109+
vehicle_class="pickup",
110+
action=ActionSpaceType.Continuous,
111+
)
112+
113+
.. note::
114+
115+
See also :ref:`agent`.
116+
117+
118+
Syntax
119+
------
120+
121+
A vehicle can be composed in the following way:
122+
123+
124+
.. code-block:: yaml
125+
126+
# vehicle_definitions_list.yaml
127+
f150: /usr/home/dev/vehicles/f150.yaml
128+
129+
130+
.. code-block:: yaml
131+
132+
# /usr/home/dev/vehicles/f150.yaml
133+
model: Ford F-150
134+
type: truck
135+
controller_params: ${SMARTS_ASSETS_PATH}/vehicles/controller_params/generic_pickup_truck.yaml
136+
chassis_params: ${SMARTS_ASSETS_PATH}/vehicles/chassis_params/generic_pickup_truck.yaml
137+
dynamics_model: /usr/home/dev/vehicles/f150_loaded.urdf
138+
visual_model: /usr/home/dev/vehicles/f150.glb
139+
tire_params: null # ${SMARTS_ASSETS_PATH}/vehicles/tire_params/base_tire_parameters.yaml
140+
141+
142+
.. note::
143+
144+
See :ref:`engine_configuration` for details about how YAML is resolved.
145+
146+
147+
.. note::
148+
149+
See :assets:`vehicles/controller_params/generic_pickup_truck.yaml` and :assets:`vehicles/chassis_params/generic_pickup_truck.yaml`.
150+

envision/server.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"Missing dependencies for Envision. Install them using the command `pip install -e .[envision]` at the source directory."
4747
)
4848

49-
import smarts.core.models
49+
import smarts.assets.vehicles.visual_model
5050
from envision.web import dist as web_dist
5151
from smarts.core.utils.file import path2hash
5252

@@ -473,11 +473,13 @@ def initialize(self):
473473
async def get(self, id_):
474474
"""Serve the requested model geometry."""
475475
if id_ not in self._path_map or not pkg_resources.is_resource(
476-
smarts.core.models, self._path_map[id_]
476+
smarts.assets.vehicles.visual_model, self._path_map[id_]
477477
):
478478
raise tornado.web.HTTPError(404, f"GLB Model `{id_}` not found.")
479479

480-
with pkg_resources.path(smarts.core.models, self._path_map[id_]) as path:
480+
with pkg_resources.path(
481+
smarts.assets.vehicles.visual_model, self._path_map[id_]
482+
) as path:
481483
await self.serve_chunked(path)
482484

483485

0 commit comments

Comments
 (0)