Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

263 examples gymnasium v1 #264

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed
## Fixed

## [3.0.3] - unreleased
## Added
## Changed
- Changed minimal required gymnasium version to 0.29.1.
- updated the code of gem-control to be compatible with gymnasium v1.0.0
## Fixed
- #263 updated the sb3, mpc and gem-control examples to run with gymnasium v1.0.0

## [3.0.2] - 2024-11-19
## Added
## Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,31 @@
"class MPC(Controller):\n",
" def __init__(self, environment, ph=5, ref_idx_q=0, ref_idx_d=1):\n",
" # conversion of the coordinate systems\n",
" t32 = environment.physical_system.electrical_motor.t_32\n",
" q = environment.physical_system.electrical_motor.q\n",
" t32 = environment.get_wrapper_attr('physical_system').electrical_motor.t_32\n",
" q = environment.get_wrapper_attr('physical_system').electrical_motor.q\n",
" self._backward_transformation = (lambda quantities, eps: t32(q(quantities[::-1], eps)))\n",
" \n",
" # indices\n",
" self.ref_idx_i_q = ref_idx_q\n",
" self.ref_idx_i_d = ref_idx_d\n",
" self.i_sd_idx = environment.state_names.index('i_sd')\n",
" self.i_sq_idx = environment.state_names.index('i_sq')\n",
" self.u_a_idx = environment.state_names.index('u_a')\n",
" self.u_b_idx = environment.state_names.index('u_b')\n",
" self.u_c_idx = environment.state_names.index('u_c')\n",
" self.u_sq_idx = environment.state_names.index('u_sq')\n",
" self.u_sd_idx = environment.state_names.index('u_sd')\n",
" self.omega_idx = environment.state_names.index('omega')\n",
" self.epsilon_idx = environment.state_names.index('epsilon')\n",
" self.i_sd_idx = environment.get_wrapper_attr('state_names').index('i_sd')\n",
" self.i_sq_idx = environment.get_wrapper_attr('state_names').index('i_sq')\n",
" self.u_a_idx = environment.get_wrapper_attr('state_names').index('u_a')\n",
" self.u_b_idx = environment.get_wrapper_attr('state_names').index('u_b')\n",
" self.u_c_idx = environment.get_wrapper_attr('state_names').index('u_c')\n",
" self.u_sq_idx = environment.get_wrapper_attr('state_names').index('u_sq')\n",
" self.u_sd_idx = environment.get_wrapper_attr('state_names').index('u_sd')\n",
" self.omega_idx = environment.get_wrapper_attr('state_names').index('omega')\n",
" self.epsilon_idx = environment.get_wrapper_attr('state_names').index('epsilon')\n",
"\n",
" # motor parameters\n",
" self.tau = environment.physical_system.tau\n",
" self.limits = environment.physical_system.limits\n",
" self.l_q = environment.physical_system.electrical_motor.motor_parameter['l_q']\n",
" self.l_d = environment.physical_system.electrical_motor.motor_parameter['l_d']\n",
" self.psi_ = environment.physical_system.electrical_motor.motor_parameter['psi_p']\n",
" self.r_s = environment.physical_system.electrical_motor.motor_parameter['r_s']\n",
" self.p = environment.physical_system.electrical_motor.motor_parameter['p']\n",
" self.tau = environment.get_wrapper_attr('physical_system').tau\n",
" self.limits = environment.get_wrapper_attr('physical_system').limits\n",
" self.l_q = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['l_q']\n",
" self.l_d = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['l_d']\n",
" self.psi_ = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['psi_p']\n",
" self.r_s = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['r_s']\n",
" self.p = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['p']\n",
" self.ph_ = ph\n",
"\n",
" def control(self, state, reference):\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@
" supply=dict(u_nominal=350), \n",
")\n",
"\n",
"eps_idx = env.physical_system.state_names.index('epsilon')\n",
"i_sd_idx = env.physical_system.state_names.index('i_sd')\n",
"i_sq_idx = env.physical_system.state_names.index('i_sq')\n",
"eps_idx = env.get_wrapper_attr('state_names').index('epsilon')\n",
"i_sd_idx = env.get_wrapper_attr('state_names').index('i_sd')\n",
"i_sq_idx = env.get_wrapper_attr('state_names').index('i_sq')\n",
"\n",
"env= TimeLimit(LastActionWrapper(FeatureWrapper(env)), max_episode_steps=200)\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@
"env.action_space = Discrete(7)\n",
"\n",
"# applying wrappers\n",
"eps_idx = env.physical_system.state_names.index('epsilon')\n",
"i_sd_idx = env.physical_system.state_names.index('i_sd')\n",
"i_sq_idx = env.physical_system.state_names.index('i_sq')\n",
"eps_idx = env.get_wrapper_attr('state_names').index('epsilon')\n",
"i_sd_idx = env.get_wrapper_attr('state_names').index('i_sd')\n",
"i_sq_idx = env.get_wrapper_attr('state_names').index('i_sq')\n",
"env = TimeLimit(\n",
" FeatureWrapper(\n",
" FlattenObservation(env), \n",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ numpy>=1.16.4
scipy>=1.4.1
pytest>=5.2.2
pytest-cov
gymnasium>=0.29.0
gymnasium>=0.29.1
pathspec>=0.12.0
Loading
Loading