-
Notifications
You must be signed in to change notification settings - Fork 19
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
Added view_env #21
base: master
Are you sure you want to change the base?
Added view_env #21
Conversation
@@ -308,6 +310,16 @@ def close(self): | |||
if self.gui: | |||
self._gym.destroy_viewer(self._viewer) | |||
|
|||
def view_env(self, env_idx, cam_pos=None, look_at=None, custom_draws=None): |
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.
can change this to a more general method set_viewer_camera
or something w/ the following signature:
set_viewer_camera(env_idx=None, cam_pos=None, look_at=None)
this way ppl can also use this function to just change the viewer pose w/o the env.
also custom_draws
and self.render
can be removed? since presumably w/e sim/render loop the user is running will be calling that anyway
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.
_gym.viewer_camera_look_at
requires an env_ptr
because the locations are relative to the specified environment. Although I see it used before with None
which I assume means it defaults to the first env.
I'm thinking about this more and I think we're conflating two possible cases: 1) a zoom-in view of one environment, presumably the input viewer cam positions are defined w/r/t the local environment; 2) a zoom-out view of all (well, most) of the envs.
My current implementation assumes the user specifies the cfg
in a way that it's a "zoom-in" view, but if that's not the case, the function won't work as expected when no positions are specified.
Using one function that does local or global depending on some other values seems like it would be better to split into two distinct functions, like set_global_view
would be global and set_env_view
would be the local one.
I added the call to render
because my use case was halting the simulation with pdb; pdb.set_trace()
. After viewer_camera_look_at
is called, the viewer does not update - it needs a call to render. So I put it there.
I guess if we name the function set...
it doesn't imply necessarily that the env is immediately viewable in viewer. But something like view_env
would imply that it does render. So just need to clarify what we want.
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.
on zoom-in vs. zoom-out - i think it's always "zoomed-in" b/c viewer_camera_look_at
always requires an env_ptr, so the poses are always relative to a specific env, so there's no real notion of a "global" view. if the user doesn't provide the camera poses in the cfg then we have a default view.
i'm for removing render
so it's more of a set
and there's no external effects
@@ -26,6 +26,8 @@ def __init__(self, cfg): | |||
cam_pos = gymapi.Vec3(1.5, 1.5, 0) | |||
look_at = gymapi.Vec3(0.5, 1, 0) | |||
self._gym.viewer_camera_look_at(self._viewer, None, cam_pos, look_at) | |||
self._cam_pos = cam_pos |
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.
change to self._viewer_cam_pos
and self._viewer_look_at
, and add self._viewer_env_idx
(see comment below)
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.
What would self._viewer_env_idx
encode in this case? The environment the viewer cam positions are defined with respect to? I'm a little worried the distinction won't be clear that cam_pos
and look_at
are defined "globally" [w/r/t env 0] unless otherwise specified by the cfg env. I'm not actually sure whether users are expecting this to specify a global viewer camera or one local to a certain env.
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.
cam_pos
and look_at
are not defined globally - these are always relative to a env. it just defaults to env 0. if it's clearer we can add a line in the cfg to specify the env these are relative to, and add a check to make sure that env_idx is less than n_envs
Added a convenience method to instantaneously move the viewer camera to the specified environment. I found this really useful when I wanted to look at what a certain environment was doing without having to figure out the pose of the viewer camera to show it.