0
Answered

Driver_Simple script does not accept OPC UA variable nodes

Ernesto 2 years ago in OPCUA4Unity updated 2 years ago 17

Dear developers,

I was trying to connect a custom Game4Automation Scene to a PLC through OPCUA Interface.


I followed the instructions from this tutorial:

Youtube video


The OPCUAInterface is updating the nodes correctly:


Image 582

However, when I tried to link a bool variable node from the OPCUAInterface to the Driver_Simple interface dragging it and droping it into the forward variable, it wasn't accepted (the forbiden symbol appeared).

Image 583

If I use the PLC signal component I'm able to link the component without problems.

I'm using Unity 2021.3.2f1 Editor and the game4automation-Professional-2019.13 package (OPCUAInterface is not working in the latest version of G4A, see https://forum.game4automation.com/en/communities/1/topics/376-opcua-interface-error-in-activating-session).

Any idea of what am I doing wrong?

Thank you in advance!

Answer

Answer

Hi Ernesto,


I am able to connect and to import the signals (even if I am not able to connect to the PLC because I don't have same setup).


Don't know where the problem is. Just for beeing sure I will send you again the latest code of the interface via mail. Please also check in Kepserver if you enabled anonymous login.


Under review

Something is wrong - if you are using Game4automation Professional the  OPCUA node sould also automatically be added together with e.g. the PLCOutputFloat Script. Please check if in your installation this compile swith is set

GAME4AUTOMATION_PROFESSIONAL
(see also https://game4automation.com/documentation/current/compilerdefines.html)

Create Signals should be turned on on the OPCUA interface -this will create also the PLCOutputs while importing the signals:

Or you just add manually the OPCUA_Node together with a PLCOutputFloat for example.

Thank you for the help. However, looks like I'm missing something else.

In the player settings, the compiler is defined as GAME4AUTOMATION_PROFESSIONAL:


Whe I import the nodes through the OPCUAInterface component, the PLC scripts you refered are not set automatically. If I add them manually, I can link the nodes in the Driver_Simple component but, when I start the simulation, looks like there is not communication between the PLCOutput script and the OPCUA node:


In addition, the script is desabled as you can see in the image before.

Any idea of what am I doing wrong.

Thank you in advance!

By the way, just in case it helps, the OPCUAInterface component does not have the option "Create signals":

Answered

Sorry I missed it.There also needs to be GAME4AUTOMATION in the compiler defines.

Apply standard settings should do the job. 


Normally this is called upon first installation. What kind of products do you have got. Did you had any compiler errors when first installing Game4Automation Asset.


If there are compiler errors directly after installagion e.g. by some naming collissions with other things, that are also in the project, it might happen that the standard settings are not set as wished.

I've got Game4Automation Digital Twin Professional 2020 and Game4Automation Simulation.

The problem is that the 2020 version of OPCUA is not working (see https://forum.game4automation.com/en/communities/1/topics/376-opcua-interface-error-in-activating-session) and I'm using the 2019 version of Game4Automation Professional.


I don't remember to get errors the first time I installed the packages (I removed the json because it was already installed by another package).


I'm going to add the GAME4AUTOMATION in the compiler definitions. and see what happens.


Thank you!

After adding the GAME4AUTOMATION definition, the Create Signals tag has listed as shows the following image. However, when I try to import the nodes, the following error appears:

"OpcException: The operation could not complete because the client is not connected to the server.
Opc.UaFx.Client.OpcClient.DenyIfNotConnected () (at <57347b42bf0a478bfdd00d22c94151bd>:0)
Opc.UaFx.Client.OpcClient+x.MoveNext () (at <57347b42bf0a478bfdd00d22c94151bd>:0)
System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Boolean& found) (at <1e18c5a6594041c9844bfd0b6618ee4a>:0)
System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <1e18c5a6594041c9844bfd0b6618ee4a>:0)
Opc.UaFx.Client.OpcClient.BrowseNode (Opc.UaFx.OpcBrowseNode command) (at <57347b42bf0a478bfdd00d22c94151bd>:0)
Opc.UaFx.Client.OpcClient.BrowseNode (Opc.UaFx.OpcNodeId nodeId) (at <57347b42bf0a478bfdd00d22c94151bd>:0)
game4automation.OPCUAConnection.GetAllSubNodes (System.String nodeid) (at :0)
game4automation.OPCUA_Interface.GetAllSubnodes (System.String nodeid) (at Assets/game4automation/private/Interfaces/OPCUA4Unity/OPCUA_Interface.cs:226)
game4automation.OPCUA_Interface.ImportNodes () (at Assets/game4automation/private/Interfaces/OPCUA4Unity/OPCUA_Interface.cs:252)
game4automation.OPCUAInterfaceEditor.OnInspectorGUI () (at Assets/game4automation/private/Interfaces/OPCUA4Unity/private/Editor/OPCUAInterfaceEditor.cs:20)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.b__0 () (at <5cf6bb2c14f1476f9cd6b153e70ca8b2>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)"

I can communicate with the OPC server with the client OPCWatch:

Any idea of what I'm doing wrong?

Thank you in advance!

There seems to be a connection problem to your opcua server. Please start first with only one node (delete all the others) of a standard data type (float, bool, int). I have seen sometimes problems when unknown datatypes habe been used.

Thank you for the reply.

I tried what you said but the same connection issue appears :(.


Anything more I could try?


Thank you in advance!

Are you somehow able to share your model and the opcua server. It is hard to say what is going wrong without having the same setup?

Sure. Let me simplify the unity project and I'll share it together with the server file.

Thank you for the help!

Using the following link https://github.com/ErnestoSolanes/Project4Testing.git you can clone the unity project and hereServer is the server config that you can open with Kepserverex https://www.kepserverexopc.com/. The server is configured to communicate via TCP/IP to a Siemens PLC.

Thank you for the help in advanced!

Any update? I cannot connect to kepserverex yet. Could you please indicate me a tested OPCUA server compatible with Siemens PLC? Perhaps Siemens OPCUA server?

Thank you in advance!

As in the last thread, I'm still stacked connecting with the OPC server...

Following your instructions, I did replace the OPCUA_Interface.cs file but, unfortunately, I'm not getting a connection.

In the following image you can see the error I'm getting.

Am I missing something?

Thank you again for the help.

Kind regards,

Hi Ernesto,

I would need to test again with your config. Will check with Kepserver and your Server Config and will let you know tomorrow morning. 

Best regards

Thank you very much!


I'll look forward to your update.

Answer

Hi Ernesto,


I am able to connect and to import the signals (even if I am not able to connect to the PLC because I don't have same setup).


Don't know where the problem is. Just for beeing sure I will send you again the latest code of the interface via mail. Please also check in Kepserver if you enabled anonymous login.



I replaced the last OPCUA_Interface.cs script you sent me via email and now seems to work fine!!!

Again, thank you for your support!