Error when env.render()

Hi everyone,

I want render the env after loading it from the tutorial 3. However, I get the error :

“AttributeError: ‘MPDrawParams’ object has no attribute ‘update’”.

I have the latest version of CommonRoad_RL.
What could be the problem?

Here is the full error

AttributeError                            Traceback (most recent call last)
<ipython-input-16-3bda7b2d99d9> in <module>
      1 observation = training_env.reset()
      2 for _ in range(50):
----> 3   training_env.render() # rendered images with be saved under ./img
      4   action, _states = model_continual.predict(observation, deterministic=True)
      5   observation, reward, done, info = training_env.step(action)

~/miniconda3/envs/commonroad2023/lib/python3.7/site-packages/stable_baselines/common/vec_env/base_vec_env.py in render(self, mode)
    245 
    246     def render(self, mode: str = 'human'):
--> 247         return self.venv.render(mode=mode)
    248 
    249     def get_images(self):

~/miniconda3/envs/commonroad2023/lib/python3.7/site-packages/stable_baselines/common/vec_env/dummy_vec_env.py in render(self, mode)
     83         """
     84         if self.num_envs == 1:
---> 85             return self.envs[0].render(mode=mode)
     86         else:
     87             return super().render(mode=mode)

~/miniconda3/envs/commonroad2023/lib/python3.7/site-packages/gym/core.py in render(self, mode, **kwargs)
    293 
    294     def render(self, mode="human", **kwargs):
--> 295         return self.env.render(mode, **kwargs)
    296 
    297     def close(self):

~/miniconda3/envs/commonroad2023/lib/python3.7/site-packages/gym/core.py in render(self, mode, **kwargs)
    293 
    294     def render(self, mode="human", **kwargs):
--> 295         return self.env.render(mode, **kwargs)
    296 
    297     def close(self):

~/miniconda3/envs/commonroad2023/lib/python3.7/site-packages/commonroad_rl/gym_commonroad/commonroad_env.py in render(self, mode, **kwargs)
    326 
    327         # update timestep in draw_params
--> 328         self.draw_params.update({"scenario": {"time_begin": self.current_step, "time_end": self.current_step}})
    329 
    330         # Draw scenario, goal, sensing range and detected obstacles

AttributeError: 'MPDrawParams' object has no attribute 'update'

Hi,

The problem could be that your commonroad-io version is not updated. Could you check which version are you using?

Best,
Xiao

Hi,

I am facing the same problem. @diegofc were you able to fix it?

I am using the following versions:
commonroad-drivability-checker: 2022.2.1
commonroad-io: 2022.3
commonroad-rl: 2023.1
commonroad-route-planner: 2022.3

Best
Mattijs

Hi both, there is a bug in the render() function. Here should be changed to

        self.draw_params.time_begin = self.current_step
        self.draw_params.time_end = self.current_step

This fix will be included in the next release.

Best,
Xiao

1 Like

Hello,
I recently installed CommonRoad-RL, but the errors seem to still be there.
Thanks in advance for your answer

Traceback (most recent call last):
  File "test.py", line 25, in <module>
    env.render() 
  File "/home/user/miniconda3/envs/cr37/lib/python3.7/site-packages/gym/core.py", line 295, in render
    return self.env.render(mode, **kwargs)
  File "/home/user/commonroad-rl/commonroad_rl/gym_commonroad/commonroad_env.py", line 328, in render
    self.draw_params.update({"scenario": {"time_begin": self.current_step, "time_end": self.current_step}})
AttributeError: 'MPDrawParams' object has no attribute 'update'

Hi crazymon,

yes, for an immediate fix, see above.
We are just now preparing the next release for the coming days where it will be fixed.

Best,
Philipp

Hello PhilippGassert,

What exactly needs to be changed in the code? (or maybe I should add?)
Could you please clarify the line of code where the fixes are needed?

Thanks for the help)

Hi,

as described here, you have to change the line of code that is linked to to the two new lines mentioned:

Best,
Philipp

Hello Philipp,

I corrected the lines of code, but the previous error when running the code appeared again. Here is a link to my previous problem [Tutorial code running problems].
Why is this happening?
I installed some packages and the problem went away then, but when I want to run the corrected code, the problem with the Qt plugin reappeared
Is it possible to somehow fix it?

Best,
crazymon

Hi crazymon,

did you try
sudo apt-get install -y libopenmpi-dev build-essential unzip cmake libboost-dev libboost-thread-dev libboost-test-dev libboost-filesystem-dev libeigen3-dev libcgal-dev xutils-dev libfcl-dev libomp-dev libgmp-dev libglu1-mesa-dev
?

Best,
Philipp

Hello Philipp,

No, but I installed your specified packages. Did not help. Same error… It would be nice in the future to download and use it without additional package downloads and other manual fixes. You can read more about the error at the link above.

Best,
crazymon