@@ -89,6 +89,8 @@ def __init__(
8989 self ._aspect_ratio = self ._res [0 ] / self ._res [1 ]
9090 self ._visualizer = visualizer
9191 self ._is_built = False
92+ self ._attached_link = None
93+ self ._attached_offset_T = None
9294
9395 self ._in_recording = False
9496 self ._recorded_imgs = []
@@ -111,6 +113,27 @@ def _build(self):
111113 self ._is_built = True
112114 self .set_pose (self ._transform , self ._pos , self ._lookat , self ._up )
113115
116+ def attach (self , rigid_link , offset_T ):
117+ self ._attached_link = rigid_link
118+ self ._attached_offset_T = offset_T
119+
120+ def detach (self ):
121+ self ._attached_link = None
122+ self ._attached_offset_T = None
123+
124+ @gs .assert_built
125+ def move_to_attach (self ):
126+ if self ._attached_link is None :
127+ gs .raise_exception (f"The camera hasn't been mounted!" )
128+ if self ._visualizer ._scene .n_envs > 0 :
129+ gs .raise_exception (f"Mounted camera not supported in parallel simulation!" )
130+
131+ link_pos = self ._attached_link .get_pos ().cpu ().numpy ()
132+ link_quat = self ._attached_link .get_quat ().cpu ().numpy ()
133+ link_T = gu .trans_quat_to_T (link_pos , link_quat )
134+ transform = link_T @ self ._attached_offset_T
135+ self .set_pose (transform = transform )
136+
114137 @gs .assert_built
115138 def render (self , rgb = True , depth = False , segmentation = False , colorize_seg = False , normal = False ):
116139 """
0 commit comments