Quaternion 6DOF.slx is a simulink simulation of the rocket attempting to maintain an upright position during flight.
Tune2.slx is for tuning PID values.
Main.cpp is an implementation in arduino for the bluepill (stm32f103c8t6).It should work with arduinos, just copy paste the contents into the arduino ide or whichever you prefer
Using utility header files from adafuit bno055 library for quaternion class.
Understanding PID Control, Part 1: What is PID Control?
How to read values from mpu6050
The Fundamentals of Control Theory
Books Joe Barnard (BPS.space) recommends
https://folk.ntnu.no/skoge/prost/proceedings/ecc-2013/data/papers/0927.pdf
https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20120014565.pdf
http://ardupilot.org/dev/docs/apmcopter-programming-attitude-control-2.html
http://ardupilot.org/dev/docs/ekf2-estimation-system.html?highlight=quaternion
Instead of trying to estimate the quaternion orientation directly, it estimates an error rotation vector and applies the correction to the quaternion from the inertial navigation equations. This is better when there are large angle errors as it avoids errors associated with linearising quaternions across large angle changes.
See “Rotation Vector in Attitude Estimation”, Mark E. Pittelkau, Journal of Guidance, Control, and Dynamics, 2003” for details on this approach.