Skip to content

Conversation

T-K-233
Copy link
Contributor

@T-K-233 T-K-233 commented Sep 7, 2025

Description

This PR introduces an option to control the camera viewport using the keyboard.

Previously, creating a ViewportCameraController disabled mouse interaction with the viewport. This happened because the controller subscribed to the app’s post-update event stream and continuously called sim.set_camera_view(...), overriding user input. This made viewing the simulation environment difficult.

To address this, a new register_keyboard_control option is added to ViewerCfg. When enabled, the user can navigate the camera with numpad shortcuts (full keybinding list is provided below).

Example usage:

# in train.py or play.py
 viewer_cfg = ViewerCfg(
     eye=(-3.0, 0.0, 1.0),  # default camera position w.r.t. the target
     lookat=(0.0, 0.0, 0.0),
     origin_type="asset_root",
     asset_name="robot",
+    register_keyboard_control=True,
 )
 camera_controller = ViewportCameraController(env.unwrapped, viewer_cfg)

Keybinding

Numpad Key Function
Numpad 0 Default view
Numpad 1 Front view
Ctrl + Numpad 1 Back view
Numpad 3 Right-side view
Ctrl + Numpad 3 Left-side view
Numpad 7 Top view
Ctrl + Numpad 7 Bottom view
Numpad 8 Arc upward
Numpad 2 Arc downward
Numpad 4 Arc left
Numpad 6 Arc right
Numpad + (plus) Push in
Numpad – (minus) Pull out
Ctrl + Numpad 8 Pedestal up
Ctrl + Numpad 2 Pedestal down

Note to reviewers: I’m not sure which documentation section this change should go into—guidance is appreciated.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (?)

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@T-K-233 T-K-233 requested a review from ooctipus as a code owner September 7, 2025 08:23

def _on_keyboard_event(self, event: carb.input.KeyboardEvent):
"""Checks for a keyboard event and assign the corresponding command control depending on key pressed."""
if event.type == carb.input.KeyboardEventType.KEY_PRESS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to stick to default viewport controls here as options: https://docs.omniverse.nvidia.com/usd/latest/common/keyboard_shortcuts.html#viewport-controls

Not all keyboards have numpads in there.

Copy link
Collaborator

@ooctipus ooctipus Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with mayank it will be nice if it can stick to the same way how isaacsim uses keyboard control :)), Numpad can be optionally there as well, but my keyboard doesn't have a numpad and I'd like to use this functionality.

Comment on lines +154 to +157
# convert back to Cartesian coordinates
self.default_cam_eye[0] = radius * np.sin(phi) * np.cos(theta)
self.default_cam_eye[1] = radius * np.sin(phi) * np.sin(theta)
self.default_cam_eye[2] = radius * np.cos(phi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these values are changed, then are they reflected on the UI too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants