-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from f1tenth/109-v100-waypoint-follow-example…
…-results-in-frequent-crashes
- Loading branch information
Showing
10 changed files
with
47 additions
and
266 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from __future__ import annotations | ||
from f110_gym.envs.reset.masked_reset import GridResetFn, AllTrackResetFn | ||
from f110_gym.envs.reset.reset_fn import ResetFn | ||
from f110_gym.envs.track import Track | ||
|
||
|
||
def make_reset_fn(type: str, track: Track, num_agents: int, **kwargs) -> ResetFn: | ||
if type == "grid_static": | ||
return GridResetFn(track=track, num_agents=num_agents, shuffle=False, **kwargs) | ||
elif type == "grid_random": | ||
return GridResetFn(track=track, num_agents=num_agents, shuffle=True, **kwargs) | ||
elif type == "random_static": | ||
return AllTrackResetFn( | ||
track=track, num_agents=num_agents, shuffle=False, **kwargs | ||
) | ||
elif type == "random_random": | ||
return AllTrackResetFn( | ||
track=track, num_agents=num_agents, shuffle=True, **kwargs | ||
) | ||
else: | ||
raise ValueError(f"invalid reset type {type}") | ||
def make_reset_fn(type: str | None, track: Track, num_agents: int, **kwargs) -> ResetFn: | ||
type = type or "rl_grid_static" | ||
|
||
try: | ||
refline_token, reset_token, shuffle_token = type.split("_") | ||
|
||
refline = {"cl": track.centerline, "rl": track.raceline}[refline_token] | ||
reset_fn = {"grid": GridResetFn, "random": AllTrackResetFn}[reset_token] | ||
shuffle = {"static": False, "random": True}[shuffle_token] | ||
options = {"cl": {"move_laterally": True}, "rl": {"move_laterally": False}}[refline_token] | ||
|
||
except Exception as ex: | ||
raise ValueError(f"Invalid reset function type: {type}. Expected format: <refline>_<resetfn>_<shuffle>") from ex | ||
|
||
return reset_fn(reference_line=refline, num_agents=num_agents, shuffle=shuffle, **options, **kwargs) |
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
Oops, something went wrong.