fake the grasping with ROBOTIQ and UR5

Typically: "How do I... ", "How can I... " questions
Post Reply
Alvarito24
Posts: 3
Joined: 26 Feb 2021, 06:01

fake the grasping with ROBOTIQ and UR5

Post by Alvarito24 »

good afternoon, I would like to implement the code provided by ROBOTIQ_85 in its second option of "You fake the grasping by attaching the object to the gripper via a connector.", in that way to take objects and not be influenced by their dynamic properties. I leave you the code and the steps that appear to me.

-- 2. You fake the grasping by attaching the object to the gripper via a connector. This is
-- much easier and offers very stable results.
--
-- Alternative 2 is explained hereafter:
--
--
-- a) In the initialization phase, retrieve some handles:
--
-- connector=sim.getObjectHandle('ROBOTIQ_85_attachPoint')
-- objectSensor=sim.getObjectHandle('ROBOTIQ_85_attachProxSensor')

-- b) Before closing the gripper, check which dynamically non-static and respondable object is
-- in-between the fingers. Then attach the object to the gripper:
--
-- index=0
-- while true do
-- shape=sim.getObjects(index,sim.object_shape_type)
-- if (shape==-1) then
-- break
-- end
-- if (sim.getObjectInt32Parameter(shape,sim.shapeintparam_static)==0) and (sim.getObjectInt32Parameter(shape,sim.shapeintparam_respondable)~=0) and (sim.checkProximitySensor(objectSensor,shape)==1) then
-- -- Ok, we found a non-static respondable shape that was detected
-- attachedShape=shape
-- -- Do the connection:
-- sim.setObjectParent(attachedShape,connector,true)
-- break
-- end
-- index=index+1
-- end

-- c) And just before opening the gripper again, detach the previously attached shape:
--
-- sim.setObjectParent(attachedShape,-1,true)

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: fake the grasping with ROBOTIQ and UR5

Post by coppelia »

Hello,

and... ? What is your exact question? What is your problem?

Cheers

Alvarito24
Posts: 3
Joined: 26 Feb 2021, 06:01

Re: fake the grasping with ROBOTIQ and UR5

Post by Alvarito24 »

Hello,

my apologies for not posting the question, how is this code implemented correctly?
(Since I always get error regarding this line shape=sim.getObjects(index,sim.object_shape_type) and this sim.setObjectParent(attachedShape,-1,true), under that I would like to know how to correctly implement this code.)

Cheers.

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: fake the grasping with ROBOTIQ and UR5

Post by coppelia »

and here again you do not tell us what the error says... an error message gives you important clues to what is wrong in your code.

Cheers

Alvarito24
Posts: 3
Joined: 26 Feb 2021, 06:01

Re: fake the grasping with ROBOTIQ and UR5

Post by Alvarito24 »

Hi,

Sorry, I will be more specific. The gripper is assembled to the UR5 robotic arm connection. Then, looking for how to take it, I managed to bring the whole assembly to a comfortable position to take the cube (cube that must have dynamic properties at the beginning of the simulation).

Now, at the time I left the default gripper programming, when I realized that the cube had movements affected by the physics of the simulation, I continued reading the default code of the gripper and found the second option in the form of comments. What I did was, to copy each one of those lines (in order as the instructions said) at the beginning and in the same function of "sysCall_actuation", leaving them after the commands already written (or after the third end in the line 36 that comes by default) and run the simulation.

When running I got the following error:
"Lua runtime error: [string "CHILD SCRIPT ROBOTIQ_85"]:56: One of the function's argument type is not correct. (sim.setObjectParent)"
which would be this command: sim.setObjectParent(attachedShape,-1,true). That command should be the last step of "before opening the gripper again, detach the previously attached shape".

So, I take this opportunity to ask, how can I fix this error (concerning sim.setObjectParent(attachedShape,-1,true))? Is it necessary to leave the second option given by the commented code in another function? In case I did not understand well the instructions that is inside this code I ask again, how to implement this second option that is in the code by defalut?

PS: Kindly I don't know if it is mandatory that the gripper has to be near the cube before starting the simulation. Also say that the gripper opens and closes without problems, and you can grab the cube in a normal way, but affected in a physical way. I take this opportunity to ask how to place the images to these comments, to make screenshots.

Cheers.

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: fake the grasping with ROBOTIQ and UR5

Post by coppelia »

Simply print the value of attachedShape, just before the error happens. What does it say?

Code: Select all

print(attachedShape)
The error is very very probably because attachedShape is not defined (i.e. nil) or does not correspond to an object handle.

Cheers

Post Reply