omuni

Dependencies:   EC mbed

Files at this revision

API Documentation at this revision

Comitter:
yuto17320508
Date:
Sat Oct 21 07:57:16 2017 +0000
Commit message:
a; ;

Changed in this revision

EC.lib Show annotated file Show diff for this revision Revisions of this file
atai.h Show annotated file Show diff for this revision Revisions of this file
jyairo.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
max_determine.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
motor_move.h Show annotated file Show diff for this revision Revisions of this file
photo.h Show annotated file Show diff for this revision Revisions of this file
pin_define.h Show annotated file Show diff for this revision Revisions of this file
sokkyo.h Show annotated file Show diff for this revision Revisions of this file
sokuteirinn.h Show annotated file Show diff for this revision Revisions of this file
x.y_theta_dainyuu.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1787ed4e6e61 EC.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EC.lib	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ROBOSTEP_SHARE/code/EC/#d73c40fd4b55
diff -r 000000000000 -r 1787ed4e6e61 atai.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/atai.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,44 @@
+
+
+//前進の方向の定義
+double fai=60;//φ
+//個体差で出力調整
+double power_set=0.4;
+double power[3];
+double M[3];
+double MAX;
+double max();
+double x;
+double y;
+double X;
+double Y;
+int i;
+int j;
+//ジョイスティック入力値の偏角
+double sita;
+//関数代入用の角度調整
+double sita_2;
+
+//モーターのクラス
+PwmOut motor[3][2]= {PwmOut(p21),PwmOut(p22),
+                     PwmOut(p23),PwmOut(p24),
+                     PwmOut(p25),PwmOut(p26)
+                    };
+
+//モーターの初期設定
+void setting()
+{
+    for(i=0; i<=2; i++) {
+        power[i]=power_set;
+    }
+    for(i=0; i<=2; i++) {
+        for(j=0; j<=2; i++) {
+            motor[i][j].period_us(100);
+        }
+    }
+}
+
+float attach_timing=0.05f;
+
+
+
diff -r 000000000000 -r 1787ed4e6e61 jyairo.h
diff -r 000000000000 -r 1787ed4e6e61 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+#include "math.h"
+#define Pi 3.14159
+#include "algorithm"
+#include "EC.h"
+#include "pin_define.h"
+#include "atai.h"      //値
+
+#include "photo.h"         //フォトリフレクタ
+#include "sokuteirinn.h"    //測定輪の値の取得 (x,y)
+#include "sokkyo.h"         //測距
+#include "jyairo.h"         //ジャイロ
+#include "motor_move.h"     //モーターを動かす関数
+#include "x.y_theta_dainyuu.h"  //x,y方向をθに変換してモーターを呼び出す
+#include "max_determine.h"    //方向による出力変化の補正
+
+int main() {}
+
diff -r 000000000000 -r 1787ed4e6e61 max_determine.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max_determine.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,14 @@
+
+double max()
+{
+    double m=0;
+    for(i=0; i<=2; i++) {
+        
+        double MAX=fabs(M[i]);
+        if(MAX >= m) {
+            m=MAX;
+        }
+
+    }
+    return m;
+}
\ No newline at end of file
diff -r 000000000000 -r 1787ed4e6e61 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file
diff -r 000000000000 -r 1787ed4e6e61 motor_move.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_move.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,14 @@
+////////////////モーターの動作////////////////
+void motor_act()
+{
+    for(i=0; i<2; i++) {
+        //絶対値をつける関数
+        if(M[i]>=0) {
+            motor[i][0]=M[i];
+            motor[i][1]=0;
+        } else {
+            motor[i][0]=0;
+            motor[i][1]=-M[i];
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 1787ed4e6e61 photo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/photo.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,34 @@
+//フォトインタラプタ上
+InterruptIn photo_1();
+//フォトインタラプタ下
+InterruptIn photo_2();
+
+//フラグ
+int right_flag=1;
+int left_flag=1;
+//フォトトランジスタのフラグ呼び出し
+void photo_1_rise()//右に平行移動しない
+{
+    right_flag=0;
+}
+void photo_1_fall()//右に平行移動する
+{
+    right_flag=1;
+}
+void photo_2_rise()//左に平行移動しない
+{
+    left_flag=0;
+}
+void photo_2_fall()//左に平行移動する
+{
+    left_flag=1;
+}
+
+
+//フォトインタラプタ1
+    photo_1.rise(&photo_1_rise);
+    photo_1.fall(&photo_1_fall);
+
+//フォトインタラプタ2
+    photo_2.rise(&photo_2_rise);
+    photo_2.fall(&photo_2_fall);
\ No newline at end of file
diff -r 000000000000 -r 1787ed4e6e61 pin_define.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pin_define.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,4 @@
+
+
+
+
diff -r 000000000000 -r 1787ed4e6e61 sokkyo.h
diff -r 000000000000 -r 1787ed4e6e61 sokuteirinn.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sokuteirinn.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,21 @@
+int resolution=1024;
+
+
+//測定輪の定義
+float radius = 69.56f;   //測定輪半径
+Ec EncoderDX(pin_encoderDXA,pin_encoderDXB,NC,resolution,attach_timing);
+Ec EncoderDY(pin_encoderDYA,pin_encoderDYB,NC,resolution,attach_timing);
+
+
+//現在距離の取得
+int get_now_distanceX()
+{
+    int now_distanceX=(int)(EncoderDX.getCount()/resolution*Pi*radius);
+    return now_distanceX;
+}
+int get_now_distanceY()
+{
+    int now_distanceY=(int)(EncoderDY.getCount()/resolution*Pi*radius);
+    return now_distanceY;
+}
+int now_distance[2]={get_now_distanceX(),get_now_distanceY()};
\ No newline at end of file
diff -r 000000000000 -r 1787ed4e6e61 x.y_theta_dainyuu.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/x.y_theta_dainyuu.h	Sat Oct 21 07:57:16 2017 +0000
@@ -0,0 +1,14 @@
+//////////x, y代入して出力///////////////////
+void for_act()
+{
+    sita = -1.0*(atan2((double)x,(double)y))*180/Pi;
+    sita_2=90-sita;
+    for (i=0; i<=2; i++) {
+        M[i]=sin((sita_2-(fai+i*(-120)))*Pi/180);
+    }
+    for (i=0; i<=2; i++) {
+        M[i]=M[i]*power[i]/max();//方向による出力の差を補正
+    }
+    motor_act();
+
+}
\ No newline at end of file