Error using camera in headless mode


I am trying to use cameras in RL scenarios, and have therefore experimented with adding cameras in the Cartpole example. It works normally, but not when set to headless mode. I get the following error:

[Error] [carb.gym.plugin] SetCameraLocation: Error: could not find camera with handle -1 in environment 0

Here is the relevant code snippet:

camera_props = gymapi.CameraProperties()
camera_props.width = 720
camera_props.height = 480
camera_props.enable_tensors = True
camera_handle = self.gym.create_camera_sensor(env_ptr, camera_props) #returns -1
self.gym.set_camera_location(camera_handle, env_ptr, gymapi.Vec3(3, 0, 2), gymapi.Vec3(0, 0, 2))

I have followed other topics where users have the same problem(here and here), and none of the steps suggested have worked.

I can run the example in headless mode no problem. I have also tried to limit the number of available GPUs with set CUDA_VISIBLE_DEVICES, with no change.

Any help is much appreciated!
Br. Anton

1 Like