Integrate PX4 and Unity

Hello PX4 community,

I want to integrate PX4 with Unity. Currently, my integration setup looks like this:
Unity → WebSocket → Simulator (Golang) → ROS2 → PX4

From Unity, I send drone position data in 3D space, along with its linear and angular velocities, to a simulator (written in Go) via WebSocket. The simulator then publishes sensor data (Accel, Gyro, Mag, GPS) to ROS2, which subsequently forwards the data to PX4. In return, I receive motor rotation speed data from PX4 and send it back to Unity. Using Unity’s physics engine and lift force calculations, Unity simulates the flight.

At this point, I have all parts of the integration working, but unfortunately, I haven’t been able to achieve a stable takeoff. I’ve been stuck on this issue for a week now, trying many different things but without success. The problem is that during takeoff, the drone starts tilting over the X or Y axis and eventually flips over. Below, I’ll attach a link to a video demonstrating the issue.

Things I have already checked:

  1. Motor positions
  2. Motor rotation directions
  3. Drone type
  4. Distances to motors
  5. Center of gravity
  6. All necessary calibrations

A quick note: All basic calibrations (accelerometer, compass, gyroscope) pass successfully, and preflight checks are also green. Additionally, if I programmatically set the same motor speeds in Unity, my drone takes off vertically, indicating that the center of gravity is correct.

I would appreciate any ideas or suggestions on what might be causing this issue. Thank you in advance!

Video link

INFO  [commander] Takeoff detected	
WARN  [health_and_arming_checks] Preflight Fail: Attitude failure (pitch)
WARN  [failsafe] Failsafe activated	
WARN  [failsafe] Failsafe activated	
WARN  [failsafe] Failsafe activated	
WARN  [health_and_arming_checks] Preflight Fail: Attitude failure (roll)
WARN  [mc_pos_control] invalid setpoints
WARN  [mc_pos_control] Failsafe: blind land
WARN  [health_and_arming_checks] Preflight Fail: Attitude failure (roll)
WARN  [failsafe] Failsafe activated	
WARN  [health_and_arming_checks] Preflight Fail: Attitude failure (roll)
INFO  [navigator] Using default takeoff altitude: 2.5 m