Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "hiway-v1" interface #2033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions smarts/core/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,9 +1513,7 @@ def _check_ground_plane(self):
)
self._setup_pybullet_ground_plane(self._bullet_client)

def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
if not self._envision:
return
def _gen_envision_state(self, provider_state: ProviderState, obs, scores):

filter = self._envision.envision_state_filter

Expand Down Expand Up @@ -1671,6 +1669,12 @@ def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
ego_agent_ids=list(self._agent_manager.ego_agent_ids),
frame_time=self._rounder(self._elapsed_sim_time + self._total_sim_time),
)
return state

def _try_emit_envision_state(self, provider_state: ProviderState, obs, scores):
if not self._envision:
return
state = self._gen_envision_state(provider_state, obs, scores)
self._envision.send(state)

def _try_emit_visdom_obs(self, obs):
Expand Down
22 changes: 4 additions & 18 deletions smarts/env/gymnasium/hiway_env_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ class HiWayEnvV1(gym.Env):
action_space: spaces.Space
observation_space: spaces.Space

# Created
_np_random: Optional[np.random.Generator] = None

def __init__(
self,
scenarios: Sequence[str],
Expand Down Expand Up @@ -403,27 +400,16 @@ def close(self):
if self._smarts is not None:
self._smarts.destroy()

@property
def unwrapped(self) -> gym.Env[ObsType, ActType]:
"""Returns the base non-wrapped environment.
Returns:
Env: The base non-wrapped :class:`gymnasium.Env` instance
"""
return self

@property
def np_random(self) -> np.random.Generator:
"""Returns the environment's internal :attr:`_np_random` that if not set will initialise with a random seed.
Returns:
Instances of `np.random.Generator`.
"""
return super().np_random

@np_random.setter
def np_random(self, value: np.random.Generator):
self._np_random = value
warnings.warn(
"The generator in `np_random` is not used. This method will have no effect on the environment."
)
super()._np_random = value

def __str__(self):
"""Returns a string of the environment with :attr:`spec` id's if :attr:`spec`.
Expand Down