记一次de了一晚上bug的问题
不知道未来有一天谁能解答 我用的芯片是stm32F411ceu 这个算出来的Pitch变量值一直为0
这是我当时的代码(最后有简化版)
pitch_ay=atan((float)icm_acc_y/(float)icm_acc_z)*57.3;
gx=icm_gyro_x/16.4;
Pitch = K1 * pitch_ay + (1-K1) * (Pitch + gx * dt);
Pitch = K1 * (int)(pitch_ay*100)*0.01 + (1-K1) * (Pitch + gx * dt);
这是它们的变量类型
int16_t icm_acc_x,icm_acc_y,icm_acc_z;
int16_t icm_gyro_x,icm_gyro_y,icm_gyro_z;
float K1=0.2;;
float dt = 10*0.001;
float angle_car;
double pitch_ay;
float gx;
float Pitch=0;
float angle_x;
float angle_y;
float angle_z;
简单来说就是:
double pitch_ay;
float Pitch=0;
pitch_ay=atan(3)*180/3.14;
Pitch = pitch_ay + Pitch;
Pitch的值一直算出为0 100%复现
或者
double xxx;
short x=3000;
xxx=x/(double)icm_acc_z;
这样的xxx也算不出来
|