Wallbot_CaaS

Dependencies:   MPU6050 mbed PID

Fork of BLE_MPU6050_test6_challenge_sb by Junichi Katsu

Revision:
5:eeabd90b6d62
Parent:
4:6b4563aaee2c
Child:
6:9fd87d75a24b
--- a/main.cpp	Wed May 16 09:52:29 2018 +0000
+++ b/main.cpp	Thu May 17 01:41:56 2018 +0000
@@ -227,10 +227,16 @@
     //Advertizeの開始
     ble.startAdvertising();
 
-	wb.right_motor(0.5);
-	wb.left_motor(0.5);
+	//wb.move(30,30);
+	pc.printf("auto calibrate start\n\r");
+    wb.auto_calibrate();
+    for(int i = 0 ; i < 4 ; i++)
+	{
+		pc.printf("(%d,%d) ",wb._calibratedMinimum[i],wb._calibratedMaximum[i]);
+	}
+	pc.printf("\n\rauto calibrate end\n\r");
     
-#ifdef ENCCALIB //エンコーダキャリブレーション用コード
+#if 0 //エンコーダキャリブレーション用コード
 	BusIn enc(P0_8,P0_10,P0_6,P0_7);
 	enc.mode(PullNone);
 	while(1){
@@ -239,18 +245,15 @@
 		wait_ms(10);
 	}
 #endif
+
     while (true) {
-    	
 		//mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
 		#ifdef DEBUG
-			
-			//pc.printf("pulse(%d,%d) state(%d,%d)",wb.left_getPulses(),wb.right_getPulses(),wb._left_enc.getCurrentState(),wb._right_enc.getCurrentState());
-			//pc.printf("%d%d%d%d ",((enc.read() >> 3) & 1), ((enc.read() >> 2) & 1), ((enc.read() >> 1) & 1), (enc.read() & 1));
-			//pc.printf("LinePos:%d RPM(%d,%d)",wb.GetLinePosition(),wb.get_left_rpm(),wb.get_right_rpm());
-			//pc.printf("calib(%d,%d,%d,%d)",wb.sensor_values[0],wb.sensor_values[1],wb.sensor_values[2],wb.sensor_values[3]);
+			pc.printf("Pulse(%d,%d) RPM(%.2f,%.2f) ",wb._left_pulses,wb._right_pulses,wb.get_left_rpm(),wb.get_right_rpm());
+			pc.printf("LinePos:%d ",wb.GetLinePosition());
+			pc.printf("calib(%d,%d,%d,%d)",wb.sensor_values[0],wb.sensor_values[1],wb.sensor_values[2],wb.sensor_values[3]);
 		    //pc.printf("MPU6050(%d;%d;%d;%d;%d;%d)\n\r",ax,ay,az,gx,gy,gz);
-		    
-		    //pc.printf("\n\r");
+		    pc.printf("\n\r");
 		    wait_ms(10);
 		#endif
     }