Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read Position Data form Machining Project
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:
path_settings = RDK.AddMachiningProject("milling")
prog, status = path_settings.setMachiningParameters(ncfile="Milling Bowl", part=RDK.Item('FrameTest'), params = "RotZ_Range=45 RotZ_Step=5 NormalApproach=50")

ItemList = prog.InstructionList()
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:

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

# 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
       # 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)