diff --git a/car_dreamer/carla_stop_sign_env.py b/car_dreamer/carla_stop_sign_env.py index 74f1cfb..c7516b2 100644 --- a/car_dreamer/carla_stop_sign_env.py +++ b/car_dreamer/carla_stop_sign_env.py @@ -71,7 +71,7 @@ def calculate_traffic_light_violation_penalty(self): return 0.0 def violate_traffic_light(self): - if self.is_near_sepecific_stop_sign(self._config.traffic_locations): + if self.is_within_stop_sign_proximity(self._config.traffic_locations): self._stop_time += 1 self._entered = 1 elif self._entered == 1: # Mark the leaving @@ -80,23 +80,24 @@ def violate_traffic_light(self): if self._entered == 2 and self._stop_time < self._config.stopping_time: return True return False + + def is_within_stop_sign_proximity(self, sign_location): - def is_near_sepecific_stop_sign(self, sign_location): """ Check if the ego vehicle is near the stop sign. """ ego_location = np.array([*get_vehicle_pos(self.ego), 0.1]) distance = np.linalg.norm(ego_location - sign_location) - return distance <= self._config.stop_sign_near_threshold + return distance <= self._config.stop_sign_proximity_threshold def _is_ego_near_stop_sign(self, stop_sign: carla.Actor) -> bool: """Check if the ego vehicle is within the proximity threshold of the stop sign.""" ego_location = self.ego.get_location() stop_sign_location = stop_sign.get_location() distance = ego_location.distance(stop_sign_location) - return distance < self._config.stop_sign_near_threshold - + return distance < self._config.stop_sign_proximity_threshold + def handle_stop_sign(self): stop_signs = self._world._get_world().get_actors().filter("traffic.stop") for stop_sign in stop_signs: diff --git a/car_dreamer/toolkit/observer/handlers/renderer/birdeye_renderer.py b/car_dreamer/toolkit/observer/handlers/renderer/birdeye_renderer.py index d8455d8..8e57cbf 100644 --- a/car_dreamer/toolkit/observer/handlers/renderer/birdeye_renderer.py +++ b/car_dreamer/toolkit/observer/handlers/renderer/birdeye_renderer.py @@ -268,13 +268,6 @@ def _render_stop_signs(self, **env_state): self._render_stop_sign(self._surface, stop_sign, color) - # def _is_ego_near_stop_sign(self, stop_sign: carla.Actor) -> bool: - # """Check if the ego vehicle is within the proximity threshold of the stop sign.""" - # ego_location = self._ego.get_location() - # stop_sign_location = stop_sign.get_location() - # distance = ego_location.distance(stop_sign_location) - # return distance < self._stop_sign_near_threshold - def _render_stop_sign(self, surface, stop_sign: carla.Actor, color: Color): """Render a stop sign on the surface.""" world_pos = stop_sign.get_location()