0
$\begingroup$

I wrote an Arduino program for my quadcopter that sets to power of the 4 ESC's using software. Now I need to incorporate the gyro and add a "Complementary Filter" to stabilize it.

I am currently using a MPU 6050 for the job.

I primarily want to know what is the best approach to take for compensating the angular rate from the receiver using gyro.

Should i give the use the angle from my receiver and program my quad works to achieve that angle or should I try to control angular rate?

e.g angular rate:- receiver roll stick moves produces an angular rate that my PID compares with angular rate of gyro and alters values for the esc's.

e.g angle:- receiver roll stick moves produces an angle that my PID compares with the ANGLE of gyro+Accelerometer and then alters my ESC values

$\endgroup$
  • $\begingroup$ A complementary filter adds a percentage P of signal "A" with a complementary percentage (1-P) of signal "B". It is vital that signal "A" and signal "B" be reporting in the same units! You can't just take a gyro (degrees per second) and "join" it to an accelerometer (meters per second squared) to get an angle (degrees). You need to convert everything to angles FIRST before you can fuse them with a complimentary filter. I always advocate everyone just use the Madgwick filter instead of trying to write your own. $\endgroup$ – Chuck Jan 16 '18 at 20:35
  • $\begingroup$ If you really want to use the complementary filter, then please edit your question to reflect the information requested above: what you want, what you tried, what you saw, and what you expected to see. Diagrams, source code, papers you read, etc. are all helpful in understanding what you're trying to do. $\endgroup$ – Chuck Jan 16 '18 at 20:37
  • $\begingroup$ Are you asking whether it is better for your PID loop should control angle or angular rate? $\endgroup$ – markshancock Jan 17 '18 at 20:49
  • $\begingroup$ yes that is what i am asking... $\endgroup$ – Syed Maaz Jan 18 '18 at 12:54
  • $\begingroup$ I tried my best to edit the question to clarify what the OP is asking. If I understand it correctly now, I think I can answer it. $\endgroup$ – markshancock Jan 19 '18 at 5:13
1
$\begingroup$

Whether to control absolute angle or angular rate depends a lot on how you want your design to work.

For a PID loop, the best parameter to calculate the error for is the parameter that you want to control.

If you were commanding direction and had a compass sensor, it would make the most sense to control absolute angle rather than rate.

In your case, it seems like the the joy stick is commanding rotation rate and the gyro is measuring rotation rate as well; so, controlling rate might make the most sense in your application.

BUT ... Think of the operator, what does HE really want to be controlled. IMHO, the operator really wants the quadcopter to hold position. That is the most important parameter for him. Rotation rate is only a means to an end. He is setting rate to achieve position. The operator's brain is actually running separate control loop that is trying to achieve the desired direction. If a wind blast comes, what does he what held - angular position or angular rate. IMHO, he wants it to hold angular position.

I know position is an inferred parameter from the gyro rate and the joystick rate; but, angular position error is what I would control.

Again, the design is yours. Only you know what is best to control.

$\endgroup$
  • 1
    $\begingroup$ @markshanock surprisingly many quadrotor racing hobbyists control their platform via angular rate, after the tedious acclimation it seems to provide better agility (also removing the use of accelerometers data). I agree that in general for untrained user and intuitive reaction to external disturbances (wind) angular position control might be more advisable. Especially if the intend goal is to fly a lot in hovering. $\endgroup$ – N. Staub Jan 26 '18 at 18:00
  • $\begingroup$ @N.Staub The human control loop definitely throws some subjectivity into the choice. Skilled drivers often don't want the control system to "help" them. Ex: Coming around a corner, the driver may be intentional steering the craft the "wrong" direction to account for what they expect will happen in the turn. Like when Doc told Lightning "Turn Right To Go Left" $\endgroup$ – markshancock Jan 26 '18 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.