メインマイコンのプログラム

Dependencies:   mbed SBDBT_for_2022gourobo arrc_mbed

Revision:
3:e4b5563563af
Parent:
1:642ee25ea489
Child:
6:fd9b59f828e8
--- a/main.cpp	Sat Jan 08 12:56:19 2022 +0000
+++ b/main.cpp	Fri Jan 21 08:52:19 2022 +0000
@@ -1,38 +1,47 @@
 #include "mbed.h"
-#include "core.hpp"
+#include "scrp_slave.hpp"
+#include "sbdbt.hpp"
 
 int main(){
-    Robot main_robot(46,25.4,322.5,259.75);
-    ScrpSlave scrp(PC_12,PD_2 ,PH_1 ,0x0807f800);
-    Core rbt(&main_robot,&scrp,OMNI4,0.02);
-    
 //---------------初期設定---------------
-    //モータ
-    rbt.addMOT(PB_14,PB_13,2048,0);//モータ0
-    rbt.addMOT(PB_7,PB_6,2048,1);  //モータ1
-    rbt.addMOT(PB_9,PB_8,2048,2);  //モータ2
-    rbt.addMOT(PA_11,PB_1,2048,3); //モータ3
-    //エンコーダ
-    RBT.addENC(PC_4,PA_13,512,4,1);
-    RBT.addENC(PA_14,PA_15,512,4,2);
-    RBT.addENC(PC_2,PC_3,512,4,3);
-    RBT.addENC(PC_10,PC_11,512,4,4);
-    RBT.addENC(PA_7,PA_6,512,4,5);
-    RBT.addENC(PA_9,PA_8,512,4,6);
-    RBT.addENC(PC_1,PC_0,512,4,7);
-    RBT.addENC(PC_5,PA_12,512,4,8);
+    //scrp_slave
+    ScrpSlave scrp(PC_12,PD_2,PH_1,0x0807f800);
+    //sbdbt
+    sbdbt sb(A0,A1);     
+    //scrp_slaveのid設定
+    const int wheel_num = 255;
+    const int BeanbagGet_num = 2;
+    const int BeanbagShot_num = 3;
+    const int TakoGetPut_num = 4;
+    //コマンド番号設定
+    const int x_component_cmd = 1;
+    const int y_component_cmd = 2;
+    const int l2_cmd = 3;
+    const int r2_cmd = 4;
+    const int select = 5;
     //変数
-    bool auto = true;
-//------------------------------
-
-    rbt.START();
-    RBT.setPosition(0.0,0.0,0.0);
-    
-//---------------ループ---------------
+    int x_component;
+    int y_component;
+    int l2_num;
+    int r2_num;
+//-------------------------------------
+//スティックの返り値-128~127
     while(true){
-        rbt.getStatus();
-        
-        rbt.LOOP();
+        sb.button_state();
+        x_component = sb.lsx();
+        y_component = sb.lsy();
+        l2_num = sb.l2An();
+        r2_num = sb.r2An();
+        //printf("%d %d",x_component,y_component);
+        scrp.send1(wheel_num,x_component_cmd,x_component);
+        wait_ms(1);
+        scrp.send1(wheel_num,y_component_cmd,y_component);
+        wait_ms(1);
+        scrp.send1(wheel_num,l2_cmd,l2_num);
+        wait_ms(1);
+        scrp.send1(wheel_num,r2_cmd,r2_num);
+        wait_ms(1);
+        scrp.send1(wheel_num,select,sb.select());
+        wait_ms(1);
     }
-    
 }
\ No newline at end of file