Pick Place Task for custom object

Hi, I have been trying to make a simulation, where I have to use a Franka bot to pick and place small custom prim. I followed this code for setting up a task

from omni.isaac.examples.base_sample import BaseSample

from omni.isaac.franka.tasks import PickPlace

from omni.isaac.franka.controllers import PickPlaceController



class HelloWorld(BaseSample):

    def __init__(self) -> None:

        super().__init__()

        return


    def setup_scene(self):

        world = self.get_world()

        # We add the task to the world here

        world.add_task(PickPlace(name="awesome_task"))

        return


    async def setup_post_load(self):

        self._world = self.get_world()

        # The world already called the setup_scene from the task so

        # we can retrieve the task objects

        # Each defined task in the robot extensions

        # has set_params and get_params to allow for changing tasks during

        # simulation, {"task_param_name": "value": [value], "modifiable": [True/ False]}

        task_params = self._world.get_task("awesome_task").get_params()

        self._franka = self._world.scene.get_object(task_params["robot_name"]["value"])

        self._cube_name = task_params["cube_name"]["value"]

        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)

        await self._world.play_async()

        return


    async def setup_post_reset(self):

        self._controller.reset()

        await self._world.play_async()

        return


    def physics_step(self, step_size):

        # Gets all the tasks observations

        current_observations = self._world.get_observations()

        actions = self._controller.forward(

            picking_position=current_observations[self._cube_name]["position"],

            placing_position=current_observations[self._cube_name]["target_position"],

            current_joint_positions=current_observations[self._franka.name]["joint_positions"],

        )

        self._franka.apply_action(actions)

        if self._controller.is_done():

            self._world.pause()

        return

Here the issue is this PickandPlace task already comes with a cube. I want to know how can i modify it so that pick and place works with any custom prim I want?

I was able to solve this by following Hello world documentation, which shows how to write a custom task using Pick Place controller

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.