-
Notifications
You must be signed in to change notification settings - Fork 501
Add camera pose editors plugins #1397
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
base: main
Are you sure you want to change the base?
Changes from all commits
5052bd5
8f2fb68
0a768aa
8dc1a80
801a0c9
3dc8c0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,9 @@ class Args: | |
| pause: Annotated[bool, tyro.conf.arg(aliases=["-p"])] = False | ||
| """If using human render mode, auto pauses the simulation upon loading""" | ||
|
|
||
| edit_camera_poses: bool = False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The demo random action file should not be demoing specific plugins like camera editing. I recommend making a new function to demonstrate how to add plugins to a viewer by a user in code We can include some widely used plugins in the future as part of the default set of plugins added to sapien in maniskill (and this could be one of them, at the moment I'd hold off from making it a default). |
||
| """Enable in-viewer camera pose editing when using the human render mode""" | ||
|
|
||
| quiet: bool = False | ||
| """Disable verbose output.""" | ||
|
|
||
|
|
@@ -83,6 +86,7 @@ def main(args: Args): | |
| render_backend=args.render_backend, | ||
| enable_shadow=True, | ||
| parallel_in_single_scene=parallel_in_single_scene, | ||
| enable_camera_pose_editing=args.edit_camera_poses, | ||
| ) | ||
| if args.robot_uids is not None: | ||
| env_kwargs["robot_uids"] = tuple(args.robot_uids.split(",")) | ||
|
|
@@ -107,21 +111,26 @@ def main(args: Args): | |
| obs, _ = env.reset(seed=args.seed, options=dict(reconfigure=True)) | ||
| if args.seed is not None and env.action_space is not None: | ||
| env.action_space.seed(args.seed[0]) | ||
| pause_after_viewer_boot = False | ||
| if args.render_mode == "human": | ||
| viewer = env.render() | ||
| if isinstance(viewer, sapien.utils.Viewer): | ||
| viewer.paused = args.pause | ||
| env.render() | ||
| pause_after_viewer_boot = args.pause and isinstance(viewer, sapien.utils.Viewer) | ||
| if args.edit_camera_poses: | ||
| print("Camera pose editing enabled: click a camera frustum in the viewer and drag the gizmo in the Camera Editor window.") | ||
| while True: | ||
| if args.render_mode == "human": | ||
| viewer = env.render() | ||
| if isinstance(viewer, sapien.utils.Viewer) and pause_after_viewer_boot: | ||
| viewer.paused = True | ||
| pause_after_viewer_boot = False | ||
| continue | ||
| action = env.action_space.sample() if env.action_space is not None else None | ||
| obs, reward, terminated, truncated, info = env.step(action) | ||
| if verbose: | ||
| print("reward", reward) | ||
| print("terminated", terminated) | ||
| print("truncated", truncated) | ||
| print("info", info) | ||
| if args.render_mode == "human": | ||
| env.render() | ||
| if args.render_mode is None or args.render_mode != "human": | ||
| if (terminated | truncated).any(): | ||
| break | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given I think we should make new plugins a bit more standardized, we should not add specific viewer plugin related code here like one just for camera editing.
Instead, we have two (not mutually exclusive) options
attach_viewer_pluginthat accepts a created plugin object or maybe the plugin class and adds it to the viewer once viewer is created (we will need to maintain a list of plugins).pluginsand you can pass in a list of plugins that we add upon viewer creation