Shanghai Jiao Tong University Capstone Design

Introduction

Imagine in this pandemic of Covid-19, some engineers have no access to manufacturing machines. Or, imagine we students want to learn to use some machines in the factory. How can we learn this online? So our motivation is to use virtual reality and augmented reality technology to synchronously show the manufacturing process and simulate the milling process.

Before heading to the details, we first have a overview of our system. There are three main parts: user, transmission and machine. The remote users could control the machine by gesture and observe the machine with VR headset. The local user can use the mobile application to see a virtual workpiece rendered on the screen. The red arrow represents control signals input; while blue arrows are real-time feedbacks from the machine. Our system looks complicated at first sight, but it would be clear later.

Requirements and Concept Generation

In terms of needs, for VR part, users require real time synchronization, high degree of freedom, and immersive experience. For AR part, we need precisely positioning and carving. Particularly, a sample of AR effect is shown here. Users will scan the machine without materials to know how an artifact will be manufactured. It helps validate the correctness of manufacturing program without wasting materials. For both subfunctions, users need high portability, low financial cost and low learning cost.

From the needs, we formulate some engineering specifications. We set refresh frequency and latency as the real time criteria and we also add the specifications for object deviation rate, financial cost and so on. The engineering specifications will affect our concept generation and selection.

From the needs, we list out the necessary sub-functions we want to have and choose. We use weight matrices to carry out decision selection based on the engineering specifications. For the user side, we choose HTC Vive Pro as the headset for VR since it a commonly used VR headset with friendly handles and good user experience. We choose smartphones to be the AR terminal because that everyone can download an APP and access to the system. Unity 3D is chose to build the model since it can make and simulate vivid 3D model. For the transmission side, we choose socket connection to reduce the latency and raise the update frequency. Mysql is a stable and fast database that can transmit and store structured data in a short time. For the machine side, we choose Mach3 to control the CNC milling machine, the software can read the real time milling machine status in a low latency.

Design Description

VR System

Now let’s discuss about implementation details. For VR control system part, currently we have implemented environment to enable user to control CNC machine manually to start, move and stop virtually. Also, user may choose to load precompiled Gcode Program to show simulation result of a model. We use Unity Package SteamVR and VRTK to build up the VR environment. Then we setup the control panel by Csharp scripts in Unity which sends user’s commands to MySQL database while simulating CNC machine with data feedback from database.

Real-time Simulation

For real-time simulation, we create a brand new algorithm with several Csharp scripts to simulate real time cutting effect of CNC machine in Unity. Below displays actual effect of two controlling methods. In Unity, the program would first generate enough mesh vertices on surface of the piece. Then, whenever the cutter contacts with the vertices, the vertices will modify its height to display cutting effect. This algorithm ensures real-time connection between devices.

AR System

Most parts of the AR environment is a migration from VR. Besides, we utilize vuforia tools to build the AR visualization. We designed the image target to stable the model, which we’ll show later in the demo. Also, we seperate the 3D calculation and the AR visualization to make the whole program run smoothly.

Prototype

VR System

The VR system is built up by three parts: from left to right, remote client, MySQL server and Mach3 client. In the remote client, we built a unity model which is divided into four parts: the base and x, y, z axis. The scale of the coordinate and the directions of the axis are consistent with the real machine. Therefore, given the real-world coordinate, the model will visualize the machine correctly. The Mach3 client is a relay between MySQL server and Mach3. It receives commands from sql and sends to Mach3 and also receives coordinates from Mach3 and sends to sql. MySQL then is a data storage for remote communication. The desktop running Mach3 and Mach3 client is connected to the real machine to operate.

Real-time Simulation

For the real-time transmission, we have two parts. First, the Mach3 client will create connection to the MySQL database and query the data in every loop, which is more than 30Hz, so that once there’s new command (such as “Load” or “Stop”) sent to the database, the client can get it immediately. The second part is the socket transmission. Once the client queries the new command data, it will send it through the socket channel to Mach3. In the meantime, Mach3 VB script will always listen to the socket port, and if there’s any data in the socket channel buffer, it will run sockRead to get the command. With our prototype, the whole transmission process is in real-time.

AR System

For the AR, the visualization is similar to VR, but it has a different database connection method and a new tag recognition task. Due to mobile security issue, both android and ios don’t allow direct connection to online database. So we wrote a php website on the google cloud platform app engine. It directly connects to the database and opens a web api which is a query to the position data so that on the mobile platform, our program can utilize webrequest package to request the api url to get the data through html form. About the tag recognition, we designed a tag which has a lot of geometric features. The round SJTU logo can help locate the center and the color blocks on the margin have character points which help Vuforia engine determine the direction.

Results

VR Demo

In the video, the right-hand-side is the laptop running our VR model, and on the left is the real cutting process. We can click buttons or use VR device to remote control Mach3 client which is connected to the real physical machine. And the Mach3 client will send back position and moving information back to VR model for visualization. We can see the latency is very low, and it is due to the internet connection and low computing power of the old lab desktop.

AR Demo

Here is the AR APP running on the iOS platform. We can either pre-load our JI cutting model into database or run the Gcode in real-time, and the AR APP can visualize it.

Discussion and Conclusions

Quantitative experiments

After finishing the prototype, we conducted some experiments for validation. Using the network tool Wireshark, we calculated the frequency of the position feedback, which is around 20 packets per second. At the same time, on the RHS the round-trip time graph shows that the latency is around 50ms, which is lower than our expectation 200ms.

Pros and Cons

Our system enables remote and real-time simulation. Those who are thousands miles away from the machine can still have access to the control and feedback. The database storage enables the users to recap their Gcode programs. However, due to the hardware setting limit, our computer cannot afford greater amount of calculations for higher precision. If we need to simulate a sophisticated artifact, our current design may not give precise enough outcomes.

What-if

Reviewing our design, we found many aspects that we could’ve done better. The first point is computer hardware. Since our CNC Milling machine can only support Windows 7 32bit, it later became our performance bottleneck. If we could start over, we should pay more attention to the choice of hardware. Also, we expect that in the future, AR can adapt itself to the nested mobile device.

Conclusions

In summary, we are dedicated to a remote, real-time control system. Our design used socket connection and MySQL database to record position parameters. We also designed a new shader algorithm for workpiece simulation. In general, our design meets most of the requirements. The server establishment and shader algorithm are the two most important achievements. During this pandemic, we witnessed the power of remote teamwork, and the importance of time management. We are excited and grateful to be a part of this wonderful journey.

Documents

It’s in the game

Years ago, in the middle-earth…

Warrior waves the sword
Thief steals from others
Witch shoots fireballs
Bomberman drops bombs

The four elites cooperate and compete with each other to collect golds from a newly found gold mine

Want to join? Follow The Gold Rush
Presented by Godzilli

No permanence is ours; we are a wave
That flows to fit whatever form it finds:
Through night or day, cathedral or the cave
We pass forever, craving form that binds.
– Hermann Hesse, Das Glasperlenspiel

A game prototype inspired by the book Das Glasperlenspiel. In the game, players can step on the lights to control the movement of various parts to form the path to the end. The designed view change will help players solve the puzzle. Enjoy.

《塞尔达传说》地牢关卡的重制旨在贴合原版细节,保持旧式红白机控制的触感,并对每个元素进行细致比对,以确保复刻后的关卡在视觉与操作上保持一致。

虽然游戏采用2D视觉,但墙体、障碍物和水面等元素在深度上存在区分,转场时相机会移动。为简化布局和碰撞处理,整体场景使用3D坐标系构建,仅在渲染阶段切换到2D视角,Canvas与UI逻辑保持不变。

碰撞与物理的实现是最具挑战的部分。不同交互对象使用不同的碰撞层和标签,例如武器与怪物、林克与怪物的碰撞规则各不相同。角色与静态障碍均添加 Rigidbody,以防止穿模;每帧检测后会重置速度,避免碰撞对运动产生累计影响。林克在受伤后的冷却期间会暂时禁用与怪物的碰撞,以防止重复伤害,这需要通过多层Tag和Layer的组合来实现。

在怪物实现方面,猪怪的行为最为复杂。它除了继承骷髅和蝙蝠的随机移动逻辑外,还需要处理投掷回旋镖的行为。系统必须判断投掷的最大距离、在途中与墙体的交互、回旋镖对林克与怪物的不同响应,以及投掷过程中猪怪被击杀的情况,这些都依赖于精细的Collider与Trigger判定。

角色移动看似只需根据上下左右的按键给出位移,但因为地图由正方形格子拼接且为营造伪3D效果,角色的Collider实际小于半格。每次移动后必须将角色坐标对齐到预定义的纵横线,以实现格子行走的精度。远程攻击方面,剑的投掷采用多实例方式:手持一把剑,另外四把分别对应四个方向,平时保持隐藏,仅在对应方向投掷时设为可见。投掷期间角色仍可进行其他动作,但同一方向不可同时投掷多把剑,这需要在代码中管理可见性和实例状态。

在保留原版地图和怪物的基础上,额外设计了两个小房间作为实验性内容。第一个房间的灵感来源于棋盘格子和《哈利波特》中的巫师棋,玩家以黑子身份在棋盘上完成“将军”后触发机关,棋子布局参考了《密室》关卡的改动。第二个房间采用红色地砖,长时间踩踏会对角色造成伤害,房间内的红色蝙蝠必须全部击败后才能掉落通关钥匙。

0%