The problem is that the quadrotor can become unstable. I need to maintain a level flying platform... The inputs to the system consist of four motor speeds and when the force generated by all four motors is greater then the downward gravitational force then we achieve flight. I can get a rotational matrix from ODE and VPython gives me the up axis..
I have investigated using PID control but I am unsure as to how to tune the various parameters and what to do with the output that such a routine would give. I tried a routine myself that consisted of simply comparing the Y coordinates and adjusting the motor speeds that way but this proved too unstable (Yes I know that technically this method was cheating as I used more knowledge of the system then I have given here...).
Screenshot of my system:
Any thoughts? I have had some thoughts involving taking the up axis of the main "body" of the quadrotor and taking a dot product with the desired up vector... and then what to do from there is sort of eluding me...
Here is a PID control pseduocode I adapted from wikipedia articles to prove that I am clueless:
Ku = 1
Tu = 2
Kp = 0.33*Ku
Ki = (2*Kp) / Tu
Kd = (Kp*Tu) / 3
previous_error = target - actual
integral = 0
start:
error = target - actual
integral += error * dt
derivative = (error - previous_error) /dt
output = (Kp * error) + (Ki * integral) + (Kd * derivative)
previous_error = error
*Implements PID in Ideal Parallel Form from : http://en.wikipedia..../PID_controller
*Also implements the Ziegler–Nichols method for tuning: http://en.wikipedia....3Nichols_method using overshoot parameters.
P.S. : The entire code is open source and under a GNU GPL v3 license ... I am still actively developing the code... so it probably looks terrible (sorry about that!) but hopefully it will help others! here is a link: quadrotor simulation source