a

Dependents:   4thcomp 6th33222_copy

Fork of Locate by Tk A

Files at this revision

API Documentation at this revision

Comitter:
choutin
Date:
Sat Sep 17 23:20:49 2016 +0000
Parent:
9:69fe7b8350c6
Commit message:
?

Changed in this revision

locate.cpp Show annotated file Show diff for this revision Revisions of this file
locate.h Show annotated file Show diff for this revision Revisions of this file
diff -r 69fe7b8350c6 -r d88fe87720d2 locate.cpp
--- a/locate.cpp	Fri Sep 16 08:48:12 2016 +0000
+++ b/locate.cpp	Sat Sep 17 23:20:49 2016 +0000
@@ -5,13 +5,13 @@
 
 
 /********以下グローバル変数宣言**************/
-
+Serial pc(SERIAL_TX, SERIAL_RX); 
 TIM_Encoder_InitTypeDef encoder1, encoder2;     //Encoderライブラリで使う
 TIM_HandleTypeDef  timer1,  timer2;             //Encoderライブラリで使う
 uint16_t count1=0,  count2=0;                   //Encoderライブラリで使う
 int8_t   dir1, dir2;                            //Encoderライブラリで使う
 
-Serial pc(SERIAL_TX, SERIAL_RX);    //pcと通信
+
 DigitalOut enc_v(PC_7);             //エンコーダの電源
 
 int     r, l;                  //現在の回転数
@@ -82,7 +82,7 @@
     pr = r;
     pl = l;
     //pc.printf("count1:%d%s  count2:%d%s\r\n", count1, dir1==0 ? "+":"-",count2, dir2==0 ? "+":"-");
-    pc.printf("right:%d     left:%d     x:%d    y:%d    t:%f\n\r", r, l, coordinateX(), coordinateY(), coordinateTheta());
+    pc.printf("right:%d     left:%d     x:%d    y:%d    t:%f   d%d\n\r", r, l, coordinateX(), coordinateY(), coordinateTheta(),r-l);
 }
 
 void update_np()
@@ -103,6 +103,7 @@
 
     pr = r;
     pl = l;
+    pc.printf("right:%d     left:%d     x:%d    y:%d    t:%f   d%d\n\r", r, l, coordinateX(), coordinateY(), coordinateTheta(),r-l);
 }
 
 int coordinateX()
diff -r 69fe7b8350c6 -r d88fe87720d2 locate.h
--- a/locate.h	Fri Sep 16 08:48:12 2016 +0000
+++ b/locate.h	Sat Sep 17 23:20:49 2016 +0000
@@ -4,14 +4,16 @@
 #include <math.h>
 #include "Encoder.h"
  
+ 
+ //Serial pc(SERIAL_TX, SERIAL_RX);
 /****************定数定義***************************/
  
 #define OUTERRING_D     140             //外輪間距離(mm)
 #define INNERRING_D     136             //内輪間距離(mm)
 #define PI              3.14159         //π
 #define RESOLUSION      200             //P/R(分解能)
-#define DIAMETER        31.8            //タイヤの直径(mm)
-#define ROUND_HOSEI     1.038            //角度のズレを補正.038
+#define DIAMETER        32.05          //タイヤの直径(mm)
+#define ROUND_HOSEI     1.0367            //角度のズレを補正.038
 #define HOSEI           1.00
 // エンコーダの1ステップあたりの距離;(mm)
 #define LOCATE_STEP     (DIAMETER*PI / RESOLUSION * HOSEI)