This project creates a digital twin of a human fall detection system. It mirrors the orientation and motion of a physical object, measured by an MPU6050 sensor connected to an Arduino or ESP32, into a Unity environment. The system is designed to track and replicate physical movements in real-time, providing a virtual visualization of orientation.
-
Physical Object
The physical object is equipped with an MPU6050 sensor connected to an Arduino or ESP32. It continuously publishes orientation values to the serial port using thegetOrientation.ino
script. -
Bridge Script
Thebridge.py
script acts as a mediator. It reads the orientation values from the serial port and sends them to Unity via a socket connection.
(Unity on macOS does not natively support serial port communication.) -
Unity Digital Twin
The Unity environment includes a virtual object (e.g., the "Banana Man" model) whose orientation matches the physical object. This behavior is implemented using theOrientation.cs
file.
- Hardware: Arduino or ESP32 with an MPU6050 sensor.
- Software:
- Arduino IDE
- Python 3
- Unity (macOS or other platforms)
- Connect the MPU6050 sensor to the Arduino or ESP32.
- Upload the
getOrientation.ino
sketch to the microcontroller using the Arduino IDE. - Ensure the serial connection is properly configured (default: 9600 baud).
- Install Python dependencies:
pip install pyserial
- Run
bridge.py
to start relaying orientation data:python bridge.py
- Download the Banana Man model from the Unity Asset Store or any 3D model source.
- In Unity:
- Go to Assets > Import Package > Custom Package.
- Select and import the Banana Man model package into your Unity project.
- Copy the
Orientation.cs
file into your Unity project's Assets folder. - In the Unity Editor:
- Drag and drop the Banana Man model into the Scene view.
- Select the Banana Man object in the Hierarchy panel.
- In the Inspector panel, click Add Component.
- Search for
Orientation
and add it to the Banana Man object.
- Ensure the script is properly linked to receive orientation data from the
bridge.py
socket.
-
getOrientation.ino
Arduino/ESP32 script that calculates and outputs the object's orientation to the serial port. -
bridge.py
Python script to bridge serial data to Unity via a socket connection. -
Orientation.cs
Unity script to update the virtual object's orientation in real-time.
- Start the physical object to stream orientation data.
- Run the
bridge.py
script to forward data to Unity. - Open Unity and play the scene to observe the virtual Banana Man mirroring the physical object's motion.