Skip to content

deprecated_utils

A set of utility functions slated to be deprecated once Omniverse bugs are fixed

ArticulationView

Bases: ArticulationView

ArticulationView with some additional functionality implemented.

Source code in omnigibson/utils/deprecated_utils.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
class ArticulationView(_ArticulationView):
    """ArticulationView with some additional functionality implemented."""

    def set_joint_limits(
        self,
        values: Union[np.ndarray, torch.Tensor],
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    ) -> None:
        """Sets joint limits for articulation joints in the view.

        Args:
            values (Union[np.ndarray, torch.Tensor, wp.array]): joint limits for articulations in the view. shape (M, K, 2).
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                                 to manipulate. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
            new_values = self._physics_view.get_dof_limits()
            values = self._backend_utils.move_data(values, device="cpu")
            new_values = self._backend_utils.assign(
                values,
                new_values,
                [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
            )
            self._physics_view.set_dof_limits(new_values, indices)
        else:
            indices = self._backend_utils.to_list(
                self._backend_utils.resolve_indices(indices, self.count, self._device)
            )
            dof_types = self._backend_utils.to_list(self.get_dof_types())
            joint_indices = self._backend_utils.to_list(
                self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            )
            values = self._backend_utils.to_list(values)
            articulation_read_idx = 0
            for i in indices:
                dof_read_idx = 0
                for dof_index in joint_indices:
                    dof_val = values[articulation_read_idx][dof_read_idx]
                    if dof_types[dof_index] == omni.physics.tensors.DofType.Rotation:
                        dof_val /= DEG2RAD
                    prim = get_prim_at_path(self._dof_paths[i][dof_index])
                    prim.GetAttribute("physics:lowerLimit").Set(dof_val[0])
                    prim.GetAttribute("physics:upperLimit").Set(dof_val[1])
                    dof_read_idx += 1
                articulation_read_idx += 1
        return

    def get_joint_limits(
        self,
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        clone: bool = True,
    ) -> Union[np.ndarray, torch.Tensor, wp.array]:
        """Gets joint limits for articulation in the view.

        Args:
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to query. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                                 to query. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).
            clone (Optional[bool]): True to return a clone of the internal buffer. Otherwise False. Defaults to True.

        Returns:
            Union[np.ndarray, torch.Tensor, wp.indexedarray]: joint limits for articulations in the view. shape (M, K).
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return None
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            values = self._backend_utils.move_data(self._physics_view.get_dof_limits(), self._device)
            if clone:
                values = self._backend_utils.clone_tensor(values, device=self._device)
            result = values[
                self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices
            ]
            return result
        else:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            dof_types = self._backend_utils.to_list(self.get_dof_types())
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            values = np.zeros(shape=(indices.shape[0], joint_indices.shape[0], 2), dtype="float32")
            articulation_write_idx = 0
            indices = self._backend_utils.to_list(indices)
            joint_indices = self._backend_utils.to_list(joint_indices)
            for i in indices:
                dof_write_idx = 0
                for dof_index in joint_indices:
                    prim = get_prim_at_path(self._dof_paths[i][dof_index])
                    values[articulation_write_idx][dof_write_idx][0] = prim.GetAttribute("physics:lowerLimit").Get()
                    values[articulation_write_idx][dof_write_idx][1] = prim.GetAttribute("physics:upperLimit").Get()
                    if dof_types[dof_index] == omni.physics.tensors.DofType.Rotation:
                        values[articulation_write_idx][dof_write_idx] = values[articulation_write_idx][dof_write_idx] * DEG2RAD
                    dof_write_idx += 1
                articulation_write_idx += 1
            values = self._backend_utils.convert(values, dtype="float32", device=self._device, indexed=True)
            return values

    def set_max_velocities(
        self,
        values: Union[np.ndarray, torch.Tensor, wp.array],
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    ) -> None:
        """Sets maximum velocities for articulation in the view.

        Args:
            values (Union[np.ndarray, torch.Tensor, wp.array]): maximum velocities for articulations in the view. shape (M, K).
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                                 to manipulate. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
            new_values = self._physics_view.get_dof_max_velocities()
            new_values = self._backend_utils.assign(
                self._backend_utils.move_data(values, device="cpu"),
                new_values,
                [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
            )
            self._physics_view.set_dof_max_velocities(new_values, indices)
        else:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            articulation_read_idx = 0
            indices = self._backend_utils.to_list(indices)
            joint_indices = self._backend_utils.to_list(joint_indices)
            values = self._backend_utils.to_list(values)
            for i in indices:
                dof_read_idx = 0
                for dof_index in joint_indices:
                    prim = PhysxSchema.PhysxJointAPI(get_prim_at_path(self._dof_paths[i][dof_index]))
                    if not prim.GetMaxJointVelocityAttr():
                        prim.CreateMaxJointVelocityAttr().Set(values[articulation_read_idx][dof_read_idx])
                    else:
                        prim.GetMaxJointVelocityAttr().Set(values[articulation_read_idx][dof_read_idx])
                    dof_read_idx += 1
                articulation_read_idx += 1
        return

    def get_max_velocities(
        self,
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        clone: bool = True,
    ) -> Union[np.ndarray, torch.Tensor, wp.indexedarray]:
        """Gets maximum velocities for articulation in the view.

        Args:
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to query. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                                 to query. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).
            clone (Optional[bool]): True to return a clone of the internal buffer. Otherwise False. Defaults to True.

        Returns:
            Union[np.ndarray, torch.Tensor, wp.indexedarray]: maximum velocities for articulations in the view. shape (M, K).
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return None
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
            max_velocities = self._physics_view.get_dof_max_velocities()
            if clone:
                max_velocities = self._backend_utils.clone_tensor(max_velocities, device="cpu")
            result = self._backend_utils.move_data(
                max_velocities[
                    self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices
                ],
                device=self._device,
            )
            return result
        else:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            max_velocities = np.zeros(shape=(indices.shape[0], joint_indices.shape[0]), dtype="float32")
            indices = self._backend_utils.to_list(indices)
            joint_indices = self._backend_utils.to_list(joint_indices)
            articulation_write_idx = 0
            for i in indices:
                dof_write_idx = 0
                for dof_index in joint_indices:
                    prim = PhysxSchema.PhysxJointAPI(get_prim_at_path(self._dof_paths[i][dof_index]))
                    max_velocities[articulation_write_idx][dof_write_idx] = prim.GetMaxJointVelocityAttr().Get()
                    dof_write_idx += 1
                articulation_write_idx += 1
            max_velocities = self._backend_utils.convert(max_velocities, dtype="float32", device=self._device, indexed=True)
            return max_velocities

    def set_joint_positions(
        self,
        positions: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    ) -> None:
        """Set the joint positions of articulations in the view

        .. warning::

            This method will immediately set (teleport) the affected joints to the indicated value.
            Use the ``set_joint_position_targets`` or the ``apply_action`` methods to control the articulation joints.

        Args:
            positions (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): joint positions of articulations in the view to be set to in the next frame.
                                                                    shape is (M, K).
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                                 to manipulate. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).

        .. hint::

            This method belongs to the methods used to set the articulation kinematic states:

            ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
            ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

        Example:

        .. code-block:: python

            >>> # set all the articulation joints.
            >>> # Since there are 5 envs, the joint positions are repeated 5 times
            >>> positions = np.tile(np.array([0.0, -1.0, 0.0, -2.2, 0.0, 2.4, 0.8, 0.04, 0.04]), (num_envs, 1))
            >>> prims.set_joint_positions(positions)
            >>>
            >>> # set only the fingers in closed position: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 0.0
            >>> # for the first, middle and last of the 5 envs
            >>> positions = np.tile(np.array([0.0, 0.0]), (3, 1))
            >>> prims.set_joint_positions(positions, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            new_dof_pos = self._physics_view.get_dof_positions()
            new_dof_pos = self._backend_utils.assign(
                self._backend_utils.move_data(positions, device=self._device),
                new_dof_pos,
                [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
            )
            self._physics_view.set_dof_positions(new_dof_pos, indices)

            # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND SET TARGETS INSTEAD
            # self._physics_view.set_dof_position_targets(new_dof_pos, indices)
            self.set_joint_position_targets(positions, indices, joint_indices)
        else:
            carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_positions")

    def set_joint_velocities(
        self,
        velocities: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    ) -> None:
        """Set the joint velocities of articulations in the view

        .. warning::

            This method will immediately set the affected joints to the indicated value.
            Use the ``set_joint_velocity_targets`` or the ``apply_action`` methods to control the articulation joints.

        Args:
            velocities (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): joint velocities of articulations in the view to be set to in the next frame.
                                                                    shape is (M, K).
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                                 to manipulate. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).

        .. hint::

            This method belongs to the methods used to set the articulation kinematic states:

            ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
            ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

        Example:

        .. code-block:: python

            >>> # set the velocities for all the articulation joints to the indicated values.
            >>> # Since there are 5 envs, the joint velocities are repeated 5 times
            >>> velocities = np.tile(np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]), (num_envs, 1))
            >>> prims.set_joint_velocities(velocities)
            >>>
            >>> # set the fingers velocities: panda_finger_joint1 (7) and panda_finger_joint2 (8) to -0.1
            >>> # for the first, middle and last of the 5 envs
            >>> velocities = np.tile(np.array([-0.1, -0.1]), (3, 1))
            >>> prims.set_joint_velocities(velocities, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
            new_dof_vel = self._physics_view.get_dof_velocities()
            new_dof_vel = self._backend_utils.assign(
                self._backend_utils.move_data(velocities, device=self._device),
                new_dof_vel,
                [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
            )
            self._physics_view.set_dof_velocities(new_dof_vel, indices)

            # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND SET TARGETS INSTEAD
            # self._physics_view.set_dof_velocity_targets(new_dof_vel, indices)
            self.set_joint_velocity_targets(velocities, indices, joint_indices)
        else:
            carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_velocities")
        return

    def set_joint_efforts(
        self,
        efforts: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
        indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
        joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    ) -> None:
        """Set the joint efforts of articulations in the view

        .. note::

            This method can be used for effort control. For this purpose, there must be no joint drive
            or the stiffness and damping must be set to zero.

        Args:
            efforts (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): efforts of articulations in the view to be set to in the next frame.
                                                                    shape is (M, K).
            indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
            joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                                 to manipulate. Shape (K,).
                                                                                 Where K <= num of dofs.
                                                                                 Defaults to None (i.e: all dofs).

        .. hint::

            This method belongs to the methods used to set the articulation kinematic states:

            ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
            ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

        Example:

        .. code-block:: python

            >>> # set the efforts for all the articulation joints to the indicated values.
            >>> # Since there are 5 envs, the joint efforts are repeated 5 times
            >>> efforts = np.tile(np.array([10, 20, 30, 40, 50, 60, 70, 80, 90]), (num_envs, 1))
            >>> prims.set_joint_efforts(efforts)
            >>>
            >>> # set the fingers efforts: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 10
            >>> # for the first, middle and last of the 5 envs
            >>> efforts = np.tile(np.array([10, 10]), (3, 1))
            >>> prims.set_joint_efforts(efforts, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
        """
        if not self._is_initialized:
            carb.log_warn("ArticulationView needs to be initialized.")
            return

        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)

            # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND USE ACTUATION FORCES INSTEAD
            # new_dof_efforts = self._backend_utils.create_zeros_tensor(
            #     shape=[self.count, self.num_dof], dtype="float32", device=self._device
            # )
            new_dof_efforts = self._physics_view.get_dof_actuation_forces()
            new_dof_efforts = self._backend_utils.assign(
                self._backend_utils.move_data(efforts, device=self._device),
                new_dof_efforts,
                [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
            )
            self._physics_view.set_dof_actuation_forces(new_dof_efforts, indices)
        else:
            carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_efforts")
        return

    def _invalidate_physics_handle_callback(self, event):
        # Overwrite super method, add additional de-initialization
        if event.type == int(omni.timeline.TimelineEventType.STOP):
            self._physics_view = None
            self._invalidate_physics_handle_event = None
            self._is_initialized = False

get_joint_limits(indices=None, joint_indices=None, clone=True)

Gets joint limits for articulation in the view.

Parameters:

Name Type Description Default
indices Optional[Union[ndarray, List, Tensor, array]]

indicies to specify which prims to query. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indicies to specify which joints to query. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None
clone Optional[bool]

True to return a clone of the internal buffer. Otherwise False. Defaults to True.

True

Returns:

Type Description
Union[ndarray, Tensor, array]

Union[np.ndarray, torch.Tensor, wp.indexedarray]: joint limits for articulations in the view. shape (M, K).

Source code in omnigibson/utils/deprecated_utils.py
def get_joint_limits(
    self,
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    clone: bool = True,
) -> Union[np.ndarray, torch.Tensor, wp.array]:
    """Gets joint limits for articulation in the view.

    Args:
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to query. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                             to query. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).
        clone (Optional[bool]): True to return a clone of the internal buffer. Otherwise False. Defaults to True.

    Returns:
        Union[np.ndarray, torch.Tensor, wp.indexedarray]: joint limits for articulations in the view. shape (M, K).
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return None
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        values = self._backend_utils.move_data(self._physics_view.get_dof_limits(), self._device)
        if clone:
            values = self._backend_utils.clone_tensor(values, device=self._device)
        result = values[
            self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices
        ]
        return result
    else:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        dof_types = self._backend_utils.to_list(self.get_dof_types())
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        values = np.zeros(shape=(indices.shape[0], joint_indices.shape[0], 2), dtype="float32")
        articulation_write_idx = 0
        indices = self._backend_utils.to_list(indices)
        joint_indices = self._backend_utils.to_list(joint_indices)
        for i in indices:
            dof_write_idx = 0
            for dof_index in joint_indices:
                prim = get_prim_at_path(self._dof_paths[i][dof_index])
                values[articulation_write_idx][dof_write_idx][0] = prim.GetAttribute("physics:lowerLimit").Get()
                values[articulation_write_idx][dof_write_idx][1] = prim.GetAttribute("physics:upperLimit").Get()
                if dof_types[dof_index] == omni.physics.tensors.DofType.Rotation:
                    values[articulation_write_idx][dof_write_idx] = values[articulation_write_idx][dof_write_idx] * DEG2RAD
                dof_write_idx += 1
            articulation_write_idx += 1
        values = self._backend_utils.convert(values, dtype="float32", device=self._device, indexed=True)
        return values

get_max_velocities(indices=None, joint_indices=None, clone=True)

Gets maximum velocities for articulation in the view.

Parameters:

Name Type Description Default
indices Optional[Union[ndarray, List, Tensor, array]]

indicies to specify which prims to query. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indicies to specify which joints to query. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None
clone Optional[bool]

True to return a clone of the internal buffer. Otherwise False. Defaults to True.

True

Returns:

Type Description
Union[ndarray, Tensor, indexedarray]

Union[np.ndarray, torch.Tensor, wp.indexedarray]: maximum velocities for articulations in the view. shape (M, K).

Source code in omnigibson/utils/deprecated_utils.py
def get_max_velocities(
    self,
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    clone: bool = True,
) -> Union[np.ndarray, torch.Tensor, wp.indexedarray]:
    """Gets maximum velocities for articulation in the view.

    Args:
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to query. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                             to query. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).
        clone (Optional[bool]): True to return a clone of the internal buffer. Otherwise False. Defaults to True.

    Returns:
        Union[np.ndarray, torch.Tensor, wp.indexedarray]: maximum velocities for articulations in the view. shape (M, K).
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return None
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
        max_velocities = self._physics_view.get_dof_max_velocities()
        if clone:
            max_velocities = self._backend_utils.clone_tensor(max_velocities, device="cpu")
        result = self._backend_utils.move_data(
            max_velocities[
                self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices
            ],
            device=self._device,
        )
        return result
    else:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        max_velocities = np.zeros(shape=(indices.shape[0], joint_indices.shape[0]), dtype="float32")
        indices = self._backend_utils.to_list(indices)
        joint_indices = self._backend_utils.to_list(joint_indices)
        articulation_write_idx = 0
        for i in indices:
            dof_write_idx = 0
            for dof_index in joint_indices:
                prim = PhysxSchema.PhysxJointAPI(get_prim_at_path(self._dof_paths[i][dof_index]))
                max_velocities[articulation_write_idx][dof_write_idx] = prim.GetMaxJointVelocityAttr().Get()
                dof_write_idx += 1
            articulation_write_idx += 1
        max_velocities = self._backend_utils.convert(max_velocities, dtype="float32", device=self._device, indexed=True)
        return max_velocities

set_joint_efforts(efforts, indices=None, joint_indices=None)

Set the joint efforts of articulations in the view

.. note::

This method can be used for effort control. For this purpose, there must be no joint drive
or the stiffness and damping must be set to zero.

Parameters:

Name Type Description Default
efforts Optional[Union[ndarray, Tensor, array]]

efforts of articulations in the view to be set to in the next frame. shape is (M, K).

required
indices Optional[Union[ndarray, List, Tensor, array]]

indices to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indices to specify which joints to manipulate. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None

.. hint::

This method belongs to the methods used to set the articulation kinematic states:

``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

Example:

.. code-block:: python

>>> # set the efforts for all the articulation joints to the indicated values.
>>> # Since there are 5 envs, the joint efforts are repeated 5 times
>>> efforts = np.tile(np.array([10, 20, 30, 40, 50, 60, 70, 80, 90]), (num_envs, 1))
>>> prims.set_joint_efforts(efforts)
>>>
>>> # set the fingers efforts: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 10
>>> # for the first, middle and last of the 5 envs
>>> efforts = np.tile(np.array([10, 10]), (3, 1))
>>> prims.set_joint_efforts(efforts, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
Source code in omnigibson/utils/deprecated_utils.py
def set_joint_efforts(
    self,
    efforts: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
) -> None:
    """Set the joint efforts of articulations in the view

    .. note::

        This method can be used for effort control. For this purpose, there must be no joint drive
        or the stiffness and damping must be set to zero.

    Args:
        efforts (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): efforts of articulations in the view to be set to in the next frame.
                                                                shape is (M, K).
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                             to manipulate. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).

    .. hint::

        This method belongs to the methods used to set the articulation kinematic states:

        ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
        ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

    Example:

    .. code-block:: python

        >>> # set the efforts for all the articulation joints to the indicated values.
        >>> # Since there are 5 envs, the joint efforts are repeated 5 times
        >>> efforts = np.tile(np.array([10, 20, 30, 40, 50, 60, 70, 80, 90]), (num_envs, 1))
        >>> prims.set_joint_efforts(efforts)
        >>>
        >>> # set the fingers efforts: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 10
        >>> # for the first, middle and last of the 5 envs
        >>> efforts = np.tile(np.array([10, 10]), (3, 1))
        >>> prims.set_joint_efforts(efforts, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return

    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)

        # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND USE ACTUATION FORCES INSTEAD
        # new_dof_efforts = self._backend_utils.create_zeros_tensor(
        #     shape=[self.count, self.num_dof], dtype="float32", device=self._device
        # )
        new_dof_efforts = self._physics_view.get_dof_actuation_forces()
        new_dof_efforts = self._backend_utils.assign(
            self._backend_utils.move_data(efforts, device=self._device),
            new_dof_efforts,
            [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
        )
        self._physics_view.set_dof_actuation_forces(new_dof_efforts, indices)
    else:
        carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_efforts")
    return

set_joint_limits(values, indices=None, joint_indices=None)

Sets joint limits for articulation joints in the view.

Parameters:

Name Type Description Default
values Union[ndarray, Tensor, array]

joint limits for articulations in the view. shape (M, K, 2).

required
indices Optional[Union[ndarray, List, Tensor, array]]

indicies to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indicies to specify which joints to manipulate. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None
Source code in omnigibson/utils/deprecated_utils.py
def set_joint_limits(
    self,
    values: Union[np.ndarray, torch.Tensor],
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
) -> None:
    """Sets joint limits for articulation joints in the view.

    Args:
        values (Union[np.ndarray, torch.Tensor, wp.array]): joint limits for articulations in the view. shape (M, K, 2).
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                             to manipulate. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
        new_values = self._physics_view.get_dof_limits()
        values = self._backend_utils.move_data(values, device="cpu")
        new_values = self._backend_utils.assign(
            values,
            new_values,
            [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
        )
        self._physics_view.set_dof_limits(new_values, indices)
    else:
        indices = self._backend_utils.to_list(
            self._backend_utils.resolve_indices(indices, self.count, self._device)
        )
        dof_types = self._backend_utils.to_list(self.get_dof_types())
        joint_indices = self._backend_utils.to_list(
            self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        )
        values = self._backend_utils.to_list(values)
        articulation_read_idx = 0
        for i in indices:
            dof_read_idx = 0
            for dof_index in joint_indices:
                dof_val = values[articulation_read_idx][dof_read_idx]
                if dof_types[dof_index] == omni.physics.tensors.DofType.Rotation:
                    dof_val /= DEG2RAD
                prim = get_prim_at_path(self._dof_paths[i][dof_index])
                prim.GetAttribute("physics:lowerLimit").Set(dof_val[0])
                prim.GetAttribute("physics:upperLimit").Set(dof_val[1])
                dof_read_idx += 1
            articulation_read_idx += 1
    return

set_joint_positions(positions, indices=None, joint_indices=None)

Set the joint positions of articulations in the view

.. warning::

This method will immediately set (teleport) the affected joints to the indicated value.
Use the ``set_joint_position_targets`` or the ``apply_action`` methods to control the articulation joints.

Parameters:

Name Type Description Default
positions Optional[Union[ndarray, Tensor, array]]

joint positions of articulations in the view to be set to in the next frame. shape is (M, K).

required
indices Optional[Union[ndarray, List, Tensor, array]]

indices to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indices to specify which joints to manipulate. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None

.. hint::

This method belongs to the methods used to set the articulation kinematic states:

``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

Example:

.. code-block:: python

>>> # set all the articulation joints.
>>> # Since there are 5 envs, the joint positions are repeated 5 times
>>> positions = np.tile(np.array([0.0, -1.0, 0.0, -2.2, 0.0, 2.4, 0.8, 0.04, 0.04]), (num_envs, 1))
>>> prims.set_joint_positions(positions)
>>>
>>> # set only the fingers in closed position: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 0.0
>>> # for the first, middle and last of the 5 envs
>>> positions = np.tile(np.array([0.0, 0.0]), (3, 1))
>>> prims.set_joint_positions(positions, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
Source code in omnigibson/utils/deprecated_utils.py
def set_joint_positions(
    self,
    positions: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
) -> None:
    """Set the joint positions of articulations in the view

    .. warning::

        This method will immediately set (teleport) the affected joints to the indicated value.
        Use the ``set_joint_position_targets`` or the ``apply_action`` methods to control the articulation joints.

    Args:
        positions (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): joint positions of articulations in the view to be set to in the next frame.
                                                                shape is (M, K).
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                             to manipulate. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).

    .. hint::

        This method belongs to the methods used to set the articulation kinematic states:

        ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
        ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

    Example:

    .. code-block:: python

        >>> # set all the articulation joints.
        >>> # Since there are 5 envs, the joint positions are repeated 5 times
        >>> positions = np.tile(np.array([0.0, -1.0, 0.0, -2.2, 0.0, 2.4, 0.8, 0.04, 0.04]), (num_envs, 1))
        >>> prims.set_joint_positions(positions)
        >>>
        >>> # set only the fingers in closed position: panda_finger_joint1 (7) and panda_finger_joint2 (8) to 0.0
        >>> # for the first, middle and last of the 5 envs
        >>> positions = np.tile(np.array([0.0, 0.0]), (3, 1))
        >>> prims.set_joint_positions(positions, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        new_dof_pos = self._physics_view.get_dof_positions()
        new_dof_pos = self._backend_utils.assign(
            self._backend_utils.move_data(positions, device=self._device),
            new_dof_pos,
            [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
        )
        self._physics_view.set_dof_positions(new_dof_pos, indices)

        # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND SET TARGETS INSTEAD
        # self._physics_view.set_dof_position_targets(new_dof_pos, indices)
        self.set_joint_position_targets(positions, indices, joint_indices)
    else:
        carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_positions")

set_joint_velocities(velocities, indices=None, joint_indices=None)

Set the joint velocities of articulations in the view

.. warning::

This method will immediately set the affected joints to the indicated value.
Use the ``set_joint_velocity_targets`` or the ``apply_action`` methods to control the articulation joints.

Parameters:

Name Type Description Default
velocities Optional[Union[ndarray, Tensor, array]]

joint velocities of articulations in the view to be set to in the next frame. shape is (M, K).

required
indices Optional[Union[ndarray, List, Tensor, array]]

indices to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indices to specify which joints to manipulate. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None

.. hint::

This method belongs to the methods used to set the articulation kinematic states:

``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

Example:

.. code-block:: python

>>> # set the velocities for all the articulation joints to the indicated values.
>>> # Since there are 5 envs, the joint velocities are repeated 5 times
>>> velocities = np.tile(np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]), (num_envs, 1))
>>> prims.set_joint_velocities(velocities)
>>>
>>> # set the fingers velocities: panda_finger_joint1 (7) and panda_finger_joint2 (8) to -0.1
>>> # for the first, middle and last of the 5 envs
>>> velocities = np.tile(np.array([-0.1, -0.1]), (3, 1))
>>> prims.set_joint_velocities(velocities, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
Source code in omnigibson/utils/deprecated_utils.py
def set_joint_velocities(
    self,
    velocities: Optional[Union[np.ndarray, torch.Tensor, wp.array]],
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
) -> None:
    """Set the joint velocities of articulations in the view

    .. warning::

        This method will immediately set the affected joints to the indicated value.
        Use the ``set_joint_velocity_targets`` or the ``apply_action`` methods to control the articulation joints.

    Args:
        velocities (Optional[Union[np.ndarray, torch.Tensor, wp.array]]): joint velocities of articulations in the view to be set to in the next frame.
                                                                shape is (M, K).
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indices to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indices to specify which joints
                                                                             to manipulate. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).

    .. hint::

        This method belongs to the methods used to set the articulation kinematic states:

        ``set_velocities`` (``set_linear_velocities``, ``set_angular_velocities``),
        ``set_joint_positions``, ``set_joint_velocities``, ``set_joint_efforts``

    Example:

    .. code-block:: python

        >>> # set the velocities for all the articulation joints to the indicated values.
        >>> # Since there are 5 envs, the joint velocities are repeated 5 times
        >>> velocities = np.tile(np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]), (num_envs, 1))
        >>> prims.set_joint_velocities(velocities)
        >>>
        >>> # set the fingers velocities: panda_finger_joint1 (7) and panda_finger_joint2 (8) to -0.1
        >>> # for the first, middle and last of the 5 envs
        >>> velocities = np.tile(np.array([-0.1, -0.1]), (3, 1))
        >>> prims.set_joint_velocities(velocities, indices=np.array([0, 2, 4]), joint_indices=np.array([7, 8]))
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        new_dof_vel = self._physics_view.get_dof_velocities()
        new_dof_vel = self._backend_utils.assign(
            self._backend_utils.move_data(velocities, device=self._device),
            new_dof_vel,
            [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
        )
        self._physics_view.set_dof_velocities(new_dof_vel, indices)

        # THIS IS THE FIX: COMMENT OUT THE BELOW LINE AND SET TARGETS INSTEAD
        # self._physics_view.set_dof_velocity_targets(new_dof_vel, indices)
        self.set_joint_velocity_targets(velocities, indices, joint_indices)
    else:
        carb.log_warn("Physics Simulation View is not created yet in order to use set_joint_velocities")
    return

set_max_velocities(values, indices=None, joint_indices=None)

Sets maximum velocities for articulation in the view.

Parameters:

Name Type Description Default
values Union[ndarray, Tensor, array]

maximum velocities for articulations in the view. shape (M, K).

required
indices Optional[Union[ndarray, List, Tensor, array]]

indicies to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
joint_indices Optional[Union[ndarray, List, Tensor, array]]

joint indicies to specify which joints to manipulate. Shape (K,). Where K <= num of dofs. Defaults to None (i.e: all dofs).

None
Source code in omnigibson/utils/deprecated_utils.py
def set_max_velocities(
    self,
    values: Union[np.ndarray, torch.Tensor, wp.array],
    indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
    joint_indices: Optional[Union[np.ndarray, List, torch.Tensor, wp.array]] = None,
) -> None:
    """Sets maximum velocities for articulation in the view.

    Args:
        values (Union[np.ndarray, torch.Tensor, wp.array]): maximum velocities for articulations in the view. shape (M, K).
        indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
        joint_indices (Optional[Union[np.ndarray, List, torch.Tensor, wp.array]], optional): joint indicies to specify which joints
                                                                             to manipulate. Shape (K,).
                                                                             Where K <= num of dofs.
                                                                             Defaults to None (i.e: all dofs).
    """
    if not self._is_initialized:
        carb.log_warn("ArticulationView needs to be initialized.")
        return
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, "cpu")
        new_values = self._physics_view.get_dof_max_velocities()
        new_values = self._backend_utils.assign(
            self._backend_utils.move_data(values, device="cpu"),
            new_values,
            [self._backend_utils.expand_dims(indices, 1) if self._backend != "warp" else indices, joint_indices],
        )
        self._physics_view.set_dof_max_velocities(new_values, indices)
    else:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        joint_indices = self._backend_utils.resolve_indices(joint_indices, self.num_dof, self._device)
        articulation_read_idx = 0
        indices = self._backend_utils.to_list(indices)
        joint_indices = self._backend_utils.to_list(joint_indices)
        values = self._backend_utils.to_list(values)
        for i in indices:
            dof_read_idx = 0
            for dof_index in joint_indices:
                prim = PhysxSchema.PhysxJointAPI(get_prim_at_path(self._dof_paths[i][dof_index]))
                if not prim.GetMaxJointVelocityAttr():
                    prim.CreateMaxJointVelocityAttr().Set(values[articulation_read_idx][dof_read_idx])
                else:
                    prim.GetMaxJointVelocityAttr().Set(values[articulation_read_idx][dof_read_idx])
                dof_read_idx += 1
            articulation_read_idx += 1
    return

Core

Bases: Core

Subclass that overrides a specific function within Omni's Core class to fix a bug

Source code in omnigibson/utils/deprecated_utils.py
class Core(OmniCore):
    """
    Subclass that overrides a specific function within Omni's Core class to fix a bug
    """
    def __init__(self, popup_callback: Callable[[str], None], particle_system_name: str):
        self._popup_callback = popup_callback
        self.utils = Utils()
        self.context = ou.get_context()
        self.stage = self.context.get_stage()
        self.selection = self.context.get_selection()
        self.particle_system_name = particle_system_name
        self.sub_stage_update = self.context.get_stage_event_stream().create_subscription_to_pop(self.on_stage_update)
        self.on_stage_update()

    def get_compute_graph(self, selected_paths, create_new_graph=True, created_paths=None):
        """
        Returns the first ComputeGraph found in selected_paths.
        If no graph is found and create_new_graph is true, a new graph will be created and its
        path appended to created_paths (if provided).
        """
        graph = None
        graph_paths = [path for path in selected_paths
                       if self.stage.GetPrimAtPath(path).GetTypeName() in ["ComputeGraph", "OmniGraph"] ]

        if len(graph_paths) > 0:
            graph = ogc.get_graph_by_path(graph_paths[0])
            if len(graph_paths) > 1:
                carb.log_warn(f"Multiple ComputeGraph prims selected. Only the first will be used: {graph.get_path_to_graph()}")
        elif create_new_graph:
            # If no graph was found in the selected prims, we'll make a new graph.
            # TODO: THIS IS THE ONLY LINE THAT WE CHANGE! ONCE FIXED, REMOVE THIS
            graph_path = Sdf.Path(f"/OmniGraph/{self.particle_system_name}").MakeAbsolutePath(Sdf.Path.absoluteRootPath)
            graph_path = ou.get_stage_next_free_path(self.stage, graph_path, True)

            # prim = self.stage.GetDefaultPrim()
            # path = str(prim.GetPath()) if prim else ""
            self.stage.DefinePrim("/OmniGraph", "Scope")

            container_graphs = ogc.get_global_container_graphs()
            # FIXME: container_graphs[0] should be the simulation orchestration graph, but this may change in the future.
            container_graph = container_graphs[0]
            result, wrapper_node = ogc.cmds.CreateGraphAsNode(
                graph=container_graph,
                node_name=Sdf.Path(graph_path).name,
                graph_path=graph_path,
                evaluator_name="push",
                is_global_graph=True,
                backed_by_usd=True,
                fc_backing_type=ogc.GraphBackingType.GRAPH_BACKING_TYPE_FLATCACHE_SHARED,
                pipeline_stage=ogc.GraphPipelineStage.GRAPH_PIPELINE_STAGE_SIMULATION
            )
            graph = wrapper_node.get_wrapped_graph()

            if created_paths is not None:
                created_paths.append(graph.get_path_to_graph())

            carb.log_info(f"No ComputeGraph selected. A new graph has been created at {graph.get_path_to_graph()}")

        return graph

get_compute_graph(selected_paths, create_new_graph=True, created_paths=None)

Returns the first ComputeGraph found in selected_paths. If no graph is found and create_new_graph is true, a new graph will be created and its path appended to created_paths (if provided).

Source code in omnigibson/utils/deprecated_utils.py
def get_compute_graph(self, selected_paths, create_new_graph=True, created_paths=None):
    """
    Returns the first ComputeGraph found in selected_paths.
    If no graph is found and create_new_graph is true, a new graph will be created and its
    path appended to created_paths (if provided).
    """
    graph = None
    graph_paths = [path for path in selected_paths
                   if self.stage.GetPrimAtPath(path).GetTypeName() in ["ComputeGraph", "OmniGraph"] ]

    if len(graph_paths) > 0:
        graph = ogc.get_graph_by_path(graph_paths[0])
        if len(graph_paths) > 1:
            carb.log_warn(f"Multiple ComputeGraph prims selected. Only the first will be used: {graph.get_path_to_graph()}")
    elif create_new_graph:
        # If no graph was found in the selected prims, we'll make a new graph.
        # TODO: THIS IS THE ONLY LINE THAT WE CHANGE! ONCE FIXED, REMOVE THIS
        graph_path = Sdf.Path(f"/OmniGraph/{self.particle_system_name}").MakeAbsolutePath(Sdf.Path.absoluteRootPath)
        graph_path = ou.get_stage_next_free_path(self.stage, graph_path, True)

        # prim = self.stage.GetDefaultPrim()
        # path = str(prim.GetPath()) if prim else ""
        self.stage.DefinePrim("/OmniGraph", "Scope")

        container_graphs = ogc.get_global_container_graphs()
        # FIXME: container_graphs[0] should be the simulation orchestration graph, but this may change in the future.
        container_graph = container_graphs[0]
        result, wrapper_node = ogc.cmds.CreateGraphAsNode(
            graph=container_graph,
            node_name=Sdf.Path(graph_path).name,
            graph_path=graph_path,
            evaluator_name="push",
            is_global_graph=True,
            backed_by_usd=True,
            fc_backing_type=ogc.GraphBackingType.GRAPH_BACKING_TYPE_FLATCACHE_SHARED,
            pipeline_stage=ogc.GraphPipelineStage.GRAPH_PIPELINE_STAGE_SIMULATION
        )
        graph = wrapper_node.get_wrapped_graph()

        if created_paths is not None:
            created_paths.append(graph.get_path_to_graph())

        carb.log_info(f"No ComputeGraph selected. A new graph has been created at {graph.get_path_to_graph()}")

    return graph

CreateMeshPrimWithDefaultXformCommand

Bases: CreateMeshPrimWithDefaultXformCommand

Source code in omnigibson/utils/deprecated_utils.py
class CreateMeshPrimWithDefaultXformCommand(CMPWDXC):
    def __init__(self, prim_type: str, **kwargs):
        """
        Creates primitive.

        Args:
            prim_type (str): It supports Plane/Sphere/Cone/Cylinder/Disk/Torus/Cube.

        kwargs:
            object_origin (Gf.Vec3f): Position of mesh center in stage units.

            u_patches (int): The number of patches to tessellate U direction.

            v_patches (int): The number of patches to tessellate V direction.

            w_patches (int): The number of patches to tessellate W direction.
                             It only works for Cone/Cylinder/Cube.

            half_scale (float): Half size of mesh in centimeters. Default is None, which means it's controlled by settings.

            u_verts_scale (int): Tessellation Level of U. It's a multiplier of u_patches.

            v_verts_scale (int): Tessellation Level of V. It's a multiplier of v_patches.

            w_verts_scale (int): Tessellation Level of W. It's a multiplier of w_patches.
                                 It only works for Cone/Cylinder/Cube.
                                 For Cone/Cylinder, it's to tessellate the caps.
                                 For Cube, it's to tessellate along z-axis.

            above_ground (bool): It will offset the center of mesh above the ground plane if it's True,
                False otherwise. It's False by default. This param only works when param object_origin is not given.
                Otherwise, it will be ignored.

            stage (Usd.Stage): If specified, stage to create prim on
        """

        self._prim_type = prim_type[0:1].upper() + prim_type[1:].lower()
        self._usd_context = omni.usd.get_context()
        self._selection = self._usd_context.get_selection()
        self._stage = kwargs.get("stage", self._usd_context.get_stage())
        self._settings = carb.settings.get_settings()
        self._default_path = kwargs.get("prim_path", None)
        self._select_new_prim = kwargs.get("select_new_prim", True)
        self._prepend_default_prim = kwargs.get("prepend_default_prim", True)
        self._above_round = kwargs.get("above_ground", False)

        self._attributes = {**kwargs}
        # Supported mesh types should have an associated evaluator class
        self._evaluator_class = _get_all_evaluators()[prim_type]
        assert isinstance(self._evaluator_class, type)

__init__(prim_type, **kwargs)

Creates primitive.

Parameters:

Name Type Description Default
prim_type str

It supports Plane/Sphere/Cone/Cylinder/Disk/Torus/Cube.

required
kwargs

object_origin (Gf.Vec3f): Position of mesh center in stage units.

u_patches (int): The number of patches to tessellate U direction.

v_patches (int): The number of patches to tessellate V direction.

w_patches (int): The number of patches to tessellate W direction. It only works for Cone/Cylinder/Cube.

half_scale (float): Half size of mesh in centimeters. Default is None, which means it's controlled by settings.

u_verts_scale (int): Tessellation Level of U. It's a multiplier of u_patches.

v_verts_scale (int): Tessellation Level of V. It's a multiplier of v_patches.

w_verts_scale (int): Tessellation Level of W. It's a multiplier of w_patches. It only works for Cone/Cylinder/Cube. For Cone/Cylinder, it's to tessellate the caps. For Cube, it's to tessellate along z-axis.

above_ground (bool): It will offset the center of mesh above the ground plane if it's True, False otherwise. It's False by default. This param only works when param object_origin is not given. Otherwise, it will be ignored.

stage (Usd.Stage): If specified, stage to create prim on

Source code in omnigibson/utils/deprecated_utils.py
def __init__(self, prim_type: str, **kwargs):
    """
    Creates primitive.

    Args:
        prim_type (str): It supports Plane/Sphere/Cone/Cylinder/Disk/Torus/Cube.

    kwargs:
        object_origin (Gf.Vec3f): Position of mesh center in stage units.

        u_patches (int): The number of patches to tessellate U direction.

        v_patches (int): The number of patches to tessellate V direction.

        w_patches (int): The number of patches to tessellate W direction.
                         It only works for Cone/Cylinder/Cube.

        half_scale (float): Half size of mesh in centimeters. Default is None, which means it's controlled by settings.

        u_verts_scale (int): Tessellation Level of U. It's a multiplier of u_patches.

        v_verts_scale (int): Tessellation Level of V. It's a multiplier of v_patches.

        w_verts_scale (int): Tessellation Level of W. It's a multiplier of w_patches.
                             It only works for Cone/Cylinder/Cube.
                             For Cone/Cylinder, it's to tessellate the caps.
                             For Cube, it's to tessellate along z-axis.

        above_ground (bool): It will offset the center of mesh above the ground plane if it's True,
            False otherwise. It's False by default. This param only works when param object_origin is not given.
            Otherwise, it will be ignored.

        stage (Usd.Stage): If specified, stage to create prim on
    """

    self._prim_type = prim_type[0:1].upper() + prim_type[1:].lower()
    self._usd_context = omni.usd.get_context()
    self._selection = self._usd_context.get_selection()
    self._stage = kwargs.get("stage", self._usd_context.get_stage())
    self._settings = carb.settings.get_settings()
    self._default_path = kwargs.get("prim_path", None)
    self._select_new_prim = kwargs.get("select_new_prim", True)
    self._prepend_default_prim = kwargs.get("prepend_default_prim", True)
    self._above_round = kwargs.get("above_ground", False)

    self._attributes = {**kwargs}
    # Supported mesh types should have an associated evaluator class
    self._evaluator_class = _get_all_evaluators()[prim_type]
    assert isinstance(self._evaluator_class, type)

RigidPrimView

Bases: RigidPrimView

Source code in omnigibson/utils/deprecated_utils.py
class RigidPrimView(_RigidPrimView):
    def enable_gravities(self, indices: Optional[Union[np.ndarray, list, torch.Tensor, wp.array]] = None) -> None:
        """Enable gravity on rigid bodies (enabled by default).

        Args:
            indices (Optional[Union[np.ndarray, list, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
        """
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
            data = self._physics_view.get_disable_gravities().reshape(self._count)
            data = self._backend_utils.assign(
                self._backend_utils.create_tensor_from_list([False] * len(indices), dtype="uint8"), data, indices
            )
            self._physics_view.set_disable_gravities(data, indices)
        else:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            indices = self._backend_utils.to_list(indices)
            for i in indices:
                if self._physx_rigid_body_apis[i] is None:
                    if self._prims[i].HasAPI(PhysxSchema.PhysxRigidBodyAPI):
                        rigid_api = PhysxSchema.PhysxRigidBodyAPI(self._prims[i])
                    else:
                        rigid_api = PhysxSchema.PhysxRigidBodyAPI.Apply(self._prims[i])
                    self._physx_rigid_body_apis[i] = rigid_api
                self._physx_rigid_body_apis[i].GetDisableGravityAttr().Set(False)

    def disable_gravities(self, indices: Optional[Union[np.ndarray, list, torch.Tensor, wp.array]] = None) -> None:
        """Disable gravity on rigid bodies (enabled by default).

        Args:
            indices (Optional[Union[np.ndarray, list, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                                 to manipulate. Shape (M,).
                                                                                 Where M <= size of the encapsulated prims in the view.
                                                                                 Defaults to None (i.e: all prims in the view).
        """
        indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
        if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
            data = self._physics_view.get_disable_gravities().reshape(self._count)
            data = self._backend_utils.assign(
                self._backend_utils.create_tensor_from_list([True] * len(indices), dtype="uint8"), data, indices
            )
            self._physics_view.set_disable_gravities(data, indices)
        else:
            indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
            indices = self._backend_utils.to_list(indices)
            for i in indices:
                if self._physx_rigid_body_apis[i] is None:
                    if self._prims[i].HasAPI(PhysxSchema.PhysxRigidBodyAPI):
                        rigid_api = PhysxSchema.PhysxRigidBodyAPI(self._prims[i])
                    else:
                        rigid_api = PhysxSchema.PhysxRigidBodyAPI.Apply(self._prims[i])
                    self._physx_rigid_body_apis[i] = rigid_api
                self._physx_rigid_body_apis[i].GetDisableGravityAttr().Set(True)
            return

disable_gravities(indices=None)

Disable gravity on rigid bodies (enabled by default).

Parameters:

Name Type Description Default
indices Optional[Union[ndarray, list, Tensor, array]]

indicies to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
Source code in omnigibson/utils/deprecated_utils.py
def disable_gravities(self, indices: Optional[Union[np.ndarray, list, torch.Tensor, wp.array]] = None) -> None:
    """Disable gravity on rigid bodies (enabled by default).

    Args:
        indices (Optional[Union[np.ndarray, list, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
    """
    indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        data = self._physics_view.get_disable_gravities().reshape(self._count)
        data = self._backend_utils.assign(
            self._backend_utils.create_tensor_from_list([True] * len(indices), dtype="uint8"), data, indices
        )
        self._physics_view.set_disable_gravities(data, indices)
    else:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        indices = self._backend_utils.to_list(indices)
        for i in indices:
            if self._physx_rigid_body_apis[i] is None:
                if self._prims[i].HasAPI(PhysxSchema.PhysxRigidBodyAPI):
                    rigid_api = PhysxSchema.PhysxRigidBodyAPI(self._prims[i])
                else:
                    rigid_api = PhysxSchema.PhysxRigidBodyAPI.Apply(self._prims[i])
                self._physx_rigid_body_apis[i] = rigid_api
            self._physx_rigid_body_apis[i].GetDisableGravityAttr().Set(True)
        return

enable_gravities(indices=None)

Enable gravity on rigid bodies (enabled by default).

Parameters:

Name Type Description Default
indices Optional[Union[ndarray, list, Tensor, array]]

indicies to specify which prims to manipulate. Shape (M,). Where M <= size of the encapsulated prims in the view. Defaults to None (i.e: all prims in the view).

None
Source code in omnigibson/utils/deprecated_utils.py
def enable_gravities(self, indices: Optional[Union[np.ndarray, list, torch.Tensor, wp.array]] = None) -> None:
    """Enable gravity on rigid bodies (enabled by default).

    Args:
        indices (Optional[Union[np.ndarray, list, torch.Tensor, wp.array]], optional): indicies to specify which prims
                                                                             to manipulate. Shape (M,).
                                                                             Where M <= size of the encapsulated prims in the view.
                                                                             Defaults to None (i.e: all prims in the view).
    """
    if not omni.timeline.get_timeline_interface().is_stopped() and self._physics_view is not None:
        indices = self._backend_utils.resolve_indices(indices, self.count, "cpu")
        data = self._physics_view.get_disable_gravities().reshape(self._count)
        data = self._backend_utils.assign(
            self._backend_utils.create_tensor_from_list([False] * len(indices), dtype="uint8"), data, indices
        )
        self._physics_view.set_disable_gravities(data, indices)
    else:
        indices = self._backend_utils.resolve_indices(indices, self.count, self._device)
        indices = self._backend_utils.to_list(indices)
        for i in indices:
            if self._physx_rigid_body_apis[i] is None:
                if self._prims[i].HasAPI(PhysxSchema.PhysxRigidBodyAPI):
                    rigid_api = PhysxSchema.PhysxRigidBodyAPI(self._prims[i])
                else:
                    rigid_api = PhysxSchema.PhysxRigidBodyAPI.Apply(self._prims[i])
                self._physx_rigid_body_apis[i] = rigid_api
            self._physx_rigid_body_apis[i].GetDisableGravityAttr().Set(False)

colorize_bboxes(bboxes_2d_data, bboxes_2d_rgb, num_channels=3)

Colorizes 2D bounding box data for visualization.

We are overriding the replicator native version of this function to fix a bug. In their version of this function, the ordering of the rectangle corners is incorrect and we fix it here.

Parameters:

Name Type Description Default
bboxes_2d_data ndarray

2D bounding box data from the sensor.

required
bboxes_2d_rgb ndarray

RGB data from the sensor to embed bounding box.

required
num_channels int

Specify number of channels i.e. 3 or 4.

3
Source code in omnigibson/utils/deprecated_utils.py
def colorize_bboxes(bboxes_2d_data, bboxes_2d_rgb, num_channels=3):
    """Colorizes 2D bounding box data for visualization.

    We are overriding the replicator native version of this function to fix a bug.
    In their version of this function, the ordering of the rectangle corners is incorrect and we fix it here.

    Args:
        bboxes_2d_data (numpy.ndarray): 2D bounding box data from the sensor.
        bboxes_2d_rgb (numpy.ndarray): RGB data from the sensor to embed bounding box.
        num_channels (int): Specify number of channels i.e. 3 or 4.
    """
    semantic_id_list = []
    bbox_2d_list = []
    rgb_img = Image.fromarray(bboxes_2d_rgb)
    rgb_img_draw = ImageDraw.Draw(rgb_img)
    for bbox_2d in bboxes_2d_data:
        semantic_id_list.append(bbox_2d['semanticId'])
        bbox_2d_list.append(bbox_2d)
    semantic_id_list_np = np.unique(np.array(semantic_id_list))
    color_list = random_colours(len(semantic_id_list_np.tolist()), True, num_channels)
    for bbox_2d in bbox_2d_list:
        index = np.where(semantic_id_list_np == bbox_2d['semanticId'])[0][0]
        bbox_color = color_list[index]
        outline = (bbox_color[0], bbox_color[1], bbox_color[2])
        if num_channels == 4:
            outline = (
                bbox_color[0],
                bbox_color[1],
                bbox_color[2],
                bbox_color[3],
            )
        rgb_img_draw.rectangle([(bbox_2d['x_min'], bbox_2d['y_min']), (bbox_2d['x_max'], bbox_2d['y_max'])], outline=outline, width=2)
    bboxes_2d_rgb = np.array(rgb_img)
    return bboxes_2d_rgb