Enhancing Unity Applications: Smoothing Real-World Vehicle Position Data with Low-Pass Filters

Game engines such as Unity are increasingly being adopted for industrial applications. Unity provides a developer friendly platform to create powerful 3D interfaces for various domains such as construction or mining. In many industrial use cases precise monitoring and visualization of the real world situation is crucial for operational efficiency and safety. 

However, real-world vehicle position data often contains interference and noise, leading to erratic movements in graphical user interfaces (GUIs). In such scenarios, the application of Low-Pass Filters within the Unity game engine emerges as a reliable solution to dampen noise and ensure smooth representation of vehicle positions despite real-life interferences.

Understanding Low-Pass Filters in Unity

Low-Pass Filters serve as virtual sieves, allowing low-frequency vehicle position updates to pass through while attenuating high-frequency noise caused by environmental factors or sensor inaccuracies. By incorporating a simple filtering algorithm, developers can effectively smooth out fluctuations in vehicle positions, providing clearer and more reliable data visualization within Unity-based applications.

Implementation in Unity

The application of a Low-Pass Filter to smooth position data in Unity can be represented by the following formula:

newFilteredPosition = smoothingFactor * newPosition + (1 - smoothingFactor) * previouslyFilteredPosition

In this formula:

  • newFilteredPosition represents the current smoothed position update of the vehicle.

  • newPosition denotes the latest raw position update obtained from sensors or external sources.

  • previouslyFilteredPosition stores the previous newFilteredPosition. Note that when the filter is called for the first time this value is still empty, and newPosition value should be used in this case instead (I.e. the first received position value is not filtered at all).

  • smoothingFactor signifies the filter coefficient, determining the cutoff frequency of the low-pass filter. Adjusting smoothingFactor allows developers to strike a balance between responsiveness and noise reduction in the GUI representation of vehicle positions.

    • If smoothingFactor is close to 1, the filter essentially turns off, letting the new value pass through unfiltered. This results in minimal smoothing and maximum responsiveness to changes in position data.

    • As smoothingFactor approaches 0, the filter's damping effect becomes stronger, resulting in more significant smoothing of position updates. For example, a value like 0.1 can be considered strong filtering, while a value of 0 effectively freezes the current position, as the new value is multiplied by 0, and the filtered position remains unchanged.

Adjusting the smoothingFactor parameter allows developers to fine-tune the filtering effect, balancing responsiveness and noise reduction according to the specific requirements of the application.

Watch the video below to see this in action. The transparent satellite shows the actual position, and you can see how the smoothed position starts to lag behind with strong filtering. This is because the current filter update frequency (31-32 calls per second) can’t match the satellite’s speed anymore.

Conclusion

When developing interfaces that represent real-world situations, it is important to understand the context, the data, and the tools needed to visualize this data realistically.

By leveraging Low-Pass Filters within the Unity game engine, developers can effectively mitigate noise and interference in real-world vehicle position data, facilitating clearer and more reliable visualization in GUIs for industrial applications. Whether monitoring heavy machinery on a construction site or tracking vehicles in a mining operation, the seamless representation of vehicle positions enhances situational awareness, decision-making, and operational efficiency in diverse real-world scenarios.

Previous
Previous

Pros and Cons of Unreal Blueprints

Next
Next

Vogels on the Rise of AI and Developer Productivity