Control an Industrial Robot with Your iPhone or Android

Antonius
4 min readMay 18, 2018

--

iOS Demo

Smart Devices are becoming commonplace. Our Mobile Devices, Echo Dots, Teslas, and Nests are leading the way towards an automated future. Within the segment of Industrial Automation — the industry that is building all the things we use from Shampoo Bottles to Smart Devices—we are seeing an evolution. This evolution is all about integrating the same type of ‘Smart’ Intelligence Systems used in our Commercial Products into Industrial Automation. Welcome to Industry 4.0.

The Evolution of Manufacturing and Industrial Automation

Recently, I helped build a Proof of Concept for Festo to control their Industrial Robot.

Using Open Source Technologies, I was able to show how easy it is to control it wirelessly using an iOS or Android Device.

The 3 Primary Technologies used to make this all work was React Native, NodeOPC-UA & NodeJS Mobile.

React Native is the UI layer and allows the App to be written once and deployed on both iOS and Android platforms.

NodeOPC-UA allows the App to communicate to the Robot through the OPC-UA Protocol. The Industrial Automation landscape is similar to how WhatsApp, Viber, and Slack messages can’t be sent to one another. Whereas an application using the XMPP Protocol can. OPC-UA is a Unified Protocol that allows for interoperable systems to communicate with one another. NodeOPC-UA is basically a wrapper of the OPC-UA Protocol that you can run on NodeJS.

And finally, NodeJS Mobile allows the App to run NodeOPC-UA on the Mobile Devices. Surprisingly there is no official way to run NodeJS on your iOS or Android Device. This library is quite new and a lot of development work is being done on it.

Tutorial

In the rest of this post, I’ll show you how to get this all set up.

We used the CECC-X-M1 Controller by Festo since the App is for their FMCP Product. However, you can use a Raspberry Pi running a NodeOPCUA server. Essentially you are looking to do reads and writes to specific OPCUA tags. The change in the tag value is then sent to the PLC Logic which is what physically manipulates the Robot. I won’t cover PLC here as it is another layer.

Connecting Node-OPCUA with NodeJS-Mobile

NodeJS Mobile runs in a separate thread and exists in its own folder. The file that contains all the Node code is in ‘main.js’.

The file you’re using is ‘/nodejs-assets/nodejs-project/main.js’

To initialize the connection to your Raspberry Pi OPCUA-Server, you’ll need to instantiate the OPCUAClient() and set the endpoint

Connect to the Server

Once Connected, you will have to create a Session

To browse to the folder where the Tags are callthe_session.browse(“RootFolder and to read the tags

Sending OPCUA Tag Data to React Native

Lastly, NodeJS-Mobile offers a dispatcher called rn-bridge that you can send data from Node to the React Native layer.

Receiving OPCUA Tag Data in React Native

In your React Native file, you’ll want to add a listener to retrieve the message.

Sending Data from React Native to NodeJs-Mobile

Simply call nodejs.channel.send(JSON.stringify(newRXAxisPos)); to send data to NodeJS. To receive it, the rn-bridge also has a listener

To Write, just use the following

Monitoring Items in NodeJS-Mobile using NodeOPCUA

To monitor any OPCUA Tags that may change in value

Lastly, to start NodeJS-Mobile just call

nodejs.start(“main.js”);

Some pitfalls that had to be overcome were

Issue building with Android

There’s an issue building with Android because NodeOPCUA generates files and folders with an underline. In order to overcome the ‘Node assets copy failed’ error, you’ll have to Override the Android Asset Packaging Tool Ignore Pattern for both the React Native Application and the NodeOPCUA Plugin (credit: jaimecbernardo).

Summary

Ultimately we are building a Mobile Client that reads OPCUA Tags from the OPCUA Server. However, we are using NodeOPCUA which acts as both a server and a client to read the data from the Server. A better approach in the future is to not have to start up a Node server on the React Native end and just connect to it directly the same way you can connect to HTTP on React Native. The beauty of this Proof of Concept though, is that it has achieved the goal of Write Once Deploy Everywhere (everywhere being Android and iOS).

OPCUA is Plug and Play so it is not tied to a Single Machine

Many thanks to

Alejandro Lopez — Senior Controls Engineer at Festo

Etienne Rossingnon — Author of NodeOPCUA and Founder of Sterfive

Jaime Bernardo — Software Engineer at Janea Systems

Also, I used the Prosys OPC UA Client to read and debug the Tags during development

--

--

Antonius

Past Life: Know it all. Present Life: Student. Future Life: Teacher