Ryota Kotani / Mbed 2 deprecated ROS_R2_YONRIN

Dependencies:   mbed URF MD_MDDS30_oit_ ros_lib_melodic

Revision:
0:450a7208c682
diff -r 000000000000 -r 450a7208c682 URF_check.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/URF_check.txt	Tue May 03 08:02:58 2022 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "URF.h"
+
+Serial pc(USBTX, USBRX, 115200);
+
+URF usdRight(D6);
+URF usdLeft(D8);
+
+Ticker update;
+
+DigitalOut led(LED1);
+DigitalOut led2(PC_4);
+ 
+DigitalIn btn(USER_BUTTON);
+
+void inter(void)
+{
+    usdRight.send();
+    usdLeft.send();
+}
+
+void URF(int dataRight, int dataLeft){
+    if(dataRight>100 && dataRight<=230){
+        pc.printf("right slow\n");
+        //Yonrin(-0.3f, 0);
+        if(dataLeft>100 && dataLeft<=230){
+            pc.printf("left slow\n");
+            //Yonrin(0.3f, 0);
+        }
+        else if(dataLeft<=100){
+            pc.printf("left stop\n");
+            //Yonrin(0);
+        }
+    }
+    else if(dataRight<=100){
+        pc.printf("right stop\n");
+        //Yonrin(0);
+        if(dataLeft>100 && dataLeft<=230){
+            pc.printf("left slow\n");
+            //Yonrin(0.3f, 0);
+        }
+        else if(dataLeft<=100){
+            pc.printf("left stop\n");
+            //Yonrin(0);
+        }
+    }
+    else if(dataLeft>100 && dataLeft<=230){
+        pc.printf("left slow\n");
+        //Yonrin(0.3f, 0);
+        if(dataRight>100 && dataRight<=230){
+            pc.printf("right slow\n");
+            //Yonrin(-0.3f, 0);
+        }
+        else if(dataRight<=100){
+            pc.printf("right stop\n");
+            //Yonrin(0);
+        }
+    }
+    else if(dataLeft<=100){
+        pc.printf("left stop\n");
+        //Yonrin(0);
+        if(dataRight>100 && dataRight<=230){
+            pc.printf("right slow\n");
+            //Yonrin(-0.3f, 0);
+        }
+        else if(dataRight<=100){
+            pc.printf("right stop\n");
+            //Yonrin(0);
+        }
+    }
+}
+
+int main(){
+    pc.printf("check1\n");
+
+    update.attach(&inter, 0.06);
+
+    while(1){
+        int dataRight = usdRight.read(mm);
+        int dataLeft = usdLeft.read(mm);
+        //pc.printf("right: %d, left: %d\n", dataRight, dataLeft);
+        
+        if(dataRight<=230 || dataLeft<=230){
+            URF(dataRight,dataLeft);
+        }
+    }
+}
\ No newline at end of file