確認用
Dependencies: HCSR04_2 MPU6050_2 mbed SDFileSystem3
Fork of Autoflight2018_29 by
Diff: main.cpp
- Revision:
- 13:77b13d5f4d78
- Parent:
- 12:763bf416ba4b
- Child:
- 14:bbd5ff31fb67
diff -r 763bf416ba4b -r 77b13d5f4d78 main.cpp --- a/main.cpp Sun Sep 16 06:10:05 2018 +0000 +++ b/main.cpp Sun Sep 16 07:59:29 2018 +0000 @@ -43,7 +43,7 @@ #define TAKEOFF_THR 0.8 #define LOOP_THR 0.6 -#define g_rightloopRUD 1500 +//#define g_rightloopRUD 1500 #define RIGHT_ROLL_SHORT -12.0 #define RIGHT_PITCH_SHORT -5.0 @@ -224,7 +224,13 @@ float *g_rightloopROLLshort, float *g_rightloopPITCHshort, float *g_leftloopROLLshort, float *g_leftloopPITCHshort, float *g_glideloopROLL, float *g_glideloopPITCH, - float *g_kpAIL, float *g_kiAIL, float *g_kdAIL); + float *g_kpAIL, float *g_kiAIL, float *g_kdAIL, + int *g_rightloopRUD, int *g_rightloopshortRUD, + int *g_leftloopRUD, int *g_leftloopshortRUD, + int *g_glideRUD, + int *g_AIL_L_correctionrightloop,int *g_AIL_L_correctionrightloopshort, + int *g_AIL_L_correctionlefttloop,int *g_AIL_L_correctionleftloopshort + ); //switch2割り込み void ResetTrim(); @@ -293,7 +299,13 @@ &g_rightloopROLLshort, &g_rightloopPITCHshort, &g_leftloopROLLshort, &g_leftloopPITCHshort, &g_glideloopROLL, &g_glideloopPITCH, - &g_kpAIL, &g_kiAIL,&g_kdAIL); + &g_kpAIL, &g_kiAIL,&g_kdAIL, + &g_rightloopRUD, &g_rightloopshortRUD, + &g_leftloopRUD, &g_leftloopshortRUD, + &g_glideloopRUD, + &g_AIL_L_correctionrightloop,&g_AIL_L_correctionrightloopshort, + &g_AIL_L_correctionleftloop,&g_AIL_L_correctionleftloopshort + ); Init_PWM(); @@ -591,13 +603,18 @@ float *g_rightloopROLLshort, float *g_rightloopPITCHshort, float *g_leftloopROLLshort, float *g_leftloopPITCHshort, float *g_glideloopROLL, float *g_glideloopPITCH, - float *g_kpAIL, float *g_kiAIL, float *g_kdAIL + float *g_kpAIL, float *g_kiAIL, float *g_kdAIL, + int *g_rightloopRUD, int *g_rightloopshortRUD, + int *g_leftloopRUD, int *g_leftloopshortRUD, + int *g_glideloopRUD, + int *g_AIL_L_correctionrightloop,int *g_AIL_L_correctionrightloopshort, + int *g_AIL_L_correctionleftloop,int *g_AIL_L_correctionleftloopshort ){ pc.printf("SDsetup start.\r\n"); FILE *fp; - char parameter[30]; //文字列渡す用の配列 + char parameter[40]; //文字列渡す用の配列 int SDerrorcount = 0; //取得できなかった数を返す const char *paramNames[] = { "KP_ELEVATOR", @@ -622,7 +639,16 @@ "AUTOGLIDE PITCH", "KP_AILERON", "KI_AILERON", - "KD_AILERON" + "KD_AILERON", + "RIGHTLOOP_RUDDER", + "RIGHTLOOPSHORT_RUDDER", + "LEFTLOOP_RUDDER", + "LEFTLOOPSHORT_RUDDER", + "GLIDELOOP_RUDDER", + "AILERON_LEFT_CORRECTION_RIGHTLOOP", + "AILERON_LEFT_CORRECTION_RIGHTLOOPSHORT", + "AILERON_LEFT_CORRECTION_LEFTLOOP", + "AILERON_LEFT_CORRECTION_LEFTLOOPSHORT" }; fp = fopen("/sd/option.txt","r"); @@ -721,6 +747,43 @@ else{ *g_kdAIL = KP_AIL; SDerrorcount++; } + if(GetParameter(fp,paramNames[23],parameter)) *g_rightloopRUD = atof(parameter); + else{ *g_rightloopRUD = RIGHTLOOP_RUD; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[24],parameter)) *g_rightloopshortRUD = atof(parameter); + else{ *g_rightloopshortRUD = RIGHTLOOPSHORT_RUD; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[25],parameter)) *g_leftloopRUD = atof(parameter); + else{ *g_leftloopshortRUD = LEFTLOOP_RUD; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[26],parameter)) *g_leftloopshortRUD = atof(parameter); + else{ *g_leftloopshortRUD = LEFTLOOPSHORT_RUD; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[27],parameter)) *g_glideloopRUD = atof(parameter); + else{ *g_glideloopRUD = GLIDELOOP_RUD; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[28],parameter)) *g_AIL_L_correctionrightloop = atof(parameter); + else{ *g_AIL_L_correctionrightloop = AIL_L_CORRECTION_RIGHTLOOP; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[29],parameter)) *g_AIL_L_correctionrightloopshort = atof(parameter); + else{ *g_AIL_L_correctionrightloopshort = AIL_L_CORRECTION_RIGHTLOOPSHORT; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[30],parameter)) *g_AIL_L_correctionleftloop = atof(parameter); + else{ *g_AIL_L_correctionleftloop = AIL_L_CORRECTION_LEFTLOOP; + SDerrorcount++; + } + if(GetParameter(fp,paramNames[31],parameter)) *g_AIL_L_correctionleftloopshort = atof(parameter); + else{ *g_AIL_L_correctionleftloopshort = AIL_L_CORRECTION_LEFTLOOPSHORT; + SDerrorcount++; + } + fclose(fp); }else{ //ファイルがなかったら @@ -742,7 +805,17 @@ *g_kpAIL = KP_AIL; //パラメータ変えるのお忘れなく!! *g_kiAIL = KI_AIL; *g_kdAIL = KD_AIL; - + *g_rightloopRUD = RIGHTLOOP_RUD; + *g_rightloopshortRUD = RIGHTLOOPSHORT_RUD; + *g_leftloopRUD = LEFTLOOP_RUD; + *g_leftloopshortRUD = LEFTLOOPSHORT_RUD; + *g_glideloopRUD = GLIDELOOP_RUD; + *g_AIL_L_correctionrightloop = AIL_L_CORRECTION_RIGHTLOOP; + *g_AIL_L_correctionrightloopshort = AIL_L_CORRECTION_RIGHTLOOPSHORT; + *g_AIL_L_correctionleftloop = AIL_L_CORRECTION_LEFTLOOP; + *g_AIL_L_correctionleftloopshort = AIL_L_CORRECTION_LEFTLOOPSHORT; + + SDerrorcount = -1; } pc.printf("SDsetup finished.\r\n");