Skip to content

Implement Surface-Based Aerodynamic Physics Engine for EmberOS HIL #22

Description

@yufurkan

Overview

We have successfully established the telemetry bridge, mapping STM32 AETR data to the 3D model's control surfaces. However, Unity's native physics engine (PhysX) is entirely ignorant of aerodynamics; it only understands mass, gravity, and collision. Right now, our Piper PA-18 is just a 3.6kg brick that falls straight down to the runway.

To properly test the EmberOS flight controller, we cannot rely on arcade-style physics like applying artificial torques to the center of mass. We need a highly realistic, surface-based aerodynamic simulation that forces the PID loops to work exactly as they would in reality.

Core Requirement

The core requirement is that our simulation must handle extreme aerodynamic edge cases naturally through pure vector mathematics.

  • Example Case: If the aircraft banks 90 degrees into a knife-edge, the vertical lift drops to zero and the lift vector shifts horizontally to act as a centripetal force. The plane will lose altitude unless compensated by top rudder and thrust.
  • The Goal: The simulation must replicate this without any hardcoded "if-else" behaviors, relying entirely on the physics of the surfaces.

Technical Architecture

To achieve this, we will build a modular surface-based physics system. We will define four primary aerodynamic surfaces attached to the main Rigidbody: Left Wing, Right Wing, Elevator, and Rudder. Each surface will independently calculate its local velocity, angle of attack (AoA), and resulting forces in real-time.

The aerodynamic forces for each surface will be calculated using the standard equations:

$$L = \frac{1}{2} \rho v^2 S C_L$$ $$D = \frac{1}{2} \rho v^2 S C_D$$

  • Constants: Air density ($\rho$) and surface area ($S$).
  • Dynamics: The local velocity squared ($v^2$) is derived from the Rigidbody's velocity at that specific point in 3D space.
  • Coefficients: The critical components are the lift coefficient ($C_L$) and drag coefficient ($C_D$), which will be dynamically evaluated based on the real-time Angle of Attack to simulate physical phenomena such as stall.

These forces will then be applied to the aircraft using Rigidbody.AddForceAtPosition.

Environmental Scalability

By calculating aerodynamics at the extremities of the aircraft rather than just the center of mass, we are laying the groundwork for a highly advanced environmental system.

Because the left wing and right wing sample the air independently, this architecture will allow us to easily inject spatial and temporal wind variations. We will be able to simulate localized air pockets, thermals, and dynamic weather events. A localized gust of wind hitting only the right wing will naturally induce an aerodynamic roll, forcing the EmberOS PID controllers to detect the disturbance via the IMU and fight back.

Tasks

  • Initialize Rigidbody mass and configure the center of gravity.
  • Create the AeroSurface.cs script and attach it to the four primary control points.
  • Implement the vector math to calculate local Angle of Attack and dynamic pressure.
  • Integrate the motor thrust model to provide forward propulsion.
  • Tune the $C_L$ and $C_D$ curves until the aircraft can sustain level flight under EmberOS command.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions