diff --git a/carl/envs/gymnasium/box2d/carl_bipedal_walker.py b/carl/envs/gymnasium/box2d/carl_bipedal_walker.py index 9fc34661..2ea9f4dc 100644 --- a/carl/envs/gymnasium/box2d/carl_bipedal_walker.py +++ b/carl/envs/gymnasium/box2d/carl_bipedal_walker.py @@ -114,14 +114,14 @@ def _update_context(self) -> None: gravity_y = self.context["GRAVITY_Y"] gravity = (gravity_x, gravity_y) - self.env.world.gravity = gravity + self.env.unwrapped.world.gravity = gravity # Important for building terrain - self.env.fd_polygon = fixtureDef( + self.env.unwrapped.fd_polygon = fixtureDef( shape=polygonShape(vertices=[(0, 0), (1, 0), (1, -1), (0, -1)]), friction=bipedal_walker.FRICTION, ) - self.env.fd_edge = fixtureDef( + self.env.unwrapped.fd_edge = fixtureDef( shape=edgeShape(vertices=[(0, 0), (1, 1)]), friction=bipedal_walker.FRICTION, categoryBits=0x0001, @@ -154,4 +154,4 @@ def _update_context(self) -> None: maskBits=0x001, ) - self.env.world.gravity = gravity + self.env.unwrapped.world.gravity = gravity diff --git a/carl/envs/gymnasium/box2d/carl_lunarlander.py b/carl/envs/gymnasium/box2d/carl_lunarlander.py index 46ccb6d5..9f3c59f5 100644 --- a/carl/envs/gymnasium/box2d/carl_lunarlander.py +++ b/carl/envs/gymnasium/box2d/carl_lunarlander.py @@ -86,4 +86,4 @@ def _update_context(self) -> None: ) gravity = vec2(float(gravity_x), float(gravity_y)) - self.env.world.gravity = gravity + self.env.unwrapped.world.gravity = gravity diff --git a/carl/envs/gymnasium/box2d/carl_vehicle_racing.py b/carl/envs/gymnasium/box2d/carl_vehicle_racing.py index 2b8cb6a6..dcf61d75 100644 --- a/carl/envs/gymnasium/box2d/carl_vehicle_racing.py +++ b/carl/envs/gymnasium/box2d/carl_vehicle_racing.py @@ -221,4 +221,4 @@ def get_context_features() -> dict[str, ContextFeature]: def _update_context(self) -> None: self.env: CustomCarRacing vehicle_class_index = self.context["VEHICLE_ID"] - self.env.vehicle_class = PARKING_GARAGE[vehicle_class_index] + self.env.unwrapped.vehicle_class = PARKING_GARAGE[vehicle_class_index] diff --git a/examples/demo_carracing.py b/examples/demo_carracing.py index ac4bb67f..b6b96927 100644 --- a/examples/demo_carracing.py +++ b/examples/demo_carracing.py @@ -2,9 +2,7 @@ Code adapted from gym.envs.box2d.car_racing.py """ -from typing import Any import numpy as np -import gymnasium as gym import time import pygame from carl.envs.gymnasium.box2d.carl_vehicle_racing import ( diff --git a/examples/demo_heuristic_bipedalwalker.py b/examples/demo_heuristic_bipedalwalker.py index 19d6500f..5aa58937 100644 --- a/examples/demo_heuristic_bipedalwalker.py +++ b/examples/demo_heuristic_bipedalwalker.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from carl.envs import CARLBipedalWalker from gymnasium.envs.box2d import bipedal_walker import numpy as np