Skip to content

Commit

Permalink
Merge branch 'master' into shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
fxia22 authored Jun 16, 2020
2 parents 3262bc7 + 48cc526 commit 7f039c8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
15 changes: 13 additions & 2 deletions gibson2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'global_config.yaml')) as f:
global_config = yaml.load(f, Loader=yaml.FullLoader)

assets_path = global_config['assets_path']
dataset_path = global_config['dataset_path']
# can override assets_path and dataset_path from environment variable
if 'GIBSON_ASSETS_PATH' in os.environ:
assets_path = os.environ['GIBSON_ASSETS_PATH']
else:
assets_path = global_config['assets_path']
assets_path = os.path.expanduser(assets_path)

if 'GIBSON_DATASET_PATH' in os.environ:
dataset_path = os.environ['GIBSON_DATASET_PATH']
else:
dataset_path = global_config['dataset_path']
dataset_path = os.path.expanduser(dataset_path)

root_path = os.path.dirname(os.path.realpath(__file__))

if not os.path.isabs(assets_path):
Expand Down
20 changes: 14 additions & 6 deletions gibson2/core/render/mesh_renderer/mesh_renderer_cpu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
import ctypes

Expand Down Expand Up @@ -329,14 +330,21 @@ def __init__(self, width=512, height=512, vertical_fov=90, device_idx=0, use_fis
self.faces = []
self.instances = []
self.fisheye = use_fisheye

self.enable_shadow = enable_shadow
available_devices = get_available_devices()
if device_idx < len(available_devices):
device = available_devices[device_idx]
logging.info("Using device {} for rendering".format(device))

if os.environ.get('GIBSON_DEVICE_ID', None):
device = int(os.environ.get('GIBSON_DEVICE_ID'))
logging.info(f'GIBSON_DEVICE_ID environment variable has been manually set. '
f'Using device {device} for rendering')
else:
logging.info("Device index is larger than number of devices, falling back to use 0")
device = 0
available_devices = get_available_devices()
if device_idx < len(available_devices):
device = available_devices[device_idx]
logging.info(f"Using device {device} for rendering")
else:
logging.info("Device index is larger than number of devices, falling back to use 0")
device = 0

self.device_idx = device_idx
self.device_minor = device
Expand Down
2 changes: 1 addition & 1 deletion gibson2/envs/locomotor_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_normal(self):
"""
:return: surface normal reading
"""
return self.simulator.renderer.render_robot_cameras(modes='normal')
return self.simulator.renderer.render_robot_cameras(modes='normal')[0][:, :, :3]

def get_seg(self):
"""
Expand Down
9 changes: 9 additions & 0 deletions gibson2/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import os
import numpy as np
import yaml
import collections.abc
from scipy.spatial.transform import Rotation as R

# File I/O related
def parse_config(config):
if isinstance(config, collections.abc.Mapping):
return config
else:
assert isinstance(config, str)

if not os.path.exists(config):
raise FileNotFoundError(f'config path {config} does not exist. Please either pass in a dict or a string that represents the file path to the config yaml.')
with open(config, 'r') as f:
config_data = yaml.load(f, Loader=yaml.FullLoader)
return config_data
Expand Down

0 comments on commit 7f039c8

Please sign in to comment.