KUKA has now also an official python interface. It works via the latest mxAutomation V3.3.
-> Ask the CS for the latest mxAutomation Python library: CustomerService@kuka.com
Control a KUKA industrial robot via the new python library in 6 steps:
1. Install mxAutomation via WorkVisual by drag and drop
2. Ask KUKA for the latest mxAutomation Python library.
3. Open some socket communication to the KLI (KUKA Line Interface), Port 1336
4. Process the received answer from the KUKA robot, with the class “KRC_ReadAxisGroup” of the mxAutomation python library.
5. Now you can already receive position data, via the class “KRC_ReadActualAxisPosition”
6. And you can move the Robot
Here an outtake of an small application:
Code
# -------- STEP 20 - KRC_MOVEAXISABSOLUTE ------------
_mxA_KRC_MOVEAXISABSOLUTE.AXISGROUPIDX = _axisGroupIdx
_mxA_KRC_MOVEAXISABSOLUTE.BUFFERMODE = 2
_mxA_KRC_MOVEAXISABSOLUTE.VELOCITY = 50 # %
_mxA_KRC_MOVEAXISABSOLUTE.APPROXIMATE = APO_parameter
_mxA_KRC_MOVEAXISABSOLUTE.AXISPOSITION = axis_target_pos_1
if test_step == 20 :
_mxA_KRC_MOVEAXISABSOLUTE.EXECUTECMD = True
print("Move Axis Absolute Busy: " , _mxA_KRC_MOVEAXISABSOLUTE.BUSY , " Active: ", _mxA_KRC_MOVEAXISABSOLUTE._ACTIVE, " Done ", _mxA_KRC_MOVEAXISABSOLUTE._DONE , " Error ", _mxA_KRC_MOVEAXISABSOLUTE.ERROR , _mxA_KRC_MOVEAXISABSOLUTE.ERRORID)
if test_step == 20 and _mxA_KRC_MOVEAXISABSOLUTE.DONE and round(_mxA_KRC_MOVEAXISABSOLUTE.AXISPOSITION.A1,1) == round(_mxA_READACTUALAXISPOSITION.A1,1) and NextStep :
test_step = 30
_mxA_KRC_MOVEAXISABSOLUTE.EXECUTECMD = False
if _mxA_KRC_MOVEAXISABSOLUTE.ERROR:
print("move error id" , _mxA_KRC_MOVEAXISABSOLUTE.ERRORID )
raise Exception("Error in Step " , test_step )
# -------- STEP 30 - KRC_MOVEAXISABSOLUTE_2 second call ------------
_mxA_KRC_MOVEAXISABSOLUTE_2.AXISGROUPIDX = _axisGroupIdx
_mxA_KRC_MOVEAXISABSOLUTE_2.BUFFERMODE = 2
_mxA_KRC_MOVEAXISABSOLUTE_2.VELOCITY = 50 # %
_mxA_KRC_MOVEAXISABSOLUTE_2.APPROXIMATE = APO_parameter
_mxA_KRC_MOVEAXISABSOLUTE_2.AXISPOSITION = axis_target_pos_2
if test_step == 30 :
_mxA_KRC_MOVEAXISABSOLUTE_2.EXECUTECMD = True
print("Move Axis Absolute Busy: " , _mxA_KRC_MOVEAXISABSOLUTE_2.BUSY , " Active: ", _mxA_KRC_MOVEAXISABSOLUTE_2._ACTIVE, " Done ", _mxA_KRC_MOVEAXISABSOLUTE_2._DONE , " Error ", _mxA_KRC_MOVEAXISABSOLUTE_2.ERROR , _mxA_KRC_MOVEAXISABSOLUTE_2.ERRORID)
if test_step == 30 and _mxA_KRC_MOVEAXISABSOLUTE_2.DONE and round(_mxA_KRC_MOVEAXISABSOLUTE_2.AXISPOSITION.A1,1) == round(_mxA_READACTUALAXISPOSITION.A1,1) and NextStep :
test_step = 40
_mxA_KRC_MOVEAXISABSOLUTE_2.EXECUTECMD = False
Display More