1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. KUKA Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Define TOOL and BASE in KRL

  • Agustin Costa
  • September 5, 2019 at 4:25 PM
  • Thread is Resolved
  • Agustin Costa
    Reactions Received
    4
    Trophies
    3
    Posts
    58
    • September 5, 2019 at 4:25 PM
    • #1

    Hello,

    I created a program in my robot to move it to the coordinates and orientation sent to it through EthernetKRL with the option to define BASE, TOOL and other parameters of the movement. I have also created a script in C# in my PC to send the commands to the robot and I am able to make it move to the specified coordinates and orientation.

    The problem I am having is that I cannot define the new TOOL and BASE to use when a movement command is sent, so all movements are made relative to the default $WORLD coordiante system and with the default TCP.

    I don't want define each tool and base beforehand in the SmartPAD and just change the $ACT_BASE and $ACT_TOOL numbers because this would take away some of the flexibility of the program, so I'm looking to do it in the KRL program itself. Can anyone help me with this?

    Here is my code:

    SRC:

    Code
    &ACCESS RVP
    &REL 1
    &COMMENT Programa de movimiento a coordenadas por EKI
    DEF DynamicProg ( )
    ;FOLD INI
      ;FOLD BASISTECH INI
        GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
        INTERRUPT ON 3 
        BAS (#INITMOV,0 )
      ;ENDFOLD (BASISTECH INI)
      ;FOLD USER INI
        ;Make your modifications here
    
      ;ENDFOLD (USER INI)
      ;ENDFOLD (INI)
      
    ;--------------------------INICIALIZACIONES-----------------------------
      ENA = FALSE
      $FLAG[15] = FALSE ;STATUS
      $FLAG[16] = FALSE ;TURN
      $FLAG[17] = FALSE ;ENABLE
      $FLAG[18] = FALSE ;TCP
      $FLAG[19] = FALSE ;BASE
      $FLAG[20] = FALSE ;ACCEL
      $FLAG[21] = FALSE ;VEL
      STANDBY = TRUE
      LINEAR = FALSE
      GOAL_POS_X = 400.0
      GOAL_POS_Y = 0.0
      GOAL_POS_Z = 308.0
      GOAL_ANG_A = -180.0
      GOAL_ANG_B = 87.0
      GOAL_ANG_C = -180.0
      GOAL_STAT = 6
      GOAL_TURN = 26
      USER_BASE = $NULLFRAME
      USER_TCP = $NULLFRAME
      ACTUAL = $NULLFRAME
      
      PTP INICIAL ;MOVIMIENTO A POS INICIAL
      
      RET = EKI_Init("CoordinatesMovement") ;ESTABLECE COMUNICACION
      RET = EKI_Open("CoordinatesMovement")
      
      ;------------------------------LOOP------------------------------------
      LOOP ;COMIENZA LOOP DE LECTURA DE DATOS OBJETIVO Y MOVIMIENTO
        
        STANDBY = TRUE ;BOOLEANO A PC PARA HABILITAR ENVIO DE NUEVOS DATOS
        
        RET = EKI_SetBool("CoordinatesMovement","Robot/Read/Standby",STANDBY)  ;ENVIO DE HABILITACION
        RET = EKI_Send("CoordinatesMovement","Robot")
        
        WAIT FOR $FLAG[17] ;ESPERA FLAG DE RECEPCION DE DATOS
        IF $FLAG[17]==FALSE THEN
          EXIT
        ENDIF
        
        ;---------------------------RECEPCION DE DATOS-----------------------------
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/PosX",GOAL_POS_X) ;LECTURA DE DATOS DE COORDENADAS
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/PosY",GOAL_POS_Y)
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/PosZ",GOAL_POS_Z)
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/AngA",GOAL_ANG_A)
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/AngB",GOAL_ANG_B)
        RET = EKI_GetReal("CoordinatesMovement","Controller/Write/AngC",GOAL_ANG_C)
        RET = EKI_GetBool("CoordinatesMovement","Controller/Write/Linear",LINEAR)
        
        IF $FLAG[15]==TRUE THEN ;VERIFICA SI SE ESPECIFICO STATUS
          RET = EKI_GetInt("CoordinatesMovement","Controller/Write/Status",GOAL_STAT)
        ENDIF
        
        IF $FLAG[16]==TRUE THEN ;VERIFICA SI SE ESPECIFICO TURN
          RET = EKI_GetInt("CoordinatesMovement","Controller/Write/Turn",GOAL_TURN)
        ENDIF
        
        IF $FLAG[18]==TRUE THEN ;VERIFICA SI SE ESPECIFICO TCP
          RET = EKI_GetFrame("CoordinatesMovement","Controller/Write/TCP",USER_TCP)
        ENDIF
        
        IF $FLAG[19]==TRUE THEN ;VERIFICA SI SE ESPECIFICO BASE
          RET = EKI_GetFrame("CoordinatesMovement","Controller/Write/Base",USER_BASE)
        ENDIF
        
        IF $FLAG[20]==TRUE THEN ;VERIFICA SI SE ESPECIFICO ACCELERACION
          RET = EKI_GetReal("CoordinatesMovement","Controller/Write/Accel",GOAL_ACCEL)
        ENDIF
        
        IF $FLAG[21]==TRUE THEN ;VERIFICA SI SE ESPECIFICO VELOCIDAD
          RET = EKI_GetReal("CoordinatesMovement","Controller/Write/Vel",GOAL_VEL)
        ENDIF
        
        
        STANDBY = FALSE ;BOOLEANO A PC PARA DESHABILITAR ENVIO DE NUEVOS DATOS
        
        RET = EKI_SetBool("CoordinatesMovement","Robot/Read/Standby",STANDBY)  ;DESHABILITO RECEPCION DE DATOS
        RET = EKI_Send("CoordinatesMovement","Robot") 
        
        ;-----------------------------MOVIMIENTO-------------------------------
        IF $FLAG[15] AND $FLAG[16] THEN
           GOAL.X = GOAL_POS_X
           GOAL.Y = GOAL_POS_Y
           GOAL.Z = GOAL_POS_Z
           GOAL.A = GOAL_ANG_A
           GOAL.B = GOAL_ANG_B
           GOAL.C = GOAL_ANG_C
           GOAL.S = GOAL_STAT
           GOAL.T = GOAL_TURN
        ELSE 
           GOAL.X = GOAL_POS_X
           GOAL.Y = GOAL_POS_Y
           GOAL.Z = GOAL_POS_Z
           GOAL.A = GOAL_ANG_A
           GOAL.B = GOAL_ANG_B
           GOAL.C = GOAL_ANG_C
        ENDIF
        
        IF $FLAG[18]==TRUE THEN
          $TOOL = USER_TCP
        ENDIF
        
        IF $FLAG[19]==TRUE THEN
          $BASE = USER_BASE
        ENDIF
         
        
        IF LINEAR==TRUE THEN
          LIN GOAL    
        ELSE
          PTP GOAL
        ENDIF
        
        ;--------------------------ENVIO DE POSICION---------------------------
        ACTUAL.X = $POS_ACT.X
        ACTUAL.Y = $POS_ACT.Y
        ACTUAL.Z = $POS_ACT.Z
        ACTUAL.A = $POS_ACT.A
        ACTUAL.B = $POS_ACT.B
        ACTUAL.C = $POS_ACT.C
    
        ;RET = EKI_SetFrame("CoordinatesMovement","Robot/Read/Pos",ACTUAL)
        RET = EKI_SetInt("CoordinatesMovement","Robot/Read/Status",$POS_ACT.S)
        RET = EKI_SetInt("CoordinatesMovement","Robot/Read/Turn",$POS_ACT.T)
        RET = EKI_Send("CoordinatesMovement","Robot")
        
        ;---------------------------CIERRE DE LOOP-----------------------------
        ENA = FALSE
        $FLAG[15] = FALSE ;STATUS
        $FLAG[16] = FALSE ;TURN
        $FLAG[17] = FALSE ;ENABLE
        $FLAG[18] = FALSE ;TCP
        $FLAG[19] = FALSE ;BASE
        $FLAG[20] = FALSE ;ACCEL
        $FLAG[21] = FALSE ;VEL
        
      ENDLOOP
      
      RET = EKI_Close("CoordinatesMovement") ;CIERRA COMUNICACION
      RET = EKI_Clear("CoordinatesMovement")
      
      PTP INICIAL ;MOVIMIENTO A POS INICIAL      
      
    END
    Display More

    DAT:

    Code
    &ACCESS RVP
    &REL 1
    &COMMENT Programa de movimiento a coordenadas por EKI
    DEFDAT DynamicProg PUBLIC
    ;FOLD EXTERNAL DECLARATIONS;%{PE}%MKUKATPBASIS,%CEXT,%VCOMMON,%P
    ;FOLD BASISTECH EXT;%{PE}%MKUKATPBASIS,%CEXT,%VEXT,%P
    EXT  BAS (BAS_COMMAND  :IN,REAL  :IN )
    DECL INT SUCCESS
    ;ENDFOLD (BASISTECH EXT)
    ;FOLD USER EXT;%{E}%MKUKATPUSER,%CEXT,%VEXT,%P
    ;Make here your modifications
    
    ;ENDFOLD (USER EXT)
    ;ENDFOLD (EXTERNAL DECLERATIONS)
    
    DECL EKI_STATUS RET
    DECL AXIS INICIAL={A1 0.0, A2 -47.0, A3 110.0, A4 0.0, A5 -60.0, A6 0.0}         ;POSICION INICIAL
    DECL AXIS TOOL_CHANGE={A1 48.0, A2 -13.4, A3 74.5, A4 0.0, A5 -60.0, A6 0.0}     ;POSICION PARA CAMBIO DE HERRAMIENTA
    DECL POS GOAL                                                                    ;ESTRUCTURAS DE POSICIONES OBJETIVO, ACTUAL Y PREVIA
    DECL REAL GOAL_POS_X, GOAL_POS_Y, GOAL_POS_Z, GOAL_ANG_A, GOAL_ANG_B, GOAL_ANG_C ;VARIABLES REALES DE POSICIONES Y ANGULOS
    DECL INT GOAL_STAT, GOAL_TURN          ;VARIABLES ENTERAS DE STATUS Y TURN
    DECL BOOL ENA, LINEAR, STANDBY         ;VARIABLES BOOLEANAS DE CONTROL DE MOVIMIENTO
    DECL FRAME USER_TCP, USER_BASE, ACTUAL ;VARIABLES FRAME DE TCP Y BASE DEFINIDAS POR EL USUARIO
    DECL REAL GOAL_ACCEL, GOAL_VEL         ;VARIABLES REALES DE ACELERACION Y VELOCIDAD DEL MOVIMIENTO
    
    ENDDAT
    Display More

    Communication confguration XML:

    Code
    <ETHERNETKRL>
        <CONFIGURATION>
            <EXTERNAL>
             <IP>172.31.1.2</IP>
                <PORT>59152</PORT>
            </EXTERNAL>
        </CONFIGURATION>
        <RECEIVE>
            <XML>
                <ELEMENT Tag="Controller/Write/PosX" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/PosY" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/PosZ" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/AngA" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/AngB" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/AngC" Type="REAL"/>
                <ELEMENT Tag="Controller/Write/Status" Type="INT" Set_Flag="15"/>
                <ELEMENT Tag="Controller/Write/Turn" Type="INT" Set_Flag="16"/>
                <ELEMENT Tag="Controller/Write/Enable" Type="BOOL" Set_Flag="17"/>
                <ELEMENT Tag="Controller/Write/Linear" Type="BOOL"/>
                <ELEMENT Tag="Controller/Write/TCP" Type="FRAME" Set_Flag="18"/>
                <ELEMENT Tag="Controller/Write/Base" Type="FRAME" Set_Flag="19"/>
                <ELEMENT Tag="Controller/Write/Accel" Type="REAL" Set_Flag="20"/>
                <ELEMENT Tag="Controller/Write/Vel" Type="REAL" Set_Flag="21"/>
            </XML>
        </RECEIVE>
        <SEND>
            <XML>
                <ELEMENT Tag="Robot/Read/Pos" Type="FRAME"/>
                <ELEMENT Tag="Robot/Read/Status" Type="INT"/>
                <ELEMENT Tag="Robot/Read/Turn" Type="INT"/>
                <ELEMENT Tag="Robot/Read/AxisA1" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/AxisA2" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/AxisA3" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/AxisA4" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/AxisA5" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/AxisA6" Type="REAL"/>
                <ELEMENT Tag="Robot/Read/Standby" Type="BOOL"/>        
            </XML>
        </SEND>
    </ETHERNETKRL>
    Display More

    I am using a KR3 R540 robot with the KRC4 compact controller running KSS V8.3.37

    Sorry for the long post and thank you!!

    :sorry:

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • September 5, 2019 at 4:58 PM
    • #2

    So, where in your code are you setting $TOOL and $BASE? That BAS (#INITMOV,0 ) sets them both to $NULLFRAME (all 0s). You need to either pre-define your Tools and Bases in $CONFIG.DAT (or just by using the pendant menus) and use $TOOL=TOOL_DATA[ x ], $BASE=BASE_DATA[ x ], or you need to use your incoming XYZABC values to fill a FRAME variable and set $TOOL and/or $BASE equal to it.

    So, you either need to add an option switch to your EKI and run the EKI data transaction 3 times (once for location, once for Tool, once for Base), then apply all of those, or you need to expand your EKI to pull in three FRAMEs' worth of XYZABC values in parallel.

  • panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • September 5, 2019 at 5:22 PM
    • #3

    lines 117 and 121 can assign user frames to tool and base but...

    user frames are set as nullframes in lines 36 and 37 and they never get modified.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Agustin Costa
    Reactions Received
    4
    Trophies
    3
    Posts
    58
    • September 5, 2019 at 6:24 PM
    • #4

    Hello SkyeFire and panic mode,

    Quote from panic mode

    user frames are set as nullframes in lines 36 and 37 and they never get modified.

    They are modified by the functions in lines 76 and 80, where it receives the FRAME data types from the Ethernet connection.

    Maybe that isn't working for some reason. This is an example of the data I'm sending as base and tool frames:

    Code
    ...
    <TCP>{X -13.0, Y -69.0, Z 38.0, A 0.0, B 0.0, C 90.0}</TCP>
    <Base>{X 0.0, Y -404.0, Z 12.0, A 0.0, B 0.0, C 0.0}</Base>
    ...

    Is there something wrong with this?

  • Agustin Costa
    Reactions Received
    4
    Trophies
    3
    Posts
    58
    • September 5, 2019 at 6:39 PM
    • #5

    I think I've figured out why it doesn't work, the robot is not receiving the base and tool frames through the Ethernet interface so the flags 18 and 19 never get set and the $TOOL and $BASE are never modified.

    I still have to understand why this fails but it helps to know that the $TOOL and $BASE assignments are correct.

  • Agustin Costa
    Reactions Received
    4
    Trophies
    3
    Posts
    58
    • September 5, 2019 at 6:53 PM
    • #6

    Ok, I've figured it out. Frames need to be sent using this syntax for XML communication:

    Code
    <TCP X='-13.0' Y='-69.0' Z='38.0' A='0.0' B='0.0' C='90.0' />

    It's working perfectly now!

    Thanks SkyeFire and panic mode

    :guru:

  • panic mode
    Reactions Received
    1,278
    Trophies
    11
    Posts
    13,079
    • September 5, 2019 at 7:04 PM
    • #7

    i forgive you :winking_face:

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Similar Threads

  • Escaping from tight space

    • Jan Hrabovský
    • May 19, 2019 at 12:56 PM
    • KUKA Robot Forum
  • Teach point in defined BASE

    • JackS
    • May 17, 2019 at 7:25 PM
    • KUKA Robot Forum
  • changing a program tool and base number

    • bigboss
    • April 3, 2019 at 10:50 AM
    • KUKA Robot Forum
  • The wrong moves of the axes x and y in the Cartesian coordinates

    • km427
    • July 18, 2018 at 8:23 PM
    • KUKA Robot Forum
  • Robot KR240 file from powermill not works

    • Alex_Moser564
    • July 13, 2017 at 11:37 AM
    • KUKA Robot Forum
  • Tool and uframe calibrations in comau?

    • knowledgesharing
    • February 3, 2016 at 9:01 AM
    • Comau Robots
  • positioning error in BASE

    • robot-cnc
    • September 22, 2016 at 7:26 PM
    • KUKA Robot Forum
  • How should i set tool z height offset ?

    • SYED
    • August 28, 2016 at 9:54 AM
    • KUKA Robot Forum

Tags

  • KRC4
  • EKI
  • KRL
  • TOOL
  • BASE
  • Status
  • Turn
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download