Px4 simulink error

Hello every one
We are trying to upload a controller on the Pixhawk 4 or cube using PX4 and simulink (Matlab 2021a) and test it on the testbed. The problem is when applying PID on the quaternion outputs (because of using integration) will have NAN on the outputs. In fact, to control the Euler angles we need to have some thing like a PID controller on the Euler angles. Have anyone encountered suh a problem or have any suggestion about how to apply the PID controller to control the Euler angles since we were not able to use the gyro sensor also for deriving the Euler angles with using the Quarternions.
thanks in dvance