Repository: stepjam/RLBench
Issue: Measuring rendering speed?
Root cause: External Dependency Breakage

Hi Stephen,

Thanks for sharing your hard work! This is quite impressive feat. 

I'm trying to evaluate RLBench for an RL project, especially the rendering and simulation speed.  I tried to measure the time it takes to take one step in the environment, but I'm getting inconsistent measurement. I'm running the following script from the example:

```
from rlbench.environment import Environment
from rlbench.action_modes import ArmActionMode, ActionMode
from rlbench.observation_config import ObservationConfig
from rlbench.tasks import ReachTarget
import numpy as np
import time


class Agent(object):

    def __init__(self, action_size):
        self.action_size = action_size

    def act(self, obs):
        return (np.random.normal(0.0, 0.1, size=(self.action_size,))).tolist()


obs_config = ObservationConfig()
obs_config.set_all(False)
obs_config.left_shoulder_camera.rgb = True
obs_config.right_shoulder_camera.rgb = True

action_mode = ActionMode(ArmActionMode.ABS_JOINT_VELOCITY)
env = Environment(
    action_mode, obs_config=obs_config, headless=False)
env.launch()

task = env.get_task(ReachTarget)

agent = Agent(action_mode.action_size)

training_steps = 120 
episode_length = 40
obs = None
for i in range(training_steps):
    if i % episode_length == 0:
        print('Reset Episode')
        descriptions, obs = task.reset()                                                                                                                 
        print(descriptions)
    action = agent.act(obs)
    b = time.time()
    obs, reward, terminate = task.step(action)
    print('time', time.time() - b)

print('Done')
env.shutdown()
```

The output I got is something like:
```
Reset Episode
['reach the red target', 'touch the red ball with the panda gripper', 'reach the red sphere']
time 0.4733397960662842
time 0.020693063735961914
time 0.019981861114501953
time 0.4483151435852051
time 0.02089381217956543
time 0.4511847496032715
time 0.4504091739654541
time 0.02108478546142578
time 0.451430082321167
time 0.44994044303894043
time 0.021603107452392578
time 0.4509134292602539
time 0.02010631561279297
time 0.45382070541381836
time 0.02047109603881836
time 0.020781755447387695
time 0.022526979446411133
time 0.4556691646575928
time 0.4509866237640381
time 0.44914793968200684
time 0.44646525382995605
time 0.45250749588012695
time 0.5030205249786377
time 0.0205843448638916
time 0.45667576789855957
time 0.021213293075561523
time 0.020083189010620117
time 0.020364046096801758
time 0.020453453063964844
time 0.021342992782592773
time 0.4546060562133789
time 0.02128005027770996
time 0.020647525787353516
time 0.45148324966430664
time 0.020636320114135742
time 0.4499623775482178
time 0.436708927154541
time 0.44021058082580566
time 0.020857810974121094
time 0.4387171268463135
```

Is this normal?

Also, how would you compare PyRep with Mujoco in terms of rendering speed? Thanks

Hi,
Sorry for the delay in getting back to you (I've been away).
Hmm, no this doesn't seem right. I imagine this is down to the OpenGL3 plugin. I will have to look in to this (luckily, I wrote this plugin). I'll get back to you once I have any updates.

In the meantime, if you don't need shadows, you can swap to using the OpenGL2 renderer instead:
```python
from pyrep.const import RenderMode
obs_config = ObservationConfig(render_mode=RenderMode. OPENGL)
```

Best,
Stephen


I'm closing this as this is a PyRep issue rather than an RLBench issue. I will continue to look in to this though. Please feel free to reopen the issue on the PyRep page. 

Best,
Stephen