RoboDK Forum
Run Program Instruction from API- Printable Version

+- RoboDK Forum (//m.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//m.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//m.sinclairbody.com/forum/Forum-RoboDK-API)
从API(+——线程:运行程序指令/Thread-Run-Program-Instruction-from-API)



Run Program Instruction from API-Jacob-02-05-2020

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



RE: Run Program Instruction from API-Albert-02-05-2020

嗨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


RE: Run Program Instruction from API-Jacob-02-05-2020

(02-05-2020, 06:55 PM)Albert Wrote:嗨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()?


RE: Run Program Instruction from API-Albert-04-28-2020

嗨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