2021 NHK B syudo

Dependencies:   2021Bcon omni_wheel ikarashiMDC_2byte_ver Servo_softpwm NHK2021_ikarashiSV

Files at this revision

API Documentation at this revision

Comitter:
nagix
Date:
Wed Oct 20 08:30:14 2021 +0000
Parent:
2:e7910c124624
Commit message:
Servo tuika

Changed in this revision

NHK2021_ikarashiSV.lib Show annotated file Show diff for this revision Revisions of this file
Servo_softpwm.lib 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
pinconfig.h Show annotated file Show diff for this revision Revisions of this file
diff -r e7910c124624 -r a564d484cd4a NHK2021_ikarashiSV.lib
--- a/NHK2021_ikarashiSV.lib	Sun Oct 17 10:04:20 2021 +0000
+++ b/NHK2021_ikarashiSV.lib	Wed Oct 20 08:30:14 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/NHK2021_ikarashiSV/#696f7c0ab1bd
+https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/NHK2021_ikarashiSV/#1fc2008f3a07
diff -r e7910c124624 -r a564d484cd4a Servo_softpwm.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo_softpwm.lib	Wed Oct 20 08:30:14 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/ikarashikota/code/Servo_softpwm/#39d683a34a55
diff -r e7910c124624 -r a564d484cd4a main.cpp
--- a/main.cpp	Sun Oct 17 10:04:20 2021 +0000
+++ b/main.cpp	Wed Oct 20 08:30:14 2021 +0000
@@ -6,6 +6,7 @@
 #include "controller.h"
 #include "pinconfig.h"
 #include "omni_wheel.h"
+#include "Servo.h"
 #include "math.h"
 
 #define PI 3.141592653589
@@ -30,7 +31,9 @@
     ikarashiMDC(1,1,SM,&RS485),/*腕前後*/
 };
 
-ikarashiSV slv(PC_7,PB_10,PB_4,PB_5);
+ikarashiSV slv(slv1,slv2,slv3,slv4);
+
+Servo servo(Servo_Pin);
 
 OmniWheel omni(4);
 
@@ -52,8 +55,10 @@
 double speed[6];
 double spin_power;
 
+int val;
 
-//int i=0;
+servo.calibrate(0.00095, 90);
+servo.write(0);
 
 omni.wheel[0].setRadian(PI * 1.0 / 4.0);
 omni.wheel[1].setRadian(PI * 3.0 / 4.0);
@@ -127,7 +132,29 @@
         }
 
         for(int i=0; i<6; i++) motor[i].setSpeed(speed[i]);
+        
+        if(b[4]==1 || b[6]==1 || b[5]==1){
+            
+            b[6] += 1;
+            b[5] = 0;
+            
+//            val = slv.state_show();
+//            pc.printf("\t\tstate : %d",val);
+            if(b[4] >= 1) {    /*腕上げ*/
+                slv.solenoid(b[4]);
+            }else if(b[6] >= 2){    /*腕下げ*/
+                slv.solenoid(b[6]);
+            }else if(b[5] == 0){
+                slv.solenoid(b[5]); /*元に戻る*/
+            }
+//            slv.solenoid_show();
+        }
 
+        if(b[7] != 0){
+            servo.write(0.3);
+        }else{
+            servo.write(0);
+        }
         /*
         if(b[0]==1){
             motor[0].setSpeed(0.3);
diff -r e7910c124624 -r a564d484cd4a pinconfig.h
--- a/pinconfig.h	Sun Oct 17 10:04:20 2021 +0000
+++ b/pinconfig.h	Wed Oct 20 08:30:14 2021 +0000
@@ -20,6 +20,15 @@
 static PinName const sda = PB_9;
 static PinName const scl = PB_8;
 
+/*slv*/
+static PinName const slv1 = PC_7;
+static PinName const slv2 = PB_10;
+static PinName const slv3 = PB_4;
+static PinName const slv4 = PB_5;
+
+/*servo*/
+static PinName const Servo_Pin = PB_14;
+
 /*emergency_stop*/
 static PinName const em_stop = PA_5;
 #endif
\ No newline at end of file