5 years of digital twins, started with two shipping containers
I remember asking the lead developer of the Azure Digital Twins plugin, in a webinar held by Epic, the simplest question: how do I connect a physical device to the model? The answer was along the lines of “I don’t know off the top of my head, but you can look at how Azure connects devices and publishes telemetry.”
That question sent us down a five-year road.
The story began in late 2020, when we started exploring whether it was feasible to build a proof of concept for a digital twin. The definition back then was “an identical replica of an existing asset, and its live sensor telemetry, visualised in a real-time environment”. That was not only our definition: experts and big names such as NVIDIA and Siemens defined their digital twins the same way.
Resources on building such a complex system were scarce, and there was no AI to lean on yet. But we had long experience with IoT, going back to 2013. Unreal Engine had been our main tool since 2017. And as architects and engineers, we knew BIM. So we started digging into a multidisciplinary field that nobody was doing at scale, or at least not properly.
Looking for a way to connect a real device
While we were deep in research, the Azure Digital Twin (ADT) plugin was released on the Unreal Marketplace. It used Azure to connect simulated devices to Unreal, with a sophisticated UI system and a very nice Niagara particle system that simulated temperature spreading through a space, among other features.
So the research continued. We reached out to Microsoft representatives and Azure specialists to understand how Azure works with physical devices, but they were too busy to answer a basic question from someone who would not bring them any revenue, or at least that is how it felt. We spent around $150 on Azure just to test a few simulated devices.
The wrong platforms, and the promising one
Frustration piled up. We had all the pieces of the puzzle: IoT hardware at our disposal, Unreal as our bread and butter, and a free plugin on the marketplace to learn from and build around.
Azure was the wrong choice at the time, and so were Google Cloud and AWS. That was partly down to our own lack of experience. They are infrastructure platforms, and wiring the right components and services together to get the outcome we wanted would have taken a great deal of effort for a self-funded team. We needed something off the shelf, a plug-and-play platform to host IoT telemetry and let us retrieve it in Unreal.
Our research led us to ThingsBoard, a platform dedicated to IoT and industrial IoT, with devices that are easy to set up, mostly for smart homes and building management systems. Our devices publish their readings to ThingsBoard over MQTT, and on the Unreal side we used the VaRest plugin to call ThingsBoard’s REST API. After six months of research, it worked.
Our first reading was as simple as a REST GET call, made with VaRest, that printed a string on screen. It was a single-device test and it only went in one direction, but it kept us believing we were getting there. We built around it and the ADT plugin for the next four months, developing our first digital twin application in Unreal with the help of IMA Architects, a Leicester-based firm that provided the physical assets for the devices to live in. They called them the IMA Pods.
The IMA Pods
The Pods were a two-storey structure made of two shipping containers stacked on top of each other, designed as a gym on the ground floor with a meeting room above it.
IMA Pods, Leicester, UK | 2021
We prepared a BIM model of the containers in Revit with all the related metadata. We also made a 3D LiDAR scan of the building and its surroundings and brought it into UE4. That gave us a digital replica, but that was the easy part. The twin was still to come.
Back to square one
One device was the easy part. The real challenge was making 20 devices work together: fetching their data as it was sent, in real time, with a UI that reflected it and 3D scene components you could interact with. How do you design the architecture for that?
It was a use case with no reference, no tutorial and no how-to guide. When a developer builds a UI or constructs a Blueprint in Unreal, there is a wealth of community material to learn from: almost every problem has happened to someone else, and they wrote about it somewhere. But how do you build a real-time digital twin UI? Where do you start? And how do you choose, from a wide range of options, a system structure that is efficient?
Instead of getting stuck, we moved on with the knowledge we had, broke things and fixed them later.
Designing the hardware
Our development had to grow to include hardware design. We set an MVP for a small set of sensors reading the basics: temperature, humidity, occupancy, visible and UV light, and the open or closed state of windows and doors. We added relays to control a few machines, such as a water fountain, a TV and the lights.
We installed around ten devices per floor. When we say devices, we mean a bare PCB each, manufactured in China, which would look like a hobbyist design by today’s standards. But what do you do when funds and resources are limited?
Making it run in Unreal
On the Unreal side, experience had taught us that if something has to work, it has to run at 60 fps at least, and it had to work with Pixel Streaming.
Luckily we had only a handful of devices in the building, so the telemetry to handle each second was limited. Even so, the numbers add up quickly: 20 devices reporting several values every second produces around 300 million data points a month. Throttling and bottlenecks were still to hit us further down the road, but at the time everything worked like a charm.
A twin that sends and receives
A few months of experimenting, trials and errors, and the twin was ready to send data to the Pods and receive data from them, with an animated Unreal UI that had themes and plenty of polish. Blueprints for doors and windows reflected the state of the opening sensors almost instantly. Even the light arrays and machines switched on and off as we toggled them in the real Pods.
I look at it now and see a child’s toy. But back then it felt like we had invented a time machine.
IMA digital Pods, 2021 https://ima-architects.co.uk/news/ima-digital-pods/
And what do we do now?
Now that the proof of concept was working, where would we go from here?
That became a five-year development journey. Along the way we discovered the Newcastle upon Tyne Urban Observatory dataset, and the market changed around us: first with the then-new Unreal Engine 5, then with the AI revolution that changed everything. That is a story for next time.
Tell us about your story, has anyone else tried connecting physical hardware to Unreal? What did you use? and where did you get stuck?