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

Add transmission error rate in intention sharing. #11

Merged
merged 5 commits into from
Aug 24, 2024
Merged
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
14 changes: 14 additions & 0 deletions car_dreamer/configs/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ env:
stop_signs,
]

birdeye_error_wpt:
handler: birdeye
key: birdeye_error_wpt
shape: [128, 128, 3]
obs_range: 32
ego_offset: 12
camera_fov: 150
observability: full
color_by_obs: False
waypoint_obs: visible
extend_wpt: False
error_rate: 0.2
entities: [roadmap, waypoints, error_background_waypoints, ego_vehicle, background_vehicles]

display:
enable: True
render_keys: [camera, birdeye_wpt]
Expand Down
8 changes: 4 additions & 4 deletions car_dreamer/configs/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ carla_right_turn_simple: &carla_right_turn_simple
name: CarlaRightTurnEnv-v0
action:
discrete_steer: [-0.9, -0.3, 0.0, 0.3, 0.9]
observation.enabled: [camera, collision, birdeye_wpt]
observation.enabled: [camera, collision, birdeye_error_wpt]
<<: *carla_wpt
lane_start_point: [-33.8, -135.1, 0.1, 0.0]
ego_path: [[-33.8, -135.1, 0.1], [-5.0, -110.3, 0.1]]
use_road_waypoints: [True, False]
flow_spawn_point: [-3.4, -151.2, 0.1, 90.0]

dreamerv3:
encoder.cnn_keys: "birdeye_wpt"
decoder.cnn_keys: "birdeye_wpt"
run.log_keys_video: [camera, birdeye_wpt]
encoder.cnn_keys: "birdeye_error_wpt"
decoder.cnn_keys: "birdeye_error_wpt"
run.log_keys_video: [camera, birdeye_error_wpt]

dreamerv2:
encoder.cnn_keys: "birdeye_wpt"
Expand Down
2 changes: 2 additions & 0 deletions car_dreamer/toolkit/observer/handlers/birdeye_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def get_observation(self, env_state: Dict) -> Tuple[Dict, Dict]:
"messages_color": messages_color,
"extend_waypoints": self._config.extend_wpt,
}
if hasattr(self._config, 'error_rate'):
env_state['error_rate'] = self._config.error_rate
self._birdeye_render.render(self.surface, entities, env_state)
birdeye = self.surface

Expand Down
30 changes: 30 additions & 0 deletions car_dreamer/toolkit/observer/handlers/renderer/birdeye_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import carla
import cv2
import random
import numpy as np


from ....carla_manager import ActorPolygon, Command, WorldManager
from ..utils import should_filter
from .constants import BirdeyeEntity, Color
Expand Down Expand Up @@ -170,6 +172,33 @@ def _render_background_waypoints(self, **env_state):
last = path[-1]
path.append((last[0], last[1] - 10.0))
self._render_path(self._surface, vehicle_polygon, path, waypoint_color)

def _render_error_background_waypoints(self, **env_state):
"""Render the waypoints with error for background actors on the surface."""
color = env_state.get('background_waypoints_color')
extend_waypoints = env_state.get('extend_waypoints', False)
error_rate = env_state.get('error_rate')
background_waypoints = self._world_manager.actor_actions
background_waypoints = {
id: [(action[1].transform.location.x, action[1].transform.location.y) for action in actions]
for id, actions in background_waypoints.items() if actions
}
vehicle_polygons = self._world_manager.actor_polygons

for vehicle_id, path in background_waypoints.items():
if vehicle_id == self._ego.id or should_filter(self._ego.get_transform(), self._world_manager.actor_transforms[vehicle_id]):
continue
vehicle_polygon = vehicle_polygons.get(vehicle_id, None)
if vehicle_polygon is None:
continue
waypoint_color = color.get(vehicle_id, None)
if waypoint_color is None:
continue
if extend_waypoints:
last = path[-1]
path.append((last[0], last[1] - 10.0))
if random.random() > error_rate:
self._render_path(self._surface, vehicle_polygon, path, waypoint_color)

def _render_messages(self, **env_state):
"""
Expand Down Expand Up @@ -356,4 +385,5 @@ def _render_path(
BirdeyeEntity.TRAFFIC_LIGHTS: _render_traffic_lights,
BirdeyeEntity.STOP_SIGNS: _render_stop_signs,
BirdeyeEntity.MESSAGES: _render_messages,
BirdeyeEntity.ERROR_BACKGROUND_WAYPOINTS: _render_error_background_waypoints,
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ class BirdeyeEntity(Enum):
TRAFFIC_LIGHTS = "traffic_lights"
STOP_SIGNS = "stop_signs"
MESSAGES = "messages"
ERROR_BACKGROUND_WAYPOINTS = "error_background_waypoints"
Loading