[Tutorial Error] '3. Creating New RL Environment' - 'CartpoleTask' object has no attribute 'reset'

Hi, while I’m running the code in the tutorial ‘3. Creating New RL Environment’, an error happens.

Error

Wrapping the env with a Monitor wrapper
Wrapping the env in a DummyVecEnv.
Traceback (most recent call last):
File “cartpole_example.py”, line 26, in
model.learn(total_timesteps=100000)
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/kit/python/lib/python3.7/site-packages/stable_baselines3/ppo/ppo.py”, line 313, in learn
reset_num_timesteps=reset_num_timesteps,
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/kit/python/lib/python3.7/site-packages/stable_baselines3/common/on_policy_algorithm.py”, line 243, in learn
total_timesteps, eval_env, callback, eval_freq, n_eval_episodes, eval_log_path, reset_num_timesteps, tb_log_name
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/kit/python/lib/python3.7/site-packages/stable_baselines3/common/base_class.py”, line 429, in _setup_learn
self._last_obs = self.env.reset() # pytype: disable=annotation-type-mismatch
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/kit/python/lib/python3.7/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py”, line 61, in reset
obs = self.envs[env_idx].reset()
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/kit/python/lib/python3.7/site-packages/stable_baselines3/common/monitor.py”, line 79, in reset
return self.env.reset(**kwargs)
File “/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/exts/omni.isaac.gym/omni/isaac/gym/vec_env/vec_env_base.py”, line 130, in reset
self._task.reset()
AttributeError: ‘CartpoleTask’ object has no attribute ‘reset’
/home/jong/.local/share/ov/pkg/isaac_sim-2022.1.0/python.sh: line 46: 247039 Segmentation fault (core dumped) $python_exe “$@” $args
There was an error running python

Environment
Isaac Sim 2022.1 on Ubuntu 20.04, installed by Omniverse Launcher
For VSCode and ./python.sh, the same error happens.

Log
log.txt (15.2 KB)

Hi,

Please make sure you have copied in the reset method into your CartpoleTask class. It should be the 7th code snippet under 6. Custom RL Example using Stable Baselines — Omniverse Robotics documentation.

Thanks,
Kelly

Hi~

I copied already the code you commented.

And, I made the codes again as below:
cartpole_task.py (5.7 KB)
cartpole_example.py (669 Bytes)

But the same error happened:
log.txt (15.3 KB)

Thanks

All of the methods in the cartpole_task.py script are for the CartpoleTask class. It looks like the indentation in your script is not set up correctly. Try adding an indentation to each method (other than __init__) so that they belong to the class.

Thanks,
Kelly

2 Likes