Skip to content

Commit b96661b

Browse files
committed
use unwrapped env for context updates
1 parent c72734b commit b96661b

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

carl/envs/gymnasium/box2d/carl_bipedal_walker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ def _update_context(self) -> None:
114114
gravity_y = self.context["GRAVITY_Y"]
115115

116116
gravity = (gravity_x, gravity_y)
117-
self.env.world.gravity = gravity
117+
self.env.unwrapped.world.gravity = gravity
118118

119119
# Important for building terrain
120-
self.env.fd_polygon = fixtureDef(
120+
self.env.unwrapped.fd_polygon = fixtureDef(
121121
shape=polygonShape(vertices=[(0, 0), (1, 0), (1, -1), (0, -1)]),
122122
friction=bipedal_walker.FRICTION,
123123
)
124-
self.env.fd_edge = fixtureDef(
124+
self.env.unwrapped.fd_edge = fixtureDef(
125125
shape=edgeShape(vertices=[(0, 0), (1, 1)]),
126126
friction=bipedal_walker.FRICTION,
127127
categoryBits=0x0001,
@@ -154,4 +154,4 @@ def _update_context(self) -> None:
154154
maskBits=0x001,
155155
)
156156

157-
self.env.world.gravity = gravity
157+
self.env.unwrapped.world.gravity = gravity

carl/envs/gymnasium/box2d/carl_lunarlander.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ def _update_context(self) -> None:
8686
)
8787

8888
gravity = vec2(float(gravity_x), float(gravity_y))
89-
self.env.world.gravity = gravity
89+
self.env.unwrapped.world.gravity = gravity

carl/envs/gymnasium/box2d/carl_vehicle_racing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ def get_context_features() -> dict[str, ContextFeature]:
221221
def _update_context(self) -> None:
222222
self.env: CustomCarRacing
223223
vehicle_class_index = self.context["VEHICLE_ID"]
224-
self.env.vehicle_class = PARKING_GARAGE[vehicle_class_index]
224+
self.env.unwrapped.vehicle_class = PARKING_GARAGE[vehicle_class_index]

examples/demo_carracing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Code adapted from gym.envs.box2d.car_racing.py
33
"""
44

5-
from typing import Any
65
import numpy as np
7-
import gymnasium as gym
86
import time
97
import pygame
108
from carl.envs.gymnasium.box2d.carl_vehicle_racing import (

examples/demo_heuristic_bipedalwalker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from carl.envs import CARLBipedalWalker
24
from gymnasium.envs.box2d import bipedal_walker
35
import numpy as np

0 commit comments

Comments
 (0)