Put Values of OPC UA Server through expression first


is it possible to first use the values coming from the server in an expression or some formula before setting the value of the connected variable?

Not directly, but of course you can create expression properties to components. So you would have 2 properties, one “raw value” which is written to by Connectivity, and another which is an expression based on that “raw” value property.

1 Like

I can reference that expression property in another property right? (Can’t try it out right now)
I need to move a robot using the joint values I get but they are in “steps” so I need to map it to the right value.

If I understand it correctly I would need to create two other properties per joint property and then reference the expression property in the joint property for example
joint: joint_exp
joint_exp: joint_raw/10
joint_raw: from server

Can I do something similar with signals? The Values I get are true until triggered so I thought I would either change them too or change the standard value of the signal in the OnStart event

I will also need to send values back, basically the reverse: the joint values of the robot would be send to the robot but they also would need to go through an expression (the other reversed basically)

How should I do this? Change the expression property through python depending on a signal?

I also thought about creating a local server and client combination. It would basically get the values of the other sever and change the values and then send them to the simulation.

Which one would be better?

No, there isn’t any kind of expression system for signals.

In my opinion it would be easiest to just use a Python script behavior if you need to do anything more complex than single directional conversion for few values. It will also allow you to read and write the joint values directly through API instead of having extra properties in joint expressions etc.

Implementing a separate server in between will cause additional communication delay, you need to develop and execute it separately etc. which is much more of a hassle than having the logic within the simulation model as Python script or expressions.

1 Like

Thanks for the help.

I read somewhere that using python is slower that’s why I thought using inbuilt functions would be better.

So creating a property for the raw data and then using its OnChanged-Event to convert the Value and assign it to the right property right? Then depending on a signal stop writing and instead send the values back.

For that I would need another property connected to the server or is there a method to connect and disconnect with server variables using python?

Using a Python script can be slower than expressions, but it should only be noticeable if you need to do thousands of values per second.

It is a best practice to always have separate variables (properties / signals) for each direction of data flow i.e. inputs and outputs. So you would have 2 signals or properties for each joint and the Python script can either assign or read the actual joint value (through DOF or robot controller behavior API) based on these.

One simple example of such conversion you can find from the Universal Robots robots in the eCat. They have a JointsFromRTDE (or something) signal and a script that parses a string, assigns all joint values at once.

If you only need one direction at a time you could use e.g. a boolean component property for controlling that.

There is no Python API for the Connectivity feature. A .NET API does exist, but you won’t really need such for simple things like this.

1 Like