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

Modify KRL Variables with Python

  • VincentOro
  • January 18, 2024 at 2:42 PM
  • Thread is Unresolved
  • VincentOro
    Trophies
    1
    Posts
    4
    • January 18, 2024 at 2:42 PM
    • #1

    Hello everyone,

    I am using KukaSIM and I would like to use python to modify a defined point (in terms of X,Y,Z,A,B,C) to perform a movement for example "SPTP P1_CUSTOM" in simulation. I don't know how to access the specific value in order to modify it and I am confused on how to do it.

    Can you give me some suggestions?

  • Nation January 18, 2024 at 2:59 PM

    Approved the thread.
  • fl0rian
    Trophies
    1
    Posts
    2
    • April 18, 2024 at 11:04 AM
    • #2

    Hi,

    I am having a similar problem. I am struggling how to access a global integer variable from within a python script.

    Thanks in advance.

  • work_BR
    Reactions Received
    11
    Trophies
    1
    Posts
    95
    • April 18, 2024 at 5:23 PM
    • #3

    Is your goal to simulate something like mxAutomation or PLC I/O? I'm just curious.

    I personally have not had much luck using the inline python scripts in Kuka sim (like where you would have the KRL of the robot, but python instead).

    What i have had some success with is using:

    If $IN[1025] THEN

    ..CODE THAT YOU ONLY WANT TO EXECUTE ON THE KR C...

    ELSE

    ..THIS IS WHAT WILL RUN IN THE SIMULATION

    ENDIF

    $IN[1025] is true in the KR C but false in the simulator.

  • fl0rian
    Trophies
    1
    Posts
    2
    • April 19, 2024 at 9:49 AM
    • #4

    Thank you for your answer.

    The idea is to simulate a PLC with the python script to send a job number to the robot.

  • work_BR
    Reactions Received
    11
    Trophies
    1
    Posts
    95
    • April 19, 2024 at 3:19 PM
    • #5

    I don't know enough about what your specifically doing obviously, but the nice thing about the SIM is your worst case can just be to change a global variable to be what your job number is.

    A quick ish glance at the Python API looks like you can use the vxBooleanSignalMap to allow your python script to decide values of signals that your robot can map to a different value that your "real world" controller will read.

    I'm trying to say you can have a signal in your config file that makes it operate as you normally do. Now in your sim version, have a different signal, and this signal can be mapped to your python script?

  • desertgiant
    Reactions Received
    2
    Trophies
    1
    Posts
    51
    • April 19, 2024 at 3:54 PM
    • #6

    I have not exactly done what you need, but something similar.

    Robot writes the position for the gripper in the $OUT signals.

    This was defined as a variable in the SimPro Interface. and my python script was reading the input of the variables and was setting the required position of the gripper. And vice versa was done to read the status of the gripper from robot.

    I donot have Simpro license to exactly explain what and where it was done.

    When I was doing it I was referring to the training material from Visual components to do it.

    May be check their site and see if it helps.

  • Online
    SkyeFire
    Reactions Received
    1,052
    Trophies
    12
    Posts
    9,431
    • April 19, 2024 at 5:45 PM
    • #7

    I'm not sure it's possible to set robot inputs from inside a Python script. To be honest, I haven't tried.

    My first thought is to try wiring robot outputs to robot inputs, then control the robot outputs from the Python script. A bit hacky, but I don't see any reason it wouldn't work.

  • panic mode
    Reactions Received
    1,280
    Trophies
    11
    Posts
    13,088
    • April 19, 2024 at 8:50 PM
    • #8
    Quote from VincentOro

    I am using KukaSIM ...

    i think you really should start by providing some details...

    Which KukaSim?

    Which Version?

    How do you plan on modifying data? By processing SRC or DAT files? That can be done offline...

    If you are interested in doing do online (by communicating with live system), where is the code executed? In OL or in OPS or in Sim?

    What kind of interface you are trying to use? Some specific API or one of servers?

    Where is the python code you are trying to use?

    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

  • desertgiant
    Reactions Received
    2
    Trophies
    1
    Posts
    51
    • April 22, 2024 at 8:53 AM
    • #9
    Quote from SkyeFire

    I'm not sure it's possible to set robot inputs from inside a Python script. To be honest, I haven't tried.

    My first thought is to try wiring robot outputs to robot inputs, then control the robot outputs from the Python script. A bit hacky, but I don't see any reason it wouldn't work.

    Reading and Writing KUKA IO from Python script is possible, atleast with Office PC / Office Lite.


    But this requires additional interfaces like Y200 or VRC.


    The signals set by the robot can be read from the variables defined in simulation and vice versa can be done to send signals to KUKA.

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