Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run Program Instruction from API
#1
Hey guys,
We are trying to execute a specific instruction from a robot program using the python api.  We looked at RunInstruction() but that didnt seem to be quite what we were looking for.  We are iterating thru the list of instruction and just want to execute the move commands from the file. Here is the while loop that searches the program, but doesnt execute.  Thanks 
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)
    print(ins_type)
    #ins_type 0 is MoveJ or MoveL, MoveC =1
    if ins_type <= 1:
        # Select the movement instruction as a reference
        prog.InstructionSelect(ins_id)
        
        # Add a new program call
        # prog.RunInstruction(ins_call, INSTRUCTION_CALL_PROGRAM)
        TeachTar.RunCode()
        while TeachTar.Busy():
            pause(0.01)

        # 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
#2
Hi Jacob,

You can't run a specific instruction using the API, however, you can execute that on the robot item.
For example, if you have a linear move instruction to a Cartesian target you can do:
Code:
robot.MoveL(pose)

Albert
#3
(02-05-2020, 06:55 PM)Albert Wrote: Hi Jacob,

You can't run a specific instruction using the API, however, you can execute that on the robot item.
For example, if you have a linear move instruction to a Cartesian target you can do:
Code:
robot.MoveL(pose)

Albert

Sounds great @Albert, what if we have some moveC types?  We see the pose info for moveL but no pose info for MoveC
Code:
print(prog.Instruction(ins_id))

exam: moveL vs moveC
MoveL:
('*MoveL P2', 0, 2, 0, Matrix: (4, 4)
Pose(969.624, -138.087, 472.785,  -92.893, 85.340, -122.269):
[[ -0.043, 0.069, 0.997, 969.624 ],
[ 0.574, -0.815, 0.081, -138.087 ],
[ 0.818, 0.576, -0.004, 472.785 ],
[ 0.000, 0.000, 0.000, 1.000 ]]
, Matrix: (6, 1)
[[ -11.328 ],
[ -22.968 ],
[ -20.060 ],
[ 40.193 ],
[ 25.254 ],
[ -2.164 ]]
)
MoveC:
('*MoveC P31,P32', 1, None, None, None, None)

Also is there a way to show a target for a specific instruction without showing all the targets for a given program? such as prog.ShowTargets()?
#4
Hi Jacob,

You can right click an instruction and select "Select Target" to see the target for that specific instruction.

It is not possible to show targets only for specific instructions using the API.

Albert
  




Users browsing this thread:
1 Guest(s)