Skip to content

Commit

Permalink
Merge pull request #185 from Federico-PizarroBejarano/remove_info_in_…
Browse files Browse the repository at this point in the history
…reset

Removing info_in_reset
  • Loading branch information
adamhall authored Jan 28, 2025
2 parents 0c3c028 + 38de366 commit 1e3e46a
Show file tree
Hide file tree
Showing 38 changed files with 16 additions and 73 deletions.
1 change: 0 additions & 1 deletion examples/cbf/config_overrides/cartpole_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ task_config:
seed: 42
ctrl_freq: 25
pyb_freq: 1000
info_in_reset: True

cost: quadratic
task: stabilization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ task_config:
pole_length: 0.5
pole_mass: 0.1
inertial_prop_randomization_info: null
info_in_reset: false
init_state:
init_x: 0.0
init_x_dot: 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
task_config:
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
1 change: 0 additions & 1 deletion examples/mpsc/config_overrides/cartpole/cartpole_stab.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
2 changes: 0 additions & 2 deletions examples/no_controller/verbose_api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cartpole_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 50
gui: False
Expand Down Expand Up @@ -91,7 +90,6 @@ cartpole_config:

quadrotor_config:
seed: 1337
info_in_reset: True
ctrl_freq: 60
pyb_freq: 240
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
gui: False
Expand Down
1 change: 0 additions & 1 deletion examples/rl/config_overrides/cartpole/cartpole_stab.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
1 change: 0 additions & 1 deletion examples/rl/config_overrides/cartpole/cartpole_track.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 42
info_in_reset: True
ctrl_freq: 15
pyb_freq: 750
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
task_config:
seed: 1337
info_in_reset: True
ctrl_freq: 50
pyb_freq: 1000
physics: pyb
Expand Down
2 changes: 1 addition & 1 deletion safe_control_gym/controllers/lqr/ilqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
self.lamb_max = lamb_max
self.epsilon = epsilon

self.env = env_func(info_in_reset=True, done_on_out_of_bound=True)
self.env = env_func(done_on_out_of_bound=True)

# Controller params.
self.model = self.get_prior(self.env)
Expand Down
4 changes: 0 additions & 4 deletions safe_control_gym/envs/benchmark_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class BenchmarkEnv(gym.Env, ABC):
def __init__(self,
output_dir=None,
seed=None,
info_in_reset: bool = False,
gui: bool = False,
verbose: bool = False,
normalized_rl_action_space: bool = False,
Expand Down Expand Up @@ -91,8 +90,6 @@ def __init__(self,
Args:
output_dir (str, optional): Path to directory to save any env outputs.
seed (int, optional): Seed for the random number generator.
info_in_reset (bool, optional): Whether .reset() returns a dictionary with the
environment's symbolic model.
gui (bool, optional): Whether to show PyBullet's GUI.
verbose (bool, optional): If to suppress environment print statetments.
normalized_rl_action_space (bool, optional): Whether to normalize the action space.
Expand Down Expand Up @@ -192,7 +189,6 @@ def __init__(self,
self.seed(seed)
self.initial_reset = False
self.at_reset = False
self.INFO_IN_RESET = info_in_reset

def seed(self,
seed=None
Expand Down
6 changes: 1 addition & 5 deletions safe_control_gym/envs/gym_control/cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class CartPole(BenchmarkEnv):
multiple cost functions, stabilization and trajectory tracking references.
task_config:
info_in_reset: True
randomized_inertial_prop: True
inertial_prop_randomization_info:
pole_length:
Expand Down Expand Up @@ -338,10 +337,7 @@ def reset(self, seed=None):
obs, info = self._get_observation(), self._get_reset_info()
obs, info = super().after_reset(obs, info)
# Return either an observation and dictionary or just the observation.
if self.INFO_IN_RESET:
return obs, info
else:
return obs
return obs, info

def render(self, mode='human'):
'''Retrieves a frame from PyBullet rendering.
Expand Down
1 change: 0 additions & 1 deletion safe_control_gym/envs/gym_control/cartpole.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Simulation options
info_in_reset: False
ctrl_freq: 50
pyb_freq: 50
gui: False
Expand Down
5 changes: 1 addition & 4 deletions safe_control_gym/envs/gym_pybullet_drones/quadrotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,7 @@ def reset(self, seed=None):
obs, info = super().after_reset(obs, info)

# Return either an observation and dictionary or just the observation.
if self.INFO_IN_RESET:
return obs, info
else:
return obs
return obs, info

def step(self, action):
'''Advances the environment by one control step.
Expand Down
1 change: 0 additions & 1 deletion safe_control_gym/envs/gym_pybullet_drones/quadrotor.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Simulation options
info_in_reset: False
ctrl_freq: 60
pyb_freq: 240
physics: pyb
Expand Down
38 changes: 13 additions & 25 deletions safe_control_gym/experiments/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,8 @@ def _evaluation_reset(self, ctrl_data, sf_data, seed=None):
obs (ndarray): The initial observation.
info (dict): The initial info.
'''
if self.env.INFO_IN_RESET:
obs, info = self.env.reset(seed=seed)
else:
obs = self.env.reset(seed=seed)
info = None
obs, info = self.env.reset(seed=seed)

if ctrl_data is not None:
for data_key, data_val in self.ctrl.results_dict.items():
ctrl_data[data_key].append(np.array(deepcopy(data_val)))
Expand Down Expand Up @@ -325,26 +322,17 @@ def clear_data(self):
def reset(self, **kwargs):
'''Wrapper for the gym.env reset function.'''

if self.env.INFO_IN_RESET:
obs, info = self.env.reset(**kwargs)
if 'symbolic_model' in info:
info.pop('symbolic_model')
if 'symbolic_constraints' in info:
info.pop('symbolic_constraints')
step_data = dict(
obs=obs, info=info, state=self.env.state
)
for key, val in step_data.items():
self.episode_data[key].append(val)
return obs, info
else:
obs = self.env.reset(**kwargs)
step_data = dict(
obs=obs, state=self.env.state
)
for key, val in step_data.items():
self.episode_data[key].append(val)
return obs
obs, info = self.env.reset(**kwargs)
if 'symbolic_model' in info:
info.pop('symbolic_model')
if 'symbolic_constraints' in info:
info.pop('symbolic_constraints')
step_data = dict(
obs=obs, info=info, state=self.env.state
)
for key, val in step_data.items():
self.episode_data[key].append(val)
return obs, info

def step(self, action):
'''Wrapper for the gym.env step function.'''
Expand Down

0 comments on commit 1e3e46a

Please sign in to comment.