Octopus!!

Dependencies:   2017NHKpin_config FEP HMC6352 PID QEI R1307 ikarashiMDC omni_wheel

Fork of KANIv3 by NagaokaRoboticsClub_mbedTeam

Revision:
5:16ea97725085
Parent:
4:1073deb368df
Child:
6:fe9767a50891
--- a/bot/bot.cpp	Wed Sep 06 00:01:47 2017 +0900
+++ b/bot/bot.cpp	Wed Sep 06 17:47:20 2017 +0900
@@ -2,19 +2,25 @@
 
 Bot::Bot() :
     PIDC(), pad(XBee1TX, XBee1RX, ADDR),
-    motor(MDSDA, MDSCL, solenoidPin)
+    motor(MDSDA, MDSCL, solenoidPin),
+    led({DebugLED1, DebugLED2, DebugLED3, DebugLED4})
+    ,debugSerial(USBTX, USBRX, 11520)
 {
     motor.goXY(0, 0, 0);
     motor.moveSlider(0);
     motor.destroy(0);
     motor.swing(0);
     motor.shakeHead(0);
+
+    // led[0] = 1;
+    // led[1] = 1;
+    // led[2] = 1;
 }
 
 void Bot::confirmAll()
 {
     suc = pad.receiveState();
-    PIDC::confirm();
+    // PIDC::confirm();
     if(!suc) {
         motor.goXY(0, 0, 0);
         motor.moveSlider(0);
@@ -28,7 +34,7 @@
 {
     if(suc) {
         if(pad.getNorm(1) > 0.5) {
-            PIDC::setSetPoint((pad.getRadian(1) - M_PI / 2) * (180.0 / M_PI));
+            PIDC::PID::setSetPoint((pad.getRadian(1) - M_PI / 2) * (180.0 / M_PI));
             PIDC::confirm();
         }
         motor.goXY(pad.getStick(0) / 2.0,-pad.getStick(1) /2.0, PIDC::co);
@@ -41,13 +47,18 @@
 {
     float moment = 0;
     static float beforestick = pad.getStick(2);
+    if(!pad.getButton2(2)) {
+        PIDC::resetOffset2();
+        led[3] = 1;
+    }
 
     if((beforestick >= 0.5 && pad.getStick(2) < 0.5) || (beforestick <= -0.5 && pad.getStick(2) > -0.5)) {
-        PIDC::setSetPoint(PIDC::getDegree() / 10.0);
+        PIDC::PID::setSetPoint(0.0);
+        PIDC::resetOffset();
     }
 
     if(pad.getStick(2) > 0.5 || pad.getStick(2) < -0.5) {
-        moment = pad.getStick(2) / 2.0;
+        moment = pad.getStick(2) / 4.0;
         PIDC::confirm();
     }
     if(fabs(pad.getStick(2)) < 0.5) {
@@ -56,11 +67,12 @@
     }
 
     if(suc) {
-        motor.goCircular(pad.getNorm(0),pad.getRadian(0) - PIDC::getDegree() / 10.0 * (M_PI / 180.0) + M_PI, moment);
+        motor.goCircular(pad.getNorm(0) / 2.0,pad.getRadian(0) - PIDC::initDegree2 / 10.0 * (M_PI / 180.0) + M_PI, moment);
     } else {
         motor.goXY(0, 0, 0);
     }
     beforestick = pad.getStick(2);
+    debugSerial.printf("%d\n\r", PIDC::initDegree);
 }
 
 void Bot::controllMech()
@@ -74,8 +86,8 @@
 //        if(!pad.getButton1(4)) motor.shakeHead(-ARM_MAX_SPEED);
 //        if(pad.getButton1(3) && pad.getButton1(4)) motor.shakeHead(0);
 //
-        if(!pad.getButton1(5)) motor.swing(0.2);
-        if(!pad.getButton1(6)) motor.swing(-0.2);
+        if(!pad.getButton1(5)) motor.swing(0.6);
+        if(!pad.getButton1(6)) motor.swing(-0.6);
         if(pad.getButton1(5) && pad.getButton1(6)) motor.swing(0);
 
 //