Skip to content

Commit 5ce1273

Browse files
DeepMindcopybara-github
authored andcommitted
Add all of Camera's constructor args to MovableCamera's constructor, except for camera_id, which has to be -1.
PiperOrigin-RevId: 478002851 Change-Id: I78253a2887073490cfbd92e4295eb0539003d710
1 parent f755f68 commit 5ce1273

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

dm_control/mujoco/engine.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class Physics(_control.Physics):
105105
_contexts = None
106106

107107
def __new__(cls, *args, **kwargs):
108-
obj = super(Physics, cls).__new__(cls)
108+
# TODO(b/174603485): Re-enable once lint stops spuriously firing here.
109+
obj = super(Physics, cls).__new__(cls) # pylint: disable=no-value-for-parameter
109110
# The lock is created in `__new__` rather than `__init__` because there are
110111
# a number of existing subclasses that override `__init__` without calling
111112
# the `__init__` method of the superclass.
@@ -610,7 +611,7 @@ class Camera:
610611

611612
def __init__(
612613
self,
613-
physics,
614+
physics: Physics,
614615
height: int = 240,
615616
width: int = 320,
616617
camera_id: Union[int, str] = -1,
@@ -955,15 +956,29 @@ class MovableCamera(Camera):
955956
A `MovableCamera` always corresponds to a MuJoCo free camera with id -1.
956957
"""
957958

958-
def __init__(self, physics, height=240, width=320):
959+
def __init__(
960+
self,
961+
physics: Physics,
962+
height: int = 240,
963+
width: int = 320,
964+
max_geom: Optional[int] = None,
965+
scene_callback: Optional[Callable[[Physics, mujoco.MjvScene],
966+
None]] = None,
967+
):
959968
"""Initializes a new `MovableCamera`.
960969
961970
Args:
962971
physics: Instance of `Physics`.
963972
height: Optional image height. Defaults to 240.
964973
width: Optional image width. Defaults to 320.
974+
max_geom: Optional integer specifying the maximum number of geoms that can
975+
be rendered in the same scene. If None this will be chosen automatically
976+
based on the estimated maximum number of renderable geoms in the model.
977+
scene_callback: Called after the scene has been created and before
978+
it is rendered. Can be used to add more geoms to the scene.
965979
"""
966-
super().__init__(physics=physics, height=height, width=width, camera_id=-1)
980+
super().__init__(physics=physics, height=height, width=width, camera_id=-1,
981+
max_geom=max_geom, scene_callback=scene_callback)
967982

968983
def get_pose(self):
969984
"""Returns the pose of the camera.

0 commit comments

Comments
 (0)