Skip to content

Commit

Permalink
merge new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneT2000 committed Dec 13, 2023
1 parent bf02a06 commit 8f56415
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
56 changes: 56 additions & 0 deletions mani_skill2/examples/demo_scenes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
The code at the moment supports scenes created by [AI2-THOR](https://ai2thor.allenai.org/) stored in this
Hugging Face Dataset: https://huggingface.co/datasets/hssd/ai2thor-hab/tree/main
To download the dataset, run `python -m mani_skill2.utils.scene_builder.ai2thor.download <HUGGING_FACE_TOKEN>`
and make sure to pass in your hugging face API token. Note that you must create a hugging face account
and accept the terms of use for the dataset. Alternatively, if you can download the data through other means, simply
save it to `data/scene_datasets/ai2thor` and the code should run.
To learn how scenes are imported and built in ManiSkill, check out mani_skill2/utils/scene_builder module, there are some prebuilt scenes,
including code that imports scenes in the AI2THOR set of scenes and format, as well as code to build simple table-top scenes commonly used in
ManiSkill.
PickObjectScene-v0 selects a scene randomly from the given SceneBuilder and
instantiates a robot randomly and selects a random object for the robot to find and pick up.
render_mode="human" opens up a viewer, convex_decomposition="none" makes scene loading fast (but not well simulated)
set convex_decomposition="coacd" to use CoACD to get better collision meshes
Code is setup so that if you press the "r" key, a new scene is loaded and shown. You can run this file by running
`python -m mani_skill2.examples.demo_scenes` and explore around.
"""
import gymnasium as gym
import sapien.render
import numpy as np
import mani_skill2.envs
from mani_skill2.utils.scene_builder.ai2thor import (
ArchitecTHORSceneBuilder,
ProcTHORSceneBuilder,
RoboTHORSceneBuilder,
iTHORSceneBuilder,
)

if __name__ == "__main__":
# specify we want to sample from the ArchitecTHOR set of scenes. Other SceneBuilders are imported above and can be used
env = gym.make(
"PickObjectScene-v0",
render_mode="human",
scene_builder_cls=ArchitecTHORSceneBuilder,
convex_decomposition="none",
fixed_scene=True,
)

# optionally set these to make it more realistic
sapien.render.set_camera_shader_dir("rt")
sapien.render.set_viewer_shader_dir("rt")
sapien.render.set_ray_tracing_samples_per_pixel(4)
sapien.render.set_ray_tracing_path_depth(2)
sapien.render.set_ray_tracing_denoiser("optix")

env.reset(seed=np.random.randint(2**31), options=dict(reconfigure=True))
viewer = env.render()
while True:
env.render()
if viewer.window.key_down("r"):
env.reset(options=dict(reconfigure=True))
viewer = env.render()
3 changes: 1 addition & 2 deletions mani_skill2/examples/motionplanning/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Motion Planning Examples

To run the motion planner code to solve tasks / generate demonstrations, first install ManiSkill2 and then install mplib, a simple python motion planner library we maintain

First install the maniskill2 motion planning library
```
pip install mplib
```
2 changes: 1 addition & 1 deletion mani_skill2/examples/motionplanning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from transforms3d import quaternions

from mani_skill2.utils.common import normalize_vector
from mani_skill2.utils.trimesh_utils import get_component_mesh
from mani_skill2.utils.geometry.trimesh_utils import get_component_mesh


def get_actor_obb(actor: sapien.Entity, to_world_frame=True, vis=False):
Expand Down

0 comments on commit 8f56415

Please sign in to comment.