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

gymnasium_basic_usage.py | Problem running it #11

Open
valgau-asu opened this issue Oct 30, 2024 · 6 comments
Open

gymnasium_basic_usage.py | Problem running it #11

valgau-asu opened this issue Oct 30, 2024 · 6 comments

Comments

@valgau-asu
Copy link

Hi, I recently installed RotorPy (Running on Windows | Python 3.11.9) and wanted to use the RL/ML features you propose.
I tried to run "gymnasium_basic_usage.py" and got the following error:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
PS D:\Documents\ASU\RotorPy\rotorpy\examples> python .\gymnasium_basic_usage.py
Traceback (most recent call last):
File "D:\Documents\ASU\RotorPy\rotorpy\examples\gymnasium_basic_usage.py", line 51, in
observation, info = env.reset(initial_state='random')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: OrderEnforcing.reset() got an unexpected keyword argument 'initial_state'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Do you have any idea from where this could come from?

Thanks,

Val

@RoboDD
Copy link

RoboDD commented Nov 25, 2024

Same Issue:

Traceback (most recent call last):
File "ppo_hover_train.py", line 62, in
observation, info = env.reset(initial_state='random', options={'pos_bound': 2, 'vel_bound': 0})
TypeError: reset() got an unexpected keyword argument 'initial_state'

@spencerfolk
Copy link
Owner

Thanks for bringing this to my attention. @valgau-asu or @RoboDD can you tell me what versions of gymnasium you're running?

@RoboDD
Copy link

RoboDD commented Nov 25, 2024

Thanks for bringing this to my attention. @valgau-asu or @RoboDD can you tell me what versions of gymnasium you're running?

Hi @spencerfolk,

Thanks for your quick reply. My version of gymnasium is 1.0.0.

~/rotorpy/examples$ python
Python 3.8.10 (default, Jul 29 2024, 17:02:10)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gymnasium
>>> gymnasium.__version__
'1.0.0'

@spencerfolk
Copy link
Owner

Ok I was able to replicate the error by upgrading to gymnasium==1.0.0. I suspect they might have changed some things since the initial version I installed when developing the gym environment.

As a band-aid solution I specified a compatible version of gymnasium in the setup.py. You can see the version in 9339485

It's older but still has the main functionality offered by the gymnasium package.

I'm going to keep this issue open because I'd like to one day make the environment compatible with future versions of gymnasium. If anyone figures out the future-proof fix feel free to open a PR.

@RoboDD
Copy link

RoboDD commented Nov 26, 2024

My temporal solution to use gymnasium.__version__'1.0.0':

ppo_hover_train.py, modify these lines:

# Reset the environment
# observation, info = env.reset(initial_state='random', options={'pos_bound': 2, 'vel_bound': 0})
observation, info = env.reset(options={'initial_state': 'random', 'pos_bound': 2, 'vel_bound': 1})

quadrotor_enviroments.py, modify these lines:

def reset(self, seed=None, options={'initial_state':'random', 'pos_bound': 2, 'vel_bound': 0}):
...............
        #! add two lines to force assign parameter after super().reset(seed=seed)
        options={'initial_state':'random', 'pos_bound': 2, 'vel_bound': 0}
        initial_state = 'random'
...............

Then, I can run the given PPO train and eval scripts. It seems the reset function can not have initial_state as an argument in gymnasium 1.0.0 version. I guess the quick way to solve this is to install older version gymnasium.

@valgau-asu
Copy link
Author

Thank you for the answer! It worked on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants