I got FatalError: gladLoadGL error while trying to perform reinforcement learning #1989
Unanswered
ppyakksa
asked this question in
Asking for Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm a student and I'm trying to use MuJoCo for simulate crane automation by using PPO.
I'm looking for some help with fixing error FatalError: gladLoadGL.
I have attached four cameras to a rotating box and I am trying to get images from the cameras.
Getting the images works well when I run the code independently.
But I get fladLoadGL error when I am trying to load the image while reinforcement learning
Here is the code that doesn't work. I am using .ipynb
#cell [15]
from OpenGL.EGL import *
os.environ['MUJOCO_GL'] = 'egl'
def get_camera_images(model, data, camera_names, width=224, height=224):
def get_resnet_features(images):
with torch.no_grad():
features = resnet_extractor(images)
return features
#cell[16]
class CustomMujocoEnv(gym.Env):
def init(self, model_path, camera_names):
super(CustomMujocoEnv, self).init()
self.model = mujoco.MjModel.from_xml_path(model_path)
self.data = mujoco.MjData(self.model)
self.camera_names = camera_names
self.observation_space = gym.spaces.Box(low=-np.inf, high=np.inf, shape=(4, 2048), dtype=np.float32)
self.action_space = gym.spaces.Box(low=-1, high=1, shape=(3,), dtype=np.float32)
#cell[17]
import os
os.environ['MUJOCO_GL'] = 'egl'
camera_names = [
'control_cabin_camera_1',
'control_cabin_camera_2',
'control_cabin_camera_3',
'control_cabin_camera_4'
]
env = CustomMujocoEnv('Model_xml/model.xml', camera_names)
agent = PPOAgent()
actor_losses, critic_losses, scores, episode, score = [], [], [], 0, 0
for step in range(run_step + test_step):
if step == run_step:
if train_mode:
agent.save_model()
print("test start!")
train_mode = False
env.close()
Below is the error code that I got
{
"name": "FatalError",
"message": "gladLoadGL error",
"stack": "---------------------------------------------------------------------------
FatalError Traceback (most recent call last)
Cell In[17], line 25
22 print("test start!")
23 train_mode = False
---> 25 state = env.reset()
26 action = agent.get_action(state, train_mode)
27 next_state, reward, done, _ = env.step(action)
Cell In[16], line 13, in CustomMujocoEnv.reset(self)
11 mujoco.mj_resetData(self.model, self.data)
12 mujoco.mj_forward(self.model, self.data)
---> 13 return self._get_obs()
Cell In[16], line 27, in CustomMujocoEnv._get_obs(self)
26 def _get_obs(self):
---> 27 images = get_camera_images(self.model, self.data, self.camera_names)
29 tensor_images = preprocess(images)
30 tensor_images = tensor_images.unsqueeze(0)
Cell In[15], line 9, in get_camera_images(model, data, camera_names, width, height)
5 os.environ['MUJOCO_GL'] = 'egl'
7 images = []
----> 9 offscreen = mujoco.MjrContext(model, mujoco.mjtFontScale.mjFONTSCALE_150)
11 # Iterate over the camera names and render each one
12 for i, camera_name in enumerate(camera_names):
FatalError: gladLoadGL error"
}
Thank you very much for reading my question. I wish you to have a great day
Beta Was this translation helpful? Give feedback.
All reactions