Gym: IndexError when running "Pendulum-v0" env with matlab-http-api

Created on 30 May 2017  路  2Comments  路  Source: openai/gym

Hey guys,

I installed the gym package inside a python-2.7 virtualenv, and was running the Pendulum-v0 env using the binding-matlab/gym_http_client.m from gym-http-api.

When starting the env, an error was constantly rising:
../path_to_my_virtualenv/virtual_gym_npreps/local/lib/python2.7/site-packages/gym/envs/classic_control/pendulum.py", line 37, in _step u = np.clip(u, -self.max_torque, self.max_torque)[0] IndexError: invalid index to scalar variable.

I took off the indexing part and now I can run it properly; apparently, the control u is already a scalar for the pendulum.

Not sure if I should pull a request for this change or the reason I got this error is somewhere in the intermediate steps and u should not be a scalar after all (couldn't see any specs for the Pendulum, but it makes sense to expect a single number for the torque, right), oru should be passed as array, i.e., np.clip([u], ....)

Let me know how to handle this correctly,
Thanks

Addendum: I get this issue when running the Pendulum-v0 on Ubuntu 16.04, but it works perfectly fine when running on Mac

Most helpful comment

I also get this issue running on Windows and using the latest repo. I guess passing in the actions as an array is a simple fix.
env.step([action])

All 2 comments

I also get this issue running on Windows and using the latest repo. I guess passing in the actions as an array is a simple fix.
env.step([action])

Yes, @JadenTravnik , I agree that we could fix it in many ways - passing the action as array, or removing the indexing; I wanted to let them know that something is wrong down the way and maybe the guys who updated the agent know better where they should look for the intruded bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lbbc1117 picture lbbc1117  路  3Comments

tylerlekang picture tylerlekang  路  3Comments

hipoglucido picture hipoglucido  路  4Comments

Spiral-Galaxy picture Spiral-Galaxy  路  3Comments

pickittwice picture pickittwice  路  4Comments