I would like to read defined global variables from the robot program in my case I am using Kuka Sim (KRL) I want to implement a python script and pass these global variables value to it, not sure how to do it and how to call the py script passing these var from KRL. Thank you.
As of right now there is no direct way to access KRL variables with Python and vice versa. The only option right now is to convert the variable to IO signals via KRL and decode those signals in your Python code by reading the IO values.
More or less like every other signal that is handled in the Python script of a component. You will need to connect the input behavior with the Python script (see properties of the Boolean input behavior)
Then you can utilize the OnSignal event which will trigger for every signal that is connected with the script. Therefore you will need to check in the OnSignal method which signal was triggered, e.g. by checking the name of the signal.
from vcScript import *
comp = getComponent()
def OnSignal( signal ):
if signal.Name == ‘Visibility_OnOff’:
comp.Visible = signal.Value
Thanks so much @mastu. I understood what you meant, however (maybe I did not explain myself clearly ) I wanted to see if it was possible to read the status of a robot output but the output is not connected (maybe it is not possible) for example:
$OUT[1] = TRUE
I want to have a py script that reads the status of that output. At the moment I have a workaround where I set the outputs to a new component and the component map it back to robot inputs so I can read the inputs with:
All this because I need to use the py script inside the robot prg at a certain time in the code. I am new to kuka sim so it has not been easy with the custom scripts
In fact, the answer to this question is also written in the vcBooleanSignalMap help file, in fact, I have always felt that the name taken here is a bit confusing, in fact, for the output Boolean SignalMap, he is essentially a BooleanSignalMap, so in fact, he can also use input, in other words, in the In other words, in vcBooleanSignalMap, input is to read the signal value, and output is to assign the value to the signal, instead of being limited to input signals can only use input, output signals can only use output.
I hope you understand what I mean, sorry if it makes you feel strange (after all English is not my native language).
As far as I know it is not possible to access anything from the KUKA robot program directly from Python level.
But if you want to start certain Python code in the robot program, that’s possible. Just create a Python script behavior in the robot model and add the code that should be executed there.
Thank you for the application example! Very nice work indeed!
I am struggling with the “autoconnect” feature of the 16 bit signals, is there a way that you could explain how to get it to work?
thanks in advance
Just select the 16bit_Real_Signal_Sensor and activate the “Interfaces” view. You then should be able to see the “RobotInterface” on the sensor side as well as the “Connect Special Accessories” inteface on the robot side. If you connect this interface, the automatic connection of the 16 pre-defined signals should be triggered.
I have a question on the counter program. I can see the output of the counter in the Output Panel in kuka.sim.
Is there a way to access the counter_send_val as a Property in the modelling tab (i.e. Property → Basic Integer) for the component. Ideally I want to expose the Property value via the OPC-UA at the end.
Hi @svk, what you want to achieve is what @mastu had suggested already
have a look at the response
With that example you can interact between KRL and python scripts, it is like a workaround at the moment. Basically you can write outputs and read inputs from robot, you will have to map those to suit your application.