huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
951 stars 190 forks source link

Vehicle starts on road shoulder #1218

Open Adaickalavan opened 2 years ago

Adaickalavan commented 2 years ago

BUG REPORT

Let done_criteria to include on_shoulder=True.

https://github.com/huawei-noah/SMARTS/blob/1258f7e671f2e4bc2daefecb99fed816b1b46ccd/smarts/core/smarts.py#L350-L356

The smarts reset code is shown above. Here, when the vehicle appears and returns observations_for_ego, it is sometimes already done=True as the observations_for_ego.events.on_shoulder=True. Simply put, the vehicle appeared on road shoulder. Hence, the subsequent first call to step after reset will throw error as the agent is already done.

Furthermore, self._step_count is incremented in every call to self.step({}) inside the reset function, causing a non-zero step count right after reset returns. Hence, agents can become done earlier than the maximum-steps-per-episode configuration.

SMARTS version 0.4.18.

Steps to reproduce the bug Set done_criteria to include on_shoulder=True.

Resulting and expected behaviour Vehicle should preferably not start on road shoulder.

Impact [If known] If this is not fixed, then done_criteria cannot include on_shoulder condition.

Gamenot commented 2 years ago

This appears to be an issue with translating to Gym reset that we can have an agent done before reaching the first Gym step. I am not quite sure how to deal with this issue. I think Gym requires a valid initial state to be available after reset so the requirement in order to satisfy Gym might be to force the vehicle into a valid initial state based on the done_criteria or to warn and defer the done until the first Gym step.