Beispiel #1
0
    def _get_objects_in_tree(root_object=None,
                             object_type=ObjectType.ALL,
                             exclude_base=True,
                             first_generation_only=False) -> List['Object']:
        if root_object is None:
            root_object = sim.sim_handle_scene
        elif isinstance(root_object, Object):
            root_object = root_object.get_handle()
        elif not isinstance(root_object, int):
            raise ValueError('root_object must be None, int or Object')

        options = 0
        if exclude_base:
            options |= 1
        if first_generation_only:
            options |= 2
        handles = sim.simGetObjectsInTree(root_object, object_type.value,
                                          options)
        objects = []
        for handle in handles:
            try:
                objects.append(Object.get_object(handle))
            except KeyError:
                # e.g., CAMERA and LIGHT are not officially supported
                name = Object.get_object_name(handle)
                type = Object.get_object_type(name)
                warnings.warn("Object ({}, '{}') has {}, "
                              'which is not supported'.format(
                                  handle, name, type))
        return objects
Beispiel #2
0
    def get_object(name_or_handle: str) -> 'Object':
        """Gets object retrieved by name.

        :return: The object.
        """
        name = Object.get_object_name(name_or_handle)
        object_type = Object.get_object_type(name)
        cls = object_type_to_class[object_type]
        return cls(name)
Beispiel #3
0
 def test_get_object_name(self):
     self.assertEqual(Object.get_object_name('dynamic_cube'),
                      'dynamic_cube')
     self.assertEqual(
         Object.get_object_name(self.dynamic_cube.get_handle()),
         'dynamic_cube')