Skip to content

Commit

Permalink
Merge pull request #9 from liamjxu/master
Browse files Browse the repository at this point in the history
Carla Right Turn Random Env
  • Loading branch information
HanchuZhou authored Aug 17, 2024
2 parents aabd9fa + d10218b commit 8bb4a66
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
<!-- readme: contributors -start -->
<table>
<tbody>
<tr>
Expand Down
1 change: 1 addition & 0 deletions car_dreamer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions car_dreamer/carla_right_turn_random_env.py
Original file line number Diff line number Diff line change
@@ -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"]
34 changes: 34 additions & 0 deletions car_dreamer/configs/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8bb4a66

Please sign in to comment.