Skip to content

Commit

Permalink
Vehicle gap metric (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adaickalavan authored Apr 22, 2023
1 parent 6a5db2e commit 2b1b0af
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 87 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Added engine `observation_workers` configuration which can be used to configure the number of parallel sensor workers: 0 runs the sensors on the local thread, >=1 runs using the multiprocessing backing.
- Added engine `sensor_parallelization` configuration of sensor parallelization backing, options ("mp"|"ray"): "mp" python multiprocessing, "ray" ray worker backing.
- Added engine `reset_retries` configuration engine retries before the simulator will raise an error on reset.
- Introduced new comfort metric in metric cost functions.
- Introduced new comfort cost function in metric module.
- Introduced new gap-between-vehicles cost function in metric module.
### Changed
- The trap manager, `TrapManager`, is now a subclass of `ActorCaptureManager`.
- Considering lane-change time ranges between 3s and 6s, assuming a speed of 13.89m/s, the via sensor lane acquisition range was increased from 40m to 80m, for better driving ability.
Expand All @@ -48,6 +49,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- In the metrics module, the records which is the raw metrics data and the scoring which is the formula to compute the final results are now separated to provided greater flexibility for applying metrics to different environments.
- Benchmark listing may specify specialised metric formula for each benchmark.
- Changed `benchmark_runner_v0.py` to only average records across scenarios that share the same environment. Records are not averaged across different environments, because the scoring formula may differ in different environments.
- Renamed GapBetweenVehicles cost to VehicleGap cost in metric module.
### Deprecated
### Fixed
- Fixed issues related to waypoints in junctions on Argoverse maps. Waypoints will now be generated for all paths leading through the lane(s) the vehicle is on.
Expand Down
4 changes: 2 additions & 2 deletions docs/benchmarks/driving_smarts_2023_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Train
$ cd <path>/SMARTS/examples/rl/platoon
$ python3.8 -m venv ./.venv
$ source ./.venv/bin/activate
$ pip install --upgrade pip wheel
$ pip install --upgrade pip
$ pip install -e ./../../../.[camera_obs,argoverse]
$ pip install -e ./inference/
Expand Down Expand Up @@ -246,7 +246,7 @@ Evaluate
$ cd <path>/SMARTS
$ python3.8 -m venv ./.venv
$ source ./.venv/bin/activate
$ pip install --upgrade pip wheel
$ pip install --upgrade pip
$ pip install -e .[camera_obs,argoverse]
$ scl zoo install examples/rl/platoon/inference
$ scl benchmark run driving_smarts_2023_3 examples.rl.platoon.inference:contrib-agent-v0 --auto-install
Expand Down
2 changes: 0 additions & 2 deletions examples/rl/platoon/train/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def step(self, action):
agent_obs["events"]["collisions"] | agent_obs["events"]["off_road"]
):
pass
elif agent_obs["events"]["agents_alive_done"]:
print(f"{agent_id}: Agents alive done triggered.")
elif agent_obs["events"]["actors_alive_done"]:
print(f"{agent_id}: Actors alive done triggered.")
else:
Expand Down
20 changes: 10 additions & 10 deletions smarts/benchmark/driving_smarts/v2023/metric_formula_platoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from smarts.env.gymnasium.wrappers.metric.params import (
Comfort,
DistToObstacles,
GapBetweenVehicles,
Params,
Steps,
VehicleGap,
)
from smarts.env.gymnasium.wrappers.metric.types import Record
from smarts.env.gymnasium.wrappers.metric.utils import (
Expand Down Expand Up @@ -63,10 +63,10 @@ def params(self) -> Params:
dist_to_obstacles=DistToObstacles(
active=False,
),
gap_between_vehicles=GapBetweenVehicles(
active=False,
interest="Leader-007",
), # TODO: Activate after implementing gap_between_vehicles cost function.
vehicle_gap=VehicleGap(
active=True,
actor="Leader-007",
),
steps=Steps(
active=False,
),
Expand All @@ -85,15 +85,15 @@ def score(self, records_sum: Dict[str, Dict[str, Record]]) -> Score:
+-------------------+--------+-----------------------------------------------------------+
| DistToDestination | [0, 1] | Remaining distance to destination. The lower, the better. |
+-------------------+--------+-----------------------------------------------------------+
| GapBetweenVehicles| [0, 1] | Gap between vehicles in a platoon. The higher, the better.|
| VehicleGap | [0, 1] | Gap between vehicles in a convoy. The lower, the better. |
+-------------------+--------+-----------------------------------------------------------+
| Humanness | [0, 1] | Humanness indicator. The higher, the better. |
+-------------------+--------+-----------------------------------------------------------+
| Rules | [0, 1] | Traffic rules compliance. The higher, the better. |
+-------------------+--------+-----------------------------------------------------------+
Returns:
Score: Contains "Overall", "DistToDestination", "GapBetweenVehicles",
Score: Contains "Overall", "DistToDestination", "VehicleGap",
"Humanness", and "Rules" scores.
"""

Expand Down Expand Up @@ -123,10 +123,10 @@ def score(self, records_sum: Dict[str, Dict[str, Record]]) -> Score:
dist_to_destination = costs_final.dist_to_destination
humanness = _humanness(costs=costs_final)
rules = _rules(costs=costs_final)
gap_between_vehicles = costs_final.gap_between_vehicles
vehicle_gap = costs_final.vehicle_gap
overall = (
0.50 * (1 - dist_to_destination)
+ 0.25 * gap_between_vehicles
+ 0.25 * (1 - vehicle_gap)
+ 0.20 * humanness
+ 0.05 * rules
)
Expand All @@ -135,7 +135,7 @@ def score(self, records_sum: Dict[str, Dict[str, Record]]) -> Score:
{
"overall": overall,
"dist_to_destination": dist_to_destination,
"gap_between_vehicles": gap_between_vehicles,
"vehicle_gap": vehicle_gap,
"humanness": humanness,
"rules": rules,
}
Expand Down
2 changes: 1 addition & 1 deletion smarts/env/gymnasium/driving_smarts_2023_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def resolve_agent_interface(agent_interface: AgentInterface):
)
max_episode_steps = 1000
waypoints_lookahead = 80
neighborhood_radius = 50
neighborhood_radius = 80
return AgentInterface(
accelerometer=True,
action=agent_interface.action,
Expand Down
2 changes: 1 addition & 1 deletion smarts/env/gymnasium/platoon_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def resolve_agent_interface(agent_interface: AgentInterface):
)
max_episode_steps = 1000
waypoints_lookahead = 80
neighborhood_radius = 50
neighborhood_radius = 80
return AgentInterface(
accelerometer=True,
action=agent_interface.action,
Expand Down
Loading

0 comments on commit 2b1b0af

Please sign in to comment.