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

Read Position Data form Machining Project

#1
I'm currently working on a Python script that I want to use to automate a machining project on our robot. The creation of the machining project from the GCode is already working. Now I would like to insert a position before the first point of the machining program, so that the robot first moves over the first path point and then starts the program. My problem is now, I find in the documentation no way to read the position of the first point.


I tried to have the InstuctionList output, but here I can not find any way to identify the first move command and then read out the position data.
The code I used looks like this:
Code:
robot.setPoseFrame(RDK.Item('FrameTest'))
path_settings = RDK.AddMachiningProject("milling")
prog, status = path_settings.setMachiningParameters(ncfile="Milling Bowl 3x.nc", part=RDK.Item('FrameTest'), params = "RotZ_Range=45 RotZ_Step=5 NormalApproach=50")

ItemList = prog.InstructionList()
print(ItemList)
#2
You can use program.SelectInstruction(id) to add instructions and program.Instruction(id) / setInstruction to get/set information about a target (mostly used to retrieve the type of instruction and modify movement instructions). Also, RunInstruction allows you to add a program call at the end of a program (or after the selected instruction if you use SelectInstruction.

More examples here:
https://robodk.com/doc/en/PythonAPI/robo...AddProgram

This shows an example that adds a program call after every movement in a program.

Code:
# Iterate through all the instructions in a program:
ins_id = 0
ins_count = prog.InstructionCount()
while ins_id < ins_count:
   # Retrieve instruction
   ins_nom, ins_type, move_type, isjointtarget, pose, joints = prog.Instruction(ins_id)
   if ins_type == INS_TYPE_MOVE:
       # Select the movement instruction as a reference
       prog.InstructionSelect(ins_id)
       # Add a new program call
       prog.RunInstruction('RunSubProgram', INSTRUCTION_CALL_PROGRAM)
       # Advance one additional instruction as we just added another instruction
       ins_id = ins_id + 1
       ins_count = ins_count + 1
       
   ins_id = ins_id + 1
  




Users browsing this thread:
1 Guest(s)