Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MPU6050_2 HMC5883L_2 SDFileSystem3
Revision 11:8427ecccf07d, committed 2019-02-11
- Comitter:
- taknokolat
- Date:
- Mon Feb 11 10:58:57 2019 +0000
- Parent:
- 10:63fe920595a7
- Commit message:
- a;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Mon Feb 11 10:58:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/1519026547/code/SDFileSystem3/#85fbe134acff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/SkipperSv2.h Mon Feb 11 10:58:57 2019 +0000 @@ -0,0 +1,22 @@ +#ifndef SKIPPERSV2_H_ +#define SKIPPERSV2_H_ + +/*フライトモードの変数================ + ModeBreak モードブレイク 状態変更時に1回だけ呼び出して、現在実行中のRTOSタスクを全部無効にする + StartUP 初期化モード まず最初に呼び出して、各種設定を有効にし、機体のチェック等を行う + ManualMode 手動飛行モード 通常のラジコンと同じ状態 + AutoLoop 自動操縦 水平旋回モード + AutoMobius 自動操縦 8の字飛行モード + AutoClimb 自動操縦 上昇旋回 + AutoGlide 自動操縦 自動滑空 + AutoLanding 自動操縦 自動着陸 +*/ + + #define MAGBIASX 0 //-63 + #define MAGBIASY 0 //580 + #define MAGBIASZ 0 //132 + +bool Flag_ChangeMode=true; //モードを切り替えた瞬間を検出してtrueを返す モード変更が直ちに行われ、falseになる。 +//=========== end ============= + +#endif /* SKIPPERSV2_H_ */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config/falfalla.h Mon Feb 11 10:58:57 2019 +0000
@@ -0,0 +1,72 @@
+#ifndef FALFALLA_H
+#define FALFALLA_H
+
+#define SWITCH_CHECK 1400
+#define NUMBER_FALFALLA 2 //何号機かを入れるとそれに応じて#if以下が変わって設定が変わる
+
+static int servo_NEUTRAL_R = 1900;
+static int servo_NEUTRAL_L = 1900;
+static int servo_FORWARD_R = 1860;
+static int servo_FORWARD_L = 1860
+static int servo_back_R = 1060;
+static int servo_back_L = 1060;
+static int servo_slow_FORWARD_R = 1560;
+static int servo_slow_FORWARD_L = 1560;
+static int servo_slow_back_R = 1360;
+static int servo_slow_back_L = 1360;
+static int TurnTable_NEUTRAL = 1500;//カメラ台座のサーボ
+static int MatchSpeed = servo_NEUTRAL_R + 100; //カメラと方向を合わせるときの車輪の速度
+static int minFocus = 1200; //焦点合わせ用サーボの最小値
+
+static float g_rightloopROLL=-17.0;
+static float g_rightloopROLL_approach=-17.0;
+static float g_rightloopPITCH=-6.3;
+static float g_rightloopPITCH_approach = -15.0;
+static float g_leftloopROLL=16.0;
+static float g_leftloopROLL_approach=16.0;
+static float g_leftloopPITCH=-6.0;
+static float g_leftloopPITCH_approach=-13.0;
+static float g_gostraightROLL=2.0;
+static float g_gostraightPITCH=-3.0;
+static float g_takeoffTHR=1.0;
+static float g_loopTHR=0.58;
+
+static float g_rightloopROLLshort=-20.0;
+static float g_rightloopPITCHshort=-7.0;
+static float g_leftloopROLLshort=22.0;
+static float g_leftloopPITCHshort=-6.0;
+
+static float g_glideloopROLL = -5.0; //rewrite
+static float g_glideloopPITCH = 0.0;
+static float g_autoonPITCH = -3.0;
+
+static int g_rightloopRUD = 1500;
+static int g_rightloopRUD_approach=1500;
+static int g_rightloopshortRUD = 1500;
+static int g_leftloopRUD = 1500;
+static int g_leftloopRUD_approach = 1710;
+static int g_leftloopshortRUD = 1500;
+static int g_glideloopRUD = 1500;
+
+static int g_AIL_L_correctionrightloop = 0;
+static int g_AIL_L_correctionrightloopshort = 0;
+static int g_AIL_L_correctionleftloop = 0;
+static int g_AIL_L_correctionleftloopshort = 0;
+
+
+#if NUMBER_FALFALLA == 1 //1号機
+const int8_t Reverce_falfalla[4] = {1,-1,1,1}; //Nutral:1 , Reverce:-1
+
+#elif NUMBER_FALFALLA == 2 //2号機
+const int16_t Reverce_falfalla[4] = {1,-1,1,-1}; //Nutral:1 , Reverce:-1
+
+#endif
+
+
+#endif /* ESTRELA_H_ */
+
+/*
+x軸回り ロール
+y軸回り ピッチ
+z軸回り ヨー
+*/
\ No newline at end of file
--- a/main.cpp Sun Feb 10 09:05:27 2019 +0000
+++ b/main.cpp Mon Feb 11 10:58:57 2019 +0000
@@ -1,6 +1,7 @@
#include "mbed.h"
#include "MPU6050_DMP6.h"
#include "HMC5883L.h"
+#include "SDFileSystem.h"
//MPU_check用
#define PI 3.14159265358979
@@ -47,6 +48,16 @@
void MatchPosition();
void FocusAdjust();
+//sd設定
+int GetParameter(FILE *fp, const char *paramName,char parameter[]);
+
+int SetOptions(int *servo_NEUTRAL_R, int *servo_NEUTRAL_L,
+ int *servo_FORWARD_R, int *servo_FORWARD_L,
+ int *servo_back_R, int *servo_back_L,
+ int *servo_slow_FORWARD_R,int *servo_slow_FORWARD_L,
+ int *TurnTable_NEUTRAL,int *MatchSpeed,int *minFocus
+ );
+
static float nowAngle[3] = {0,0,0},nowAngle_HMC=0;
float FirstROLL = 0.0, FirstPITCH = 0.0 ,FirstYAW = 0.0,g_FirstYAW_HMC;
@@ -84,6 +95,8 @@
RawSerial pc2(PB_6,PB_7,115200); //uart1
//pb6:UART1_TX,pb7:UART1_RX
+SDFileSystem sd(PB_15, PB_14, PB_13, PB_12, "sd");//sdカード
+
char g_landingcommand='N';
//MPU_check用
@@ -343,6 +356,10 @@
void setup(){
+ SetOptions(&servo_NEUTRAL_R, &servo_NEUTRAL_L,&servo_FORWARD_R,&servo_FORWARD_L,&servo_back_R,&servo_back_L,&servo_slow_FORWARD_R,
+ &servo_slow_FORWARD_L,&TurnTable_NEUTRAL,&MatchSpeed,&minFocus
+ );
+
Init_sensors();
//switch2.rise(ResetTrim);
@@ -497,6 +514,136 @@
flg_checkoutlier = false;
}
+
+/sdによる設定
+int SetOptions(int *servo_NEUTRAL_R, int *servo_NEUTRAL_L,
+ int *servo_FORWARD_R, int *servo_FORWARD_L,
+ int *servo_back_R, int *servo_back_L,
+ int *servo_slow_FORWARD_R,int *servo_slow_FORWARD_L,
+ int *TurnTable_NEUTRAL,int *MatchSpeed,int *minFocus
+ ){
+
+ pc.printf("SDsetup start.\r\n");
+
+ FILE *fp;
+ char parameter[20]; //文字列渡す用の配列
+ int SDerrorcount = 0; //取得できなかった数を返す
+ const char *paramNames[] = {
+ "SERVO_NEUTRAL_R",
+ "SERVO_NEUTRAL_L",
+ "SERVO_FORWARD_R",
+ "SERVO_FORWARD_L",
+ "SERVO_BACK_R",
+ "SERVO_BACK_L",
+ "SERVO_SLOW_FORWARD_R",
+ "SERVO_SLOW_FORWARD_L",
+ "TURNTABLE_NEUTRAL",
+ "MATCH_SPEED",
+ "MINFOCUS"
+ };
+
+ fp = fopen("/sd/option.txt","r");
+
+ if(fp != NULL){ //開けたら
+ pc.printf("File was openned.\r\n");
+ if(GetParameter(fp,paramNames[0],parameter)) *servo_NEUTRAL_R = atof(parameter);
+ else{ *servo_NEUTRAL_R = SERVO_NEUTRAL_R;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[1],parameter)) *servo_NEUTRAL_L = atof(parameter);
+ else{ *servo_NEUTRAL_L = SERVO_NEUTRAL_L;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[2],parameter)) *servo_FORWARD_R = atof(parameter);
+ else{ *servo_FORWARD_R = SERVO_FORWARD_R;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[3],parameter)) *servo_FORWARD_L = atof(parameter);
+ else{ *servo_FORWARD_L = SERVO_FORWARD_L;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[4],parameter)) *servo_back_R = atof(parameter);
+ else{ *servo_back_R = SERVO_BACK_R;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[5],parameter)) *servo_back_L = atof(parameter);
+ else{ *servo_back_L = SERVO_BACK_L;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[6],parameter)) *servo_slow_FORWARD_R = atof(parameter);
+ else{ *servo_slow_FORWARD_R = SERVO_SLOW_FORWARD_R;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[7],parameter)) *servo_slow_FORWARD_L = atof(parameter);
+ else{ *servo_slow_FORWARD_L = SERVO_SLOW_FORWARD_L
+ SDerrorcount++;
+ }
+
+ if(GetParameter(fp,paramNames[10],parameter)) *TurnTable_NEUTRAL = atof(parameter);
+ else{ *TurnTable_NEUTRAL = TURNTABLE_NEUTRAL;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[11],parameter)) *MatchSpeed = atof(parameter);
+ else{ *MatchSpeed = MATCH_SPEED;
+ SDerrorcount++;
+ }
+ if(GetParameter(fp,paramNames[12],parameter)) *minFocus = atof(parameter);
+ else{ *minFocus = MINFOCUS;
+ SDerrorcount++;
+ }
+
+ fclose(fp);
+
+ }else{ //ファイルがなかったら
+ pc.printf("fp was null.\r\n");
+
+ *servo_NEUTRAL_R = SERVO_NEUTRAL_R;
+ *servo_NEUTRAL_L = SERVO_NEUTRAL_L;
+ *servo_FORWARD_R = SERVO_FORWARD_R;
+ *servo_FORWARD_L = SERVO_FORWARD_L;
+ *servo_back_R = SERVO_BACK_R;
+ *servo_back_L = SERVO_BACK_L;
+ *servo_slow_FORWARD_R = SERVO_SLOW_FORWARD_R;
+ *servo_slow_FORWARD_L = SERVO_SLOW_FORWARD_L;
+ *TurnTable_NEUTRAL = TURNTABLE_NEUTRAL;
+ *MatchSpeed = MATCH_SPEED;
+ *minFocus = MINFOCUS;
+ SDerrorcount = -1;
+ }
+ pc.printf("SDsetup finished.\r\n");
+ if(SDerrorcount == 0) pc.printf("setting option is success\r\n");
+ else if(SDerrorcount == -1) pc.printf("ERROR 1. cannot open option\r\n");
+ else if(SDerrorcount > 0) pc.printf("ERROR 2. reading parameter is failed[%d]\r\n",SDerrorcount);
+
+ pc.printf("SERVO_NEUTRAL_R = %f, SERVO_NEUTRAL_L = %f\r\n", *g_kpRUD, *g_kiRUD);
+ pc.printf("SERVO_FORWARD_R = %f, SERVO_FORWARD_L = %f, kdRUD = %f\r\n", *servo_FORWARD_R, *servo_FORWARD_L);
+ pc.printf("SERVO_BACK_R = %f, SERVO_BACK_L = %f\r\n", *servo_back_R, *servo_back_L);
+ pc.printf("SERVO_SLOW_FORWARD_R = %f, SERVO_SLOW_FORWARD_L = %f\r\n", *servo_slow_FORWARD_R, *servo_slow_FORWARD_L);
+ pc.printf("TURNTABLE_NEUTRAL = %f, MATCH_SPEED = %f\, MINFOCUS = %fr\n", *TurnTable_NEUTRAL, *MatchSpeed,*minFocus);
+
+ return SDerrorcount;
+}
+
+int GetParameter(FILE *fp, const char *paramName,char parameter[]){
+ int i=0, j=0;
+ int strmax = 200;
+ char str[strmax];
+
+ rewind(fp); //ファイル位置を先頭に
+ while(1){
+ if (fgets(str, strmax, fp) == NULL) {
+ return 0;
+ }
+ if (!strncmp(str, paramName, strlen(paramName))) {
+ while (str[i++] != '=') {}
+ while (str[i] != '\n') {
+ parameter[j++] = str[i++];
+ }
+ parameter[j] = '\0';
+ return 1;
+ }
+ }
+}
void DebugPrint(){
//for(uint8_t i=0; i<3; i++) pc.printf("%3.2f\t",nowAngle[i]); //skipper地磁気センサ_デバック用