Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Collision avoidance in tight spaces with Python API

#1
Hi everyone!

I'm working on a path for material removal on aluminum ingots, with a FANUC M900iB/700 and a very small cage. I know that the setup as is can theoretically reach all points without collisions, but RoboDK cannot process the correct path in a reasonable timeframe. Since the layout is very stringent, I decided that I would calculate the tool angle relative to the surface normal according to the tool's (x,y) position in the active reference frame.
My question is, how can I read the machining program, modify the angle for every point through the Python API (in a cartesian config, not a joint one), and save that as a new program?

Thanks a lot.

The workcell here:
.rdk NovelisV2.rdk(Size: 8.71 MB / Downloads: 358)
#2
I recommend you to just adjust the path to tool orientation properly so the path can be done in one shot with a constant orientation. You can do so by schrolling through the rotZ value (rotation around the Z axis). You can enter values manually.

You can select "Show preferred toolpath" to display a preview of what the robot tool will look like along the path. You'll get an immediate feedback of what the robot will try first.

You can also set the "allow rotation" to 0 deg. This will give you a very fast calculation result but it won't try to rotate around the Z axis if the path is not feasible.



Another option would be to use a script to import and fully customize your program but this would require some coding.
#3
Thanks for the fast response!
#4
Hi Albert.

I tried toadjust the path-to-tool orientation, but I also had to move the ingot closer (IngotRef x pos with respect to station: 913.870). Now that option isn't gonna cut it I think, unfortunately. Searching through the documentation, I'm struggling to find a way to extract the position of a program's points in the desired reference frame through the Python API. Could you point me in the right direction please? Thanks.
#5
Hi Gabriel,

The following example shows how you can extract and modify the target poses of a program.

Code:
# Example to rotate each point of a program with respect to the tool Z axis

# Start the RoboDK API
from robolink import *
from robodk import *
RDK = Robolink()

# set the rotation in radians
TOOL_RZ = 30 * pi / 180

# Ask the user to select a program
prog = RDK.ItemUserPick('Select a program to rotate targets', ITEM_TYPE_PROGRAM)
if not prog.Valid():
# exit if the user selected cancel or no programs were available
quit()

prog_name = prog.Name()
RDK.ShowMessage("Modifying program " + prog_name, False)

nins = prog.InstructionCount()
# Iterate through all the instructions and rotate poses of linear movements
for ins_id in range(nins):
ins_name, ins_type, move_type, isjointtarget, pose, joints = prog.Instruction(ins_id)
if ins_type == INS_TYPE_MOVE:
if move_type == MOVE_TYPE_LINEAR:
pose_rotated = pose*rotz(TOOL_RZ)
prog.setInstruction(ins_id, ins_name, ins_type, move_type, isjointtarget, pose_rotated, joints)
print("Changing instruction " + ins_name)

RDK.ShowMessage("Done modifying program " + prog_name, False)

Once you have the pose of a target you can pre-multiply it by the pose of your coordinate system to calculate the position with respect to another coordinate system. You can use item.Pose() and item.PoseAbs() to retrieve the relative and absolute poses of targets and reference frames respectively.
#6
非常感谢阿尔伯特!这正是我在厕所king for.




Users browsing this thread:
1 Guest(s)