-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update RL examples: Drive and VehicleFollowing (#2061)
- Loading branch information
1 parent
0dea7af
commit 1ad324b
Showing
28 changed files
with
593 additions
and
768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
# To import submission folder | ||
sys.path.insert(0, str(Path(__file__).resolve().parents[2])) | ||
# To import train folder | ||
sys.path.insert(0, str(Path(__file__).resolve().parents[0])) | ||
|
||
import gymnasium as gym | ||
|
||
from smarts.zoo.agent_spec import AgentSpec | ||
|
||
def make_env(env_id, scenario, agent_interface, config, seed): | ||
|
||
def make_env(env_id, scenario, agent_spec: AgentSpec, config, seed): | ||
from preprocess import Preprocess | ||
from reward import Reward | ||
from stable_baselines3.common.monitor import Monitor | ||
from train.reward import Reward | ||
|
||
from smarts.env.gymnasium.wrappers.api_reversion import Api021Reversion | ||
from smarts.env.gymnasium.wrappers.single_agent import SingleAgent | ||
|
||
env = gym.make( | ||
env_id, | ||
scenario=scenario, | ||
agent_interface=agent_interface, | ||
agent_interface=agent_spec.interface, | ||
seed=seed, | ||
sumo_headless=not config.sumo_gui, # If False, enables sumo-gui display. | ||
headless=not config.head, # If False, enables Envision display. | ||
) | ||
env = Reward(env) | ||
env = SingleAgent(env) | ||
env = Api021Reversion(env) | ||
env = Preprocess(env, agent_interface) | ||
env = Reward(env=env, crop=agent_spec.agent_params["crop"]) | ||
env = SingleAgent(env=env) | ||
env = Api021Reversion(env=env) | ||
env = Preprocess(env=env, agent_spec=agent_spec) | ||
env = Monitor(env) | ||
|
||
return env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.