关于MK算法的一些值的取值范围的疑惑------希望各位大大能够赐教!
最近在看MK的算法,觉得对于里面一些值的范围不是很理解,例如MEAN()中的这一部分:
// Roll
Reading_GyroRoll += tmpl;
Reading_GyroRoll += (tmpl2 * FCParam.Yaw_NegFeedback) / 512L;
Reading_IntegralGyroRoll2 += Reading_GyroRoll;
Reading_IntegralGyroRoll += Reading_GyroRoll - AttitudeCorrectionRoll;
if(Reading_IntegralGyroRoll > TurnOver180Roll)
{
Reading_IntegralGyroRoll = -(TurnOver180Roll - 10000L);
Reading_IntegralGyroRoll2 = Reading_IntegralGyroRoll;
}
if(Reading_IntegralGyroRoll < -TurnOver180Roll)
{
Reading_IntegralGyroRoll = (TurnOver180Roll - 10000L);
Reading_IntegralGyroRoll2 = Reading_IntegralGyroRoll;
}
if(AdValueGyrRoll < 15) Reading_GyroRoll = -1000;
if(AdValueGyrRoll < 7) Reading_GyroRoll = -2000;
if(BoardRelease == 10)
{
if(AdValueGyrRoll > 1010) Reading_GyroRoll = +1000;
if(AdValueGyrRoll > 1017) Reading_GyroRoll = +2000;
}
else
{
if(AdValueGyrRoll > 2020) Reading_GyroRoll = +1000;
if(AdValueGyrRoll > 2034) Reading_GyroRoll = +2000;
}
if(AdValueGyrRoll > 2020) Reading_GyroRoll = +1000;
if(AdValueGyrRoll > 2034) Reading_GyroRoll = +2000;
AdValueGyrRoll不是陀螺仪的数值吗?但是AVR可是10位的AD啊,理论上最大值应该就是1024啊,为什么要写
>2020呢?仔细看了看,没有发现MK对这个值进行了放大。觉得很疑惑,请教各位了,谢谢!
还有最后的姿态结算部分
DiffNick = Reading_GyroNick - StickNick; // get difference
SumNick += IntegralNick * Gyro_I_Factor - StickNick; // I-part for attitude control
if(SumNick > (STICK_GAIN * 16000L)) SumNick = (STICK_GAIN * 16000L);
if(SumNick < -(STICK_GAIN * 16000L)) SumNick = -(STICK_GAIN * 16000L);
pd_result = DiffNick + Ki * SumNick; // PI-controller for nick
tmp_int = (int32_t)((int32_t)FCParam.DynamicStability * (int32_t)(GasMixFraction + abs(YawMixFraction)/2)) / 64;
if(pd_result > tmp_int) pd_result = tmp_int;
if(pd_result < -tmp_int) pd_result = -tmp_int;
// Motor Front
MotorValue = GasMixFraction + pd_result + YawMixFraction; // Mixer
根据前面提到的,KI=0.0001,而这里面与加速度计补偿陀螺有关的好想只有IntegralNick,而由IntegralNick得来的SumNick乘了
0.0001,这样的话,前面的补偿的影响不是十分小了吗?看不太明白,期待高手解答~~~ |