Isaac Sim Version
2023.1.1
Operating System
Ubuntu 22.04
GPU Information
- Model: NVIDIA GeForce RTX 3090
- Driver Version: 570.124.04
Can there be 2 decider network in same cortex world with 2 different robot and different work ?
I have been trying to run 2 UR10 robot in cortex world. i have created 2 different DfState and 2 different CortexUr10 robot. i want to pick and place 2 cube at same time but with different robot.
But i am getting is only one decider network is working but the moment is copied by both the robot.
Below i have attached the code and video.
Can somebody from official team help, if this could be achievable or not. and if yes what i am missing.
CODE
> from omni.isaac.kit import SimulationApp
>
> simulation_app = SimulationApp({"headless": False})
>
> import numpy as np
> from omni.isaac.core.objects import DynamicCuboid
> from omni.isaac.cortex.cortex_world import CortexWorld
> from omni.isaac.cortex.df import DfNetwork, DfState, DfStateMachineDecider
> from omni.isaac.cortex.dfb import DfRobotApiContext, DfBasicContext
> from omni.isaac.cortex.robot import CortexUr10, add_ur10_to_stage
> from omni.isaac.universal_robots import UR10
> from omni.isaac.core.utils.types import ArticulationAction
> from omni.isaac.core.utils.stage import add_reference_to_stage
>
> class PickState(DfState):
> @property
> def robot(self):
> return self.context.robot
>
> @property
> def pick_cube(self):
> return self.context.robot.pick_cube
>
> def enter(self):
> self.gripper_has_cube = False
> # self.robot.set_joints_default_state(positions=np.array([0.0,1.57, 1.57, 0.0, 1.57, 0.0]))
> self.robot.suction_gripper.open()
> self.target_pos, self.target_ort = self.pick_cube.get_world_pose()
> print("Target Position: ", self.target_pos)
> pass
>
> def step(self):
> self.eff_p = self.robot.arm.get_fk_p()
> self.new_target = self.target_pos + np.array([0,0,0.1/2])
> print("New Target for pick cube: ", self.new_target)
> self.robot.arm.send_end_effector(target_position=self.new_target)
> if not self.gripper_has_cube and np.linalg.norm(self.new_target - self.eff_p) < 0.01 :
> self.robot.suction_gripper.close()
> self.gripper_has_cube = True
> print("Gripper has cube")
> if self.gripper_has_cube:
> self.robot.arm.send_end_effector(target_position=np.array([0.4, 0.8, 0.15]))
> if np.linalg.norm(np.array([0.4, 0.8, 0.15]) - self.eff_p) < 0.01 :
> self.robot.suction_gripper.open()
> self.robot.arm.send_end_effector(target_position=np.array([0.0, 0.8, 0.1]))
> return None
> return self
>
>
> class PickState1(DfState):
> @property
> def robot(self):
> return self.context.robot
>
> @property
> def pick_cube(self):
> return self.context.robot.pick_cube1
>
> def enter(self):
> self.gripper_has_cube = False
> # self.robot.set_joints_default_state(positions=np.array([0.0,1.57, 1.57, 0.0, 1.57, 0.0]))
> self.robot.suction_gripper.open()
> self.target_pos, self.target_ort = self.pick_cube.get_world_pose()
> print("Target Position: ", self.target_pos)
> pass
>
> def step(self):
> self.eff_p = self.robot.arm.get_fk_p()
> self.new_target = self.target_pos + np.array([0,0,0.1/2])
> print("New Target for pick cube 1: ", self.new_target)
> # self.robot.arm.send_end_effector(target_position=self.new_target)
> # if not self.gripper_has_cube and np.linalg.norm(self.new_target - self.eff_p) < 0.01 :
> # self.robot.suction_gripper.close()
> # self.gripper_has_cube = True
> # print("Gripper has cube")
> # if self.gripper_has_cube:
> # self.robot.arm.send_end_effector(target_position=np.array([0.4, 0.8, 0.15]))
> # if np.linalg.norm(np.array([0.4, 0.8, 0.15]) - self.eff_p) < 0.01 :
> # self.robot.suction_gripper.open()
> # self.robot.arm.send_end_effector(target_position=np.array([0.0, 0.8, 0.1]))
> # return None
> return self
>
>
>
> def main():
> world = CortexWorld()
> add_reference_to_stage(usd_path="/home/user/warehouse_defect_detection_pipeline/usd/Test.usd", prim_path="/World/Robot1")
> add_reference_to_stage(usd_path="/home/user/warehouse_defect_detection_pipeline/usd/Test.usd", prim_path="/World/Robot2")
>
> robot1 = world.add_robot(CortexUr10(name="Ur10_1", prim_path="/World/Robot1/UR10/ur10"))
>
> robot2 = world.add_robot(CortexUr10(name="Ur10_2", prim_path="/World/Robot2/UR10/ur10", position=np.array([1.0,1.5,0.0]), orientation=np.array([0.0, 0.0, 0.0, -1.0])))
>
> robot1.pick_cube = world.scene.add(
> DynamicCuboid(
> name="pick_cube", prim_path="/World/PickCube",position=np.array([0.0, 0.8, 0.1 / 2]), scale=np.array([0.1, 0.1, 0.1]), color=np.array([0.7,0.0,0.7])
> )
> )
>
> robot2.pick_cube1 = world.scene.add(
> DynamicCuboid(
> name="pick_cube1", prim_path="/World/PickCube_1",position=np.array([1.0, 0.8, 0.1 / 2]), scale=np.array([0.1, 0.1, 0.1]), color=np.array([0.7,0.0,0.0])
> )
> )
> world.scene.add_default_ground_plane()
>
> world.add_decider_network(DfNetwork(DfStateMachineDecider(PickState()), context=DfBasicContext(robot1)))
> world.add_decider_network(DfNetwork(DfStateMachineDecider(PickState1()), context=DfBasicContext(robot2)))
>
> world.run(simulation_app)
> simulation_app.close()
>
> if __name__ == "__main__":
> main()
VIDEO: