diff --git a/README.md b/README.md index 05a87b0..9bd8b76 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ If you find this repository useful, please cite this paper: Special thanks to the community for your valuable contributions and support in making CarDreamer better for everyone! + diff --git a/car_dreamer/__init__.py b/car_dreamer/__init__.py index 152f1ff..962d8f2 100644 --- a/car_dreamer/__init__.py +++ b/car_dreamer/__init__.py @@ -15,6 +15,7 @@ from .carla_navigation_env import CarlaNavigationEnv from .carla_overtake_env import CarlaOvertakeEnv from .carla_right_turn_env import CarlaRightTurnEnv +from .carla_right_turn_random_env import CarlaRightTurnRandomEnv from .carla_roundabout_env import CarlaRoundaboutEnv from .carla_stop_sign_env import CarlaStopSignEnv from .carla_traffic_lights_env import CarlaTrafficLightsEnv diff --git a/car_dreamer/carla_right_turn_random_env.py b/car_dreamer/carla_right_turn_random_env.py new file mode 100644 index 0000000..8c6b2de --- /dev/null +++ b/car_dreamer/carla_right_turn_random_env.py @@ -0,0 +1,31 @@ +import random +import time +from collections import deque + +import carla + +from .carla_wpt_fixed_env import CarlaWptFixedEnv +from .toolkit import FixedPathPlanner, get_vehicle_pos + + +class CarlaRightTurnRandomEnv(CarlaWptFixedEnv): + """ + Vehicle passes the crossing (random turn right) and avoid collision. + + **Provided Tasks**: ``carla_right_turn_random`` + """ + + def __init__(self, config): + super().__init__(config) + + def on_reset(self) -> None: + random.seed(time.time()) + random_index = random.randint(0, len(self._config.lane_start_point) - 1) + self.ego_src = self._config.lane_start_point[random_index] + ego_transform = carla.Transform(carla.Location(*self.ego_src[:3]), carla.Rotation(yaw=self.ego_src[3])) + self.ego = self._world.spawn_actor(transform=ego_transform) + self.ego_path = self._config.ego_path[random_index] + self.use_road_waypoints = self._config.use_road_waypoints + self.ego_planner = FixedPathPlanner(vehicle=self.ego, vehicle_path=self.ego_path, use_road_waypoints=self.use_road_waypoints) + self.waypoints, self.planner_stats = self.ego_planner.run_step() + self.num_completed = self.planner_stats["num_completed"] diff --git a/car_dreamer/configs/tasks.yaml b/car_dreamer/configs/tasks.yaml index 6d3be82..7d9eb00 100644 --- a/car_dreamer/configs/tasks.yaml +++ b/car_dreamer/configs/tasks.yaml @@ -149,6 +149,40 @@ carla_right_turn_hard: env.min_flow_dist: 6 env.max_flow_dist: 8 +carla_right_turn_random: + env: + world: + town: Town03 + name: CarlaRightTurnRandomEnv-v0 + action: + discrete_steer: [-0.9, -0.3, 0.0, 0.3, 0.9] + observation.enabled: [camera, collision, birdeye_wpt] + <<: *carla_wpt + lane_start_point: + [ + [-33.8, -135.1, 0.1, 0.0], + [-3.2, -165.2, 0.1, 90], + [9.3, -106.2, 0.1, -90] + ] + ego_path: + [ + [[-33.8, -135.1, 0.1], [-5.0, -110.3, 0.1]], + [[-3.2, -165.2, 0.1, 90], [-20.7, -142.2, 0.1, 180]], + [[9.3, -106.2, 0.1, -90], [31.3, -130.7, 0.1, 0]] + ] + use_road_waypoints: [True, False] + + dreamerv3: + encoder.cnn_keys: "birdeye_wpt" + decoder.cnn_keys: "birdeye_wpt" + run.log_keys_video: [camera, birdeye_wpt] + + dreamerv2: + encoder.cnn_keys: "birdeye_wpt" + decoder.cnn_keys: "birdeye_wpt" + decoder.cnn_kernels: [5, 5, 5, 6, 6] + train.log_keys_video: [camera, birdeye_wpt] + carla_left_turn_simple: &carla_left_turn_simple env: world: