Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty scene issue of interacting in VR with added objects (#249) #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions igibson/scenes/empty_scene.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
from collections import defaultdict

import numpy as np
import pybullet as p
Expand All @@ -20,6 +21,8 @@ class EmptyScene(Scene):
def __init__(self, render_floor_plane=True, floor_plane_rgba=[1.0, 1.0, 1.0, 1.0]):
super(EmptyScene, self).__init__()
self.objects = []
self.objects_by_category = defaultdict(list)
self.objects_by_id = {}
self.render_floor_plane = render_floor_plane
self.floor_plane_rgba = floor_plane_rgba

Expand All @@ -29,6 +32,14 @@ def get_objects(self):
def _add_object(self, obj):
self.objects.append(obj)

if obj.category not in self.objects_by_category.keys():
self.objects_by_category[obj.category] = []
self.objects_by_category[obj.category].append(obj)

if obj.get_body_ids() is not None:
for id in obj.get_body_ids():
self.objects_by_id[id] = obj

def _load(self, simulator):
plane_file = os.path.join(pybullet_data.getDataPath(), "mjcf/ground_plane.xml")
self.floor_body_ids += [p.loadMJCF(plane_file)[0]]
Expand Down