Skip to content

Commit

Permalink
Fix: by default hidden objs hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
arth-shukla committed Mar 2, 2024
1 parent 20a2d04 commit ce6fb86
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions mani_skill2/envs/sapien_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,12 @@ def _get_obs_with_sensor_data(self, info: Dict) -> OrderedDict:
obj.hide_visual()
self._scene.update_render()
self.capture_sensor_data()
obs = OrderedDict(
return OrderedDict(
agent=self._get_obs_agent(),
extra=self._get_obs_extra(info),
sensor_param=self.get_sensor_params(),
sensor_data=self.get_sensor_obs(),
)
for obj in self._hidden_objects:
obj.show_visual()
return obs

@property
def robot_link_ids(self):
Expand Down Expand Up @@ -965,6 +962,8 @@ def _setup_viewer(self):
)

def render_human(self):
for obj in self._hidden_objects:
obj.show_visual()
if self._viewer is None:
self._viewer = Viewer()
self._setup_viewer()
Expand All @@ -981,6 +980,8 @@ def render_rgb_array(self, camera_name: str = None):
"""Returns an RGB array / image of size (num_envs, H, W, 3) of the current state of the environment.
This is captured by any of the registered human render cameras. If a camera_name is given, only data from that camera is returned.
Otherwise all camera data is captured and returned as a single batched image"""
for obj in self._hidden_objects:
obj.show_visual()
self._scene.update_render()
images = []
# TODO (stao): refactor this code either into ManiSkillScene class and/or merge the code, it's pretty similar?
Expand All @@ -1007,6 +1008,8 @@ def render_rgb_array(self, camera_name: str = None):
return None
if len(images) == 1:
return images[0]
for obj in self._hidden_objects:
obj.hide_visual()
return tile_images(images)

def render_sensors(self):
Expand All @@ -1021,8 +1024,6 @@ def render_sensors(self):
sensor_images = self.get_sensor_obs()
for sensor_images in sensor_images.values():
images.extend(observations_to_images(sensor_images))
for obj in self._hidden_objects:
obj.show_visual()
return tile_images(images)

def render(self):
Expand Down
2 changes: 0 additions & 2 deletions mani_skill2/envs/scenes/tasks/sequential_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,6 @@ def render_cameras(self):
sensor_images = self.get_sensor_obs()
for sensor_images in sensor_images.values():
images.extend(observations_to_images(sensor_images))
for obj in self._hidden_objects:
obj.show_visual()
return tile_images([self.render_rgb_array()] + images)

def render_rgb_array(self):
Expand Down
5 changes: 4 additions & 1 deletion mani_skill2/utils/structs/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,7 @@ def pose(self, arg1: Union[Pose, sapien.Pose, Array]) -> None:
self._objs[0].pose = to_sapien_pose(arg1)

def set_pose(self, arg1: Union[Pose, sapien.Pose]) -> None:
self.pose = arg1
if physx.is_gpu_enabled() and self.hidden:
self.before_hide_pose = vectorize_pose(arg1)
else:
self.pose = arg1

0 comments on commit ce6fb86

Please sign in to comment.