Sending OPC UA Data with GraphQL to Unity…

In a simple setup I have tested to send 2000 value changes per second from an OPC UA server to Unity with GraphQL, the Open-Source Frankenstein Automation Gateway, and the GraphQL for Unity Asset. And it could go up to 10000 value changes per second…

I had one DotNet OPC UA server with a lot of simulated tags with random data. The .Net OPC UA server is the DotNet reference implementation from the OPCFoundation, which can be found here.

On top of that the Open-Source Frankenstein Automation Gateway for GraphQL was running. It is connected to the OPC UA server. It offers a GraphQL interface to the tags of one or more connected OPC UA servers.

In Unity I had used the GraphQL for OPC UA Asset to easily connect to the Gateway, browse the tags, and subscribe to the value changes of 100 tags.

Each tag was changed by the OPC UA server every 45ms. This ends up in a bit more than 2000 value changes per seconds, which were sent from the OPC UA server to the Unity Application.

Here we see the Application running 3 times on my Laptop with an Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz. In the center you see the amount of incoming value changes per second (red number). Around that number, we see some of the values coming in from OPC UA. At the bottom we see the CPU load of the Frankenstein Automation Gateway (java program) and the OPC UA DotNet Server. Both were running on an old Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz.

It was also possible to increase to load up to 10000 value changes per seconds! Sending 100 values every 10ms from OPC UA to Unity…

Posted in Frankenstein, GraphQL for Unity, Unity | Comments Off on Sending OPC UA Data with GraphQL to Unity…

Unity3D in WinCC Unified

There is a free Unity asset to simplify the creation of an WinCC Unified Custom Web Control out of an Unity3d application. So, with that you can easily build WinCCUnified screens with real time 3d content built with Unity.

Short Demo: https://lnkd.in/dkckxXFm
Unity Asset: https://u3d.as/2QTN

Posted in Unity, WinCC Unified | Comments Off on Unity3D in WinCC Unified

GraphQL for Unity and how to set headers in code…

If you use the GraqhQL for Unity asset and if you want to set the headers on HTTP or Websockets in the code, then you must use the the GraphQLHttp or GraphQLWebsockets class. At the base class “GraphQL” there is no “Headers” property!

public GraphQLHttp MyGraphQL;

void Start()
{        
    if (MyGraphQL != null)
    {
        MyGraphQL.Headers = new List<Header>()
        {
            new Header() { Key = "token", Value = "secret"}
        };
        ...

Then you can also execute a GraphQL query in the code.

MyGraphQL.ExecuteQuery("query { test }", null, (message) =>
{
    if (message.Type == MessageType.GQL_DATA)
    {
        Debug.Log("Data: " + message.Result.ToString());
    }
    else
    {
        Debug.Log("Error: " + message.Type);
    }
});
      
   
Posted in GraphQL for Unity | Tagged , | Comments Off on GraphQL for Unity and how to set headers in code…

GraphQL on Unity and Result Event for Data and Errors…

The GraphQL for Unity Asset can be used to execute GraphQL queries in Unity. The result is set on properties of Unity objects and there is also a Unity Event on the GraphQL Query Object where user-defined function of a GameObject can be triggered every time when a queries returns data or an error.

public class Sample1 : MonoBehaviour
{
    public void ResultEvent(GraphQLResult result)
    {
        if (result.Errors.Count==0)
        {
            Debug.Log("Data: " + result.Data.ToString());
        }
        else
        {
            Debug.Log("Error: " + result.Errors.ToString());
        }
    }
}

Create a GameObject with this class as component and then you can drag and drop this GameObject to the Query GameObject and select the “ResultEvent” method. Every time when the query is executed then this function will be called with the result data (or error data).

Posted in GraphQL for Unity | Tagged , | Comments Off on GraphQL on Unity and Result Event for Data and Errors…

GraphQL on Unity & Newtonsoft 12.0.0.0 Reference Error

The GraphQL for Unity Asset uses the Newtonsoft version which is built in newer version of Unity (2020+). If you get an error like this:

Assembly 'Library/ScriptAssemblies/Assembly-CSharp.dll' will not be loaded due to errors: Reference has errors 'GraphQL'.
 
Assembly 'Assets/GraphQL/Libs/GraphQL.dll' will not be loaded due to errors: 

GraphQL references strong named Newtonsoft.Json Assembly references: 12.0.0.0 Found in project: 12.0.1.0.

Assembly Version Validation can be disabled in Player Settings "Assembly Version Validation"
  • Then you can try to remove NewtonSoft dependency from your project – if you have a dependency. And just use the NewtonSoft version which is already built in and shipped with Unity 2020+. If you use an older version of Unity then you can try to copy the NewtonSoft DLL from 2020 and use this in your older Unity version.
  • Or you can go to Project Settings -> Player -> Other Settings and deactivate “Assembly Version Validation”
  • Install the newtonsoft package from Unity. Go into the package manager and click “+” and then select “Add package from git URL” and fill in “com.unity.nuget.newtonsoft-json”.
Posted in GraphQL for Unity | Tagged , , , | Comments Off on GraphQL on Unity & Newtonsoft 12.0.0.0 Reference Error

Dockerfile for Python 3.9 with OpenCV, MediaPipe, TensorFlow Lite and Coral Edge TPU

Dockerfile

FROM python:3.9-slim
RUN apt-get update && apt -y install curl gnupg libgl1-mesa-glx libglib2.0-0 && rm -rf /var/lib/apt/lists/*
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list 
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && apt-get update && apt-get install -y python3-tflite-runtime && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY * /app/

Requirements.txt

opencv-python
mediapipe

Posted in Allgemein, Docker, Machine Learning | Tagged , , , | Comments Off on Dockerfile for Python 3.9 with OpenCV, MediaPipe, TensorFlow Lite and Coral Edge TPU

GraphQL for Unity and execute a GraphQL Query in Unity with C# Code

With GraphQL for Unity you can execute GraphQL Queries in a Unity way with GameObjects. But with the asset you can also execute queries in Unity with C# code.

Here is a simple example:

public GraphQL Connection;

public void ScriptQuery()
    {
        var query = "query($Token: String!) { doit($Token) { result } } ";
        var args = new JObject
        {
            { "Token", "123" }
        };
        Connection.ExecuteQuery(query, args, (result) =>
        {
            Debug.Log(result.Result.ToString());
        });
    }

Link the Connection variable to your GraphQL GameObject where the connection is set.

Note: the result callback function is called asynchronous and it is not executed in the Game-loop.

A bit more complex example how the args variable could look like. This is just an example how you can create a JSON object in C# in a convenient way.

JObject args = new JObject
        {
            ["UpdateList"] = new JArray
            {
                new JObject
                {
                    ["id"] = 28,
                    ["updateAction"] = "EDIT",
                    ["status"] = "Present"
                },
                new JObject
                {
                    ["id"] = 29,
                    ["updateAction"] = "EDIT",
                    ["status"] = "Absent"
                },
                new JObject
                {
                    ["id"] = 30,
                    ["updateAction"] = "EDIT",
                    ["status"] = "Present"
                }
            }
        };
Posted in GraphQL for Unity | Comments Off on GraphQL for Unity and execute a GraphQL Query in Unity with C# Code

Industrial Data in the Graph Database Neo4j…

The Frankenstein Automation Gateway now also supports to write OPC UA values to the graph database Neo4j.

At startup it can also write the OPC UA node structure into the graph database, so that the basic model of the OPC UA server is mirrored to the graph database. For that you have to add the “Schemas” section in the config file (see an example configuration file below). There you can choose which RootNodes (and all sub nodes) of your OPC UA systems should be mirrored to the graph database.

Once you have the (simplified) OPC UA information model in the graph database, you can add on top of that your own knowledge graph data and create relations to OPC UA nodes of your machines to enrich the semantic data of the OPC UA model.

With that model you can leverage the power of your Knowledge Graphs in combination with live data from your machines and use Cypher queries to get the knowledge out of the graph.

Here we see an example of the OPC UA server from the SCADA System WinCC Open Architecture. The first level of nodes below the “Objects” node represent Datapoint-Types (e.g. PUMP1) followed by the Datapoint-Instances (e.g.: PumpNr) and below that we see the datapoint elements (e.g. value => speed). An datapoint element is an OPC UA variable where we also see the current value from the SCADA system.

Example Gateway configuration file:

Database:
  Logger:
    - Id: neo4j
      Enabled: true
      Type: Neo4j
      Url: bolt://nuc1.rocworks.local:7687
      Username: "neo4j"
      Password: "manager"
      Schemas:
        - System: opc1  # Replicate node structure to the graph database
          RootNodes:
            - "ns=2;s=Demo"  # This node and everything below this node
        - System: winccoa1  # Replicate the nodes starting from "i=85" (Objects) node
      WriteParameters:
        BlockSize: 1000
      Logging:
        - Topic: opc/opc1/path/Objects/Demo/SimulationMass/SimulationMass_Float/+
        - Topic: opc/opc1/path/Objects/Demo/SimulationMass/SimulationMass_Double/+
        - Topic: opc/opc1/path/Objects/Demo/SimulationMass/SimulationMass_Int16/+
        - Topic: opc/winccoa1/path/Objects/PUMP1/#
        - Topic: opc/winccoa1/path/Objects/ExampleDP_Int/#


Posted in Allgemein, Frankenstein | Tagged , | Comments Off on Industrial Data in the Graph Database Neo4j…

Docker CPU Limits…

If your docker container do not use all your cpu’s, it may be the case that limits are set in /etc/systemd/system/docker.slice. To apply changed settings I had to reboot my machine (just a restart of docker didn’t change the behaviour).

cat /etc/systemd/system/docker.slice 

[Unit]
Description=Docker Systemd Slice
Before=slices.target

[Slice]
CPUQuota=200%
MemoryAccounting=true
CPUAccounting=true
MemoryLimit=1280M
#StartupCPUWeight=
Posted in Allgemein | Comments Off on Docker CPU Limits…

Niryo with Unity3D and the Automation Gateway…

The Digital Twin is Alive 🙂 #Unity3D, the #Niryo Robot, and the Automation Gateway #Frankenstein with #GraphQL for #PLC4X …

#ModBus data from the Robot can now be used in #Unity for visualisation and also to control the Robot from Unity …

The Unity Package GraphQL for OPCUA is now not only for OPCUA anymore, it can also handle other types which are supported by the Automation Gateway – like the Plc option, which is based on PLC4X.

Posted in Allgemein | Comments Off on Niryo with Unity3D and the Automation Gateway…