@@ -146,13 +146,16 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
146146 raise RuntimeError (
147147 "The update function must be called before the data buffers are accessed the first time."
148148 )
149+ # default to all sensors
150+ if len (env_ids ) == self ._num_envs :
151+ env_ids = slice (None )
149152 # obtain the poses of the sensors
150153 pos_w , quat_w = self ._view .get_transforms ()[env_ids ].split ([3 , 4 ], dim = - 1 )
151154 quat_w = math_utils .convert_quat (quat_w , to = "wxyz" )
152155
153156 # store the poses
154- self ._data .pos_w [env_ids ] = pos_w + math_utils .quat_rotate (quat_w , self ._offset_pos_b )
155- self ._data .quat_w [env_ids ] = math_utils .quat_mul (quat_w , self ._offset_quat_b )
157+ self ._data .pos_w [env_ids ] = pos_w + math_utils .quat_rotate (quat_w , self ._offset_pos_b [ env_ids ] )
158+ self ._data .quat_w [env_ids ] = math_utils .quat_mul (quat_w , self ._offset_quat_b [ env_ids ] )
156159
157160 # get the offset from COM to link origin
158161 com_pos_b = self ._view .get_coms ().to (self .device ).split ([3 , 4 ], dim = - 1 )[0 ]
@@ -162,21 +165,21 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
162165 # if an offset is present or the COM does not agree with the link origin, the linear velocity has to be
163166 # transformed taking the angular velocity into account
164167 lin_vel_w += torch .linalg .cross (
165- ang_vel_w , math_utils .quat_rotate (quat_w , self ._offset_pos_b - com_pos_b [env_ids ]), dim = - 1
168+ ang_vel_w , math_utils .quat_rotate (quat_w , self ._offset_pos_b [ env_ids ] - com_pos_b [env_ids ]), dim = - 1
166169 )
167170
168171 # numerical derivative
169- lin_acc_w = (lin_vel_w - self ._prev_lin_vel_w ) / self ._dt + self ._gravity_bias_w
170- ang_acc_w = (ang_vel_w - self ._prev_ang_vel_w ) / self ._dt
172+ lin_acc_w = (lin_vel_w - self ._prev_lin_vel_w [ env_ids ] ) / self ._dt + self ._gravity_bias_w [ env_ids ]
173+ ang_acc_w = (ang_vel_w - self ._prev_ang_vel_w [ env_ids ) / self ._dt
171174 # store the velocities
172175 self ._data .lin_vel_b [env_ids ] = math_utils .quat_rotate_inverse (self ._data .quat_w [env_ids ], lin_vel_w )
173176 self ._data .ang_vel_b [env_ids ] = math_utils .quat_rotate_inverse (self ._data .quat_w [env_ids ], ang_vel_w )
174177 # store the accelerations
175178 self ._data .lin_acc_b [env_ids ] = math_utils .quat_rotate_inverse (self ._data .quat_w [env_ids ], lin_acc_w )
176179 self ._data .ang_acc_b [env_ids ] = math_utils .quat_rotate_inverse (self ._data .quat_w [env_ids ], ang_acc_w )
177180
178- self ._prev_lin_vel_w [: ] = lin_vel_w
179- self ._prev_ang_vel_w [: ] = ang_vel_w
181+ self ._prev_lin_vel_w [env_ids ] = lin_vel_w
182+ self ._prev_ang_vel_w [env_ids ] = ang_vel_w
180183
181184 def _initialize_buffers_impl (self ):
182185 """Create buffers for storing data."""
0 commit comments