Failed to run tutorial example

Hi, I am using Isaac Sim, 2022.1.1. I tried to run the tutorial example but I found that it does not work properly. Also the size of the cube is not the same as what we see in the tutorial video.

Please let me know what I am doing wrong.

Hi Leila,

Thanks for reporting this issue. The problem here is the default size of the cube which will be fixed in the next release and the default gripper position. This can be solved by specifying the size of the cube to be 1 as well as explicitly setting the gripper positions to be opened on reset and on load.

Here is the modified script:

    from omni.isaac.examples.base_sample import BaseSample
    from omni.isaac.franka import Franka
    from omni.isaac.core.objects import DynamicCuboid
    from omni.isaac.franka.controllers import PickPlaceController
    from omni.isaac.core.tasks import BaseTask
    import numpy as np
    class FrankaPlaying(BaseTask):
        # NOTE: we only cover here a subset of the task functions that are available,
        # checkout the base class for all the available functions to override.
        # ex: calculate_metrics, is_done..etc.
        def __init__(self, name):
            super().__init__(name=name, offset=None)
            self._goal_position = np.array([-0.3, -0.3, 0.0515 / 2.0])
            self._task_achieved = False
        # Here we setup all the assets that we care about in this task.
        def set_up_scene(self, scene):
            self._cube = scene.add(
                    position=np.array([0.3, 0.3, 0.3]),
                    scale=np.array([0.0515, 0.0515, 0.0515]),
                    color=np.array([0, 0, 1.0]),
                    size=1 #TODO: change here
            self._franka = scene.add(Franka(prim_path="/World/Fancy_Franka", name="fancy_franka"))
        # Information exposed to solve the task is returned from the task through get_observations
        def get_observations(self):
            cube_position, _ = self._cube.get_world_pose()
            current_joint_positions = self._franka.get_joint_positions()
            observations = {
       {"joint_positions": current_joint_positions},
       {"position": cube_position, "goal_position": self._goal_position},
            return observations
        # Called before each physics step,
        # for instance we can check here if the task was accomplished by
        # changing the color of the cube once its accomplished
        def pre_step(self, control_index, simulation_time):
            cube_position, _ = self._cube.get_world_pose()
            if not self._task_achieved and np.mean(np.abs(self._goal_position - cube_position)) < 0.02:
                # Visual Materials are applied by default to the cube
                # in this case the cube has a visual material of type
                # PreviewSurface, we can set its color once the target is reached.
                self._cube.get_applied_visual_material().set_color(color=np.array([0, 1.0, 0]))
                self._task_achieved = True
    class HelloWorld(BaseSample):
        def __init__(self) -> None:
        def setup_scene(self):
            world = self.get_world()
            # We add the task to the world here
        async def setup_post_load(self):
            self._world = self.get_world()
            # The world already called the setup_scene from the task (with first reset of the world)
            # so we can retrieve the task objects
            self._franka = self._world.scene.get_object("fancy_franka")
            self._controller = PickPlaceController(
                name="pick_place_controller", gripper=self._franka.gripper, robot_articulation=self._franka
            self._world.add_physics_callback("sim_step", callback_fn=self.physics_step)]
            #TODO: change here
            await self._world.play_async()
        async def setup_post_reset(self):
            await self._world.play_async()
            #TODO: change here
        def physics_step(self, step_size):
            # Gets all the tasks observations
            current_observations = self._world.get_observations()
            actions = self._controller.forward(
            if self._controller.is_done():

Let us know if you have more questions.

1 Like

Thank you @oahmed for your answer. The problem for opening the gripper was solved by the provided code, however, the robot is not able to pick the cube up. Because the gripper goes through the cube and cannot grab it.

I have these warnings :
[Warning] [omni.client.plugin] Tick: authentication: Discovery(wss://localhost/omni/discovery): Error creating Api/Connection search: Not connected
[Warning] [carb.flatcache.plugin] Type tag does not have a corresponding USD type
[Warning] [] Requesting texture to use texture streaming, but the service isn’t available.The texture will be created as a regular resource.

I would appreciate it if you give the solution to this problem too.