Skip to content

Commit

Permalink
Set one goal per controlled vehicle in ParkingEnv
Browse files Browse the repository at this point in the history
Fix #593
  • Loading branch information
eleurent committed Apr 27, 2024
1 parent af23919 commit 421eeee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion highway_env/envs/common/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def observe(self) -> Dict[str, np.ndarray]:
pd.DataFrame.from_records([self.observer_vehicle.to_dict()])[self.features]
)
goal = np.ravel(
pd.DataFrame.from_records([self.env.goal.to_dict()])[self.features]
pd.DataFrame.from_records([self.observer_vehicle.goal.to_dict()])[self.features]
)
obs = OrderedDict(
[
Expand Down
15 changes: 8 additions & 7 deletions highway_env/envs/parking_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ def _create_vehicles(self) -> None:
empty_spots.remove(vehicle.lane_index)

# Goal
lane_index = empty_spots[self.np_random.choice(np.arange(len(empty_spots)))]
lane = self.road.network.get_lane(lane_index)
self.goal = Landmark(
self.road, lane.position(lane.length / 2, 0), heading=lane.heading
)
self.road.objects.append(self.goal)
empty_spots.remove(lane_index)
for vehicle in self.controlled_vehicles:
lane_index = empty_spots[self.np_random.choice(np.arange(len(empty_spots)))]
lane = self.road.network.get_lane(lane_index)
vehicle.goal = Landmark(
self.road, lane.position(lane.length / 2, 0), heading=lane.heading
)
self.road.objects.append(vehicle.goal)
empty_spots.remove(lane_index)

# Other vehicles
for i in range(self.config["vehicles_count"]):
Expand Down

0 comments on commit 421eeee

Please sign in to comment.