Note: This project contains an initial, basic version of a hardware-in-the-loop visualizer. Development on this Unity implementation is currently deprecated. The focus has shifted to an Unreal Engine 5 plugin version to act as a bidirectional bridge connecting the simulation state to an ESP32 flight computer.
This visualizer acts as a real-time rendering client for embedded physics simulations. It receives continuous state data over the network and translates it into smooth 3D motion.
The UDPReceiver script handles the network layer by spinning up a dedicated background thread to listen for incoming UDP packets. As packets arrive from the flight computer or simulation server, they are placed into a thread-safe concurrent queue so the main Unity thread can process them without blocking.
In the VisualizationManager, raw byte arrays are dequeued and cast into C# structs defined in PacketDefinition.cs. The system routes the data based on the payload type, unpacking physics state data (position, velocity, acceleration, quaternions, and gyro rates) or actuator commands.
External physics engines and aerospace frameworks typically use a Right-Handed Z-Up coordinate system. Unity uses a Left-Handed Y-Up system. The visualizer automatically maps the incoming coordinates by swapping the Y and Z positional axes and flipping the W component of the quaternion to ensure the orientation is represented accurately on screen.
Directly applying network data to a Transform often causes visual stuttering due to network jitter. To solve this, the visualizer uses a timestamped state buffer. It calculates the exact blend percentage between the closest past and future packets in the buffer, using Vector3.Lerp for position and Quaternion.Slerp for rotation to guarantee smooth interpolation.