Solution for exercice 6.3 ROS manipulation

Good morning, I am struggling in the exercice 6.3 using the pick_and_place.py scripts.
I can’t figure it out how to select the right cube from the perception.

I think that I have to play in the main().
I think that the key for this exercice is to find a way to address the action to take for the right cube detected from perception:

cube, grasps = grasping_client.getGraspableObject()

If I don’t get it wrong the output would be the 2 cube detected.
I think that I need to modify the following line in order to address to the right object detected

# Pick the block
            if grasping_client.pick(cube, grasps):

for placing:

pose.pose = cube.primitive_poses[0]
            pose.pose.position.y *= -1.0

How could I address to right cube?
I have tried with cube[0] but it doesn’t work. Could someone help me out please?
Thank you
Francesco

Hello @Francesco_Rizzotti ,

I’ve sent the solution to your e-mail.

Best,