Page 1 of 2
crazyflie control system
Posted: Sun Feb 08, 2015 4:28 pm
by almaz_1c
Hello. I looked to stabilizerTask() function and made flowchart of stabilization control system ( see Picture in attachment ). So, is i right understand the mechanism of stabilization?
Now i am interested in realize mechanism of vertical movement. For example, to quadrocopter raised to a certain height. After reaching the desired height hovered on it. I think there is must be some block attached to stabilization system. And input of this block must be the desired height and output - "thrust" signal on picture. Is this block can be maided as PID regulator? I would like to understand how to develop a control system. How has developed a stabilization system ( stabilizerTask() ) of Crazyflie - Is there is used a typical scheme of control system theory? Can you point me to used literature? Thank you)
Re: crazyflie control system
Posted: Mon Feb 09, 2015 8:39 am
by poizone
I've been reading through the firmware, and if I'm correct crazyflies have barometer based altitude hold available in the most current versions. The bulk of the code can be found in
https://github.com/bitcraze/crazyflie-f ... abilizer.c, defined under stabilizerAltHoldUpdate(void).
Re: crazyflie control system
Posted: Mon Feb 09, 2015 10:21 pm
by almaz_1c
Is it possible to replace used two PID controllers with single PID, which take as input - angle error and gives the actuator thrust as output?
Re: crazyflie control system
Posted: Tue Feb 10, 2015 6:36 am
by poizone
It's most definitely possible, and refactoring the PID system is actually something I've been looking into also for my quad. The hover mode is separated because some people want the option to enable and disable it, and it was added after the original stabilization PID was written.
Your inputs would need to be a little more complicated than just angle of error though. The crazyflie is affected by air currents, battery voltage, and motor wear. You'll need to account for all three axes individual error as is done now to achieve a stable system. This could be combined into a single PID function, but would still take three axes of sensor data adjusted for gravity, as in the current code, plus a fourth for altitude using either the barometer alone, the barometer and measured vertical accelerations, or even ultrasonic altitude.
Re: crazyflie control system
Posted: Tue Feb 10, 2015 9:51 am
by tobias
Is it possible to replace used two PID controllers with single PID, which take as input - angle error and gives the actuator thrust as output?
Yes it you can. The cascaded "PI + P" actually becomes a PID as the derivative of the angle is the angular speed, thus "D" in the PID. The benefit is that the angular speed controller can run at a faster update rate then the angular controller, saving computational power.
@poizone
A rework of the stabilization system would be great, it was implemented a long time ago and since it has been working quite well it hasn't been developed that much. However as other sensors is a lot easier to add now with the expansion board capability on CF2 the stabilization system it would be great if it was easier to incorporate them.
Re: crazyflie control system
Posted: Tue Feb 10, 2015 5:36 pm
by almaz_1c
I found a paper
http://enu.kz/repository/2010/AIAA-2010-3407.pdf which states that it is possible to use only one PID regulator on each axis. The input to that PID regulator is angle error. PID regulator output - PWM actuator. I made the similarity of their stand, but a week can not find suitable PID coefficients. Unfortunately, PID coefficients selection not described in this document. Is someone have experience of selection or calculation of PID coefficients? Point me please how do that?
Re: crazyflie control system
Posted: Tue Feb 10, 2015 10:48 pm
by poizone
almaz_1c wrote:I found a paper
http://enu.kz/repository/2010/AIAA-2010-3407.pdf which states that it is possible to use only one PID regulator on each axis. The input to that PID regulator is angle error. PID regulator output - PWM actuator. I made the similarity of their stand, but a week can not find suitable PID coefficients. Unfortunately, PID coefficients selection not described in this document. Is someone have experience of selection or calculation of PID coefficients? Point me please how do that?
PID coefficients can be optimized using Particle Swarm Optimization, or many other algorithms. This is called automatic tuning, and is my second goal for the refactoring I'm trying to do. For manual tuning, tune the Kp gain first, with Ki and Kd at 0. The Kp tuning will give you the majority of the stabilization. If you want smooth motion, a smaller Kp is the goal. For aerobatic maneuvers you'll want a higher Kp to force a faster return to the setpoint. After finding a stable Kp (Too high and you'll have
marginal stability or oscillations), tune the Ki to help prevent drift and hold your heading. Finally tune the Kd to adjust the snappiness of returning to the setpoint. By snappiness, I mean how quickly it eliminates overshoot from the adjustment.
These details are all from
http://www.rcgroups.com/forums/showthread.php?t=1375728. This should give you an overview on how the tuning process works, and what changing the gain values will do for certain types of flying.
Re: crazyflie control system
Posted: Tue Feb 10, 2015 11:40 pm
by almaz_1c
poizone,
thank you for answer.
Is it right algorithm to tune PID?
1) I mount my quadcopter on stand so that quadcopter can rotate around just one of axis.
2) set Ki = 0 and Kd = 0
3) step by step to increase the Kp and at some point get oscillations of quadcopter around the axis of rotation without tipping upside down of my quadcopter?
Re: crazyflie control system
Posted: Wed Feb 11, 2015 1:21 am
by poizone
That'd be correct for controlling on a per-axis basis, yes. You should be able to find a point where oscillations are minimized using that method. Be sure to understand how pitch and roll are being calculated and corrected in the x configuration versus the plus configuration too. X configurations require input from both the pitch and roll sensors based on the orientation of the accelerometers. This can lead to a more stable and maneuverable platform, but the math requires both pitch and roll PIDs to be tightly coupled over time for true stability rather than marginal stability.
I will note that the Kp for pitch and roll should be shared, especially in X configurations. You could separate them for a plus configuration, but unequal values will give one dimension much more stability, and the other will be more maneuverable. Good for "linear" flight (Airplanes), not so much omnidirectional flight (Quads).
Re: crazyflie control system
Posted: Wed Feb 11, 2015 1:18 pm
by almaz_1c
No, it is impossible to get oscillations using only P coefficient!!!
See first picture. At starting position quadcopter placed horizontally. Then it falls down to left side until the generated actuator does stop falling ( point number 1, angular velocity = 0 ) and return it back to gorizontal position ( point number 2, angle error = 0 ). But!!! In point number 2 the angular velocity is not zero!!!! There is must be Kd coefficient that press down angular velocity to zero!