RoboDK Forum
Attach an object / Python Script- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: General questions about RoboDK (//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK)
+--- Thread: Attach an object / Python Script (/Thread-Attach-an-object-Python-Script)



Attach an object / Python Script-NRD-04-06-2020

Hello

Can you tell me if we have access to the same hand configuration parameters, from graphical mode to python programming

I encounter a problem in taking an object in python programming that I do not encounter in object mode.

Thank you in advance
Ned C.
Need-Robotics

defTCP_On(toolitem):
"""Attaches the closest object to the toolitem Htool pose,
It will also output appropriate function calls on the generated robot program (call to TCP_On)"""
toolitem.AttachClosest()
toolitem.RDK().RunMessage('Set air valve on')
toolitem.RDK().RunProgram('TCP_On()');


whilei < nparts:
# ----------- place the box i on the convegor ------
# approach to the conveyor
robot.setPoseFrame(frame_conv)
target_conv_pose = target_conv.Pose()*transl(0,0,-SIZE_BOX_Z/2)
target_conv_app = target_conv_pose*transl(0,0,-APPROACH)
robot.MoveJ(target_conv_safe)
robot.MoveJ(target_conv_app)
WaitSensor()
robot.MoveL(target_conv_pose)
TCP_On(tool)# detach an place the object in the moving reference frame of the conveyor
robot.MoveL(target_conv_app)
robot.MoveJ(target_conv_safe)


# ----------- take a part from the conveyor ------
# get the xyz position of part i
robot.setPoseFrame(frame_pallet)
part_position_i = parts_positions[i]
target_i = transl(part_position_i)*rotx(pi)
target_i_app = target_i * transl(0,0,-(APPROACH+SIZE_BOX_Z))
# approach to the pallet
robot.MoveJ(target_pallet_safe)
# get the box i
robot.MoveJ(target_i_app)
robot.MoveL(target_i)
TCP_Off(tool, frame_pallet)# attach the closest part
robot.MoveL(target_i_app)
robot.MoveJ(target_pallet_safe)

i = i +1



RE: Attach an object / Python Script-Jeremy-04-07-2020

Hi Ned,

I think this is what you are looking for:

Code:
AttachClosest()

Take a look at thislinkto our API documentation.

You will also need:
Code:
DetachAll(parent=0)
and this:
Code:
DetachClosest(parent=0)

Here's thelink.

Hope it helps.
Have a great day.
Jeremy


RE: Attach an object / Python Script-NRD-04-07-2020

Hi Jeremy

Thank you but no the problem is still the same, attached is the video the problem video.

Thank for your support
Ned

Lien du téléchargementhttps://we.tl/t-K6g9sp7ttS


RE: Attach an object / Python Script-Jeremy-04-08-2020

Hi Need,

Could you attach your RoboDK station, I'll take a quick look.

Jeremy


RE: Attach an object / Python Script-NRD-04-08-2020

Hi Jeremy
Attached is the project
Thank
Ned C.


RE: Attach an object / Python Script-Jeremy-04-08-2020

Bonjour Ned,

Ok, I figured out your problem.
It will be easy to fix.

Right now you are not able to pick the part because the distance between the TCP and the Object Reference is higher than the default setting.
The default setting is 200 mm.
The distance is shown in the picture below.


You can see the object reference by right-clicking the object and selecting "Visible Object Reference".

Know you can fix that issue in three different ways.

1 - Modify the position of the object reference.
To do so, you can either hold "Alt + Shift" and move the object reference manually or double-click the object to show the object panel, "More options" and use the text box to modify the position of the geometry. Click "Apply move" when you are done.

2 - Change the default maximum grabbing distance.
To do so, "Tools"->"Options"->"General"
At the bottom of the window, you should see "Maximum distance to attach an object". Simply increase that value.

3 - Change the default type of attaching command use from "object reference" to "object surface".
To do so, "Tools"->"Options"->"General"
At the bottom of the window, you should see "Check shortest distance between TCP and object shape". Active that option.

Have a great day.
Jeremy


RE: Attach an object / Python Script-NRD-04-09-2020

Hello and thank you Jeremy
It works and I learned two important things.
See you soon