かいださん機体 高田くん仕様キー

Dependencies:   mbed

Fork of 2016_Spring_kaida by 新部内対抗5班

Files at this revision

API Documentation at this revision

Comitter:
atsushika
Date:
Thu Jun 09 11:49:20 2016 +0000
Parent:
12:b2f3c85cba36
Commit message:
????????????????

Changed in this revision

KaidaKari.cpp Show diff for this revision Revisions of this file
Kaida_taka.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/KaidaKari.cpp	Sat Jun 04 09:06:29 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-#include "Utils.h"
-#include "USBHost.h"
-#include "hci.h"
-#include "ps3.h"
-#include "User.h"
-
-#include "mbed.h"
-
-int RSX,RSY,LSX,LSY,BSU,BSL;
-//これより下に関数外に書く要素を記入する
-PwmOut led1(LED1);
-PwmOut led2(LED2);
-DigitalOut led3(LED3);
-DigitalOut led4(LED4);
-
-//MD1
-PwmOut motorRightOne (p24);
-PwmOut motorRightTwo (p23);
-
-//MD2
-PwmOut motorLeftOne (p22);
-PwmOut motorLeftTwo (p21);
-
-//MD3 Arm1
-PwmOut armOneJun(p25);
-DigitalOut chocolateOne (p6);
-DigitalOut chocolateTwo (p5);
-
-//MD4 Arm2
-PwmOut armTwoTaka(p26);
-DigitalOut brownieOne (p29);
-DigitalOut brownieTwo (p30);
-
-
-/*
-
-PWM->0.xxx
-Digitals->0 and 0.xxx
-for arms(I guess...)
-
-For lergs, turn right or left, and just going go and back.->Probably using sticks.
-How to cha ge speed? Two different tyes of speed.
-
-Wow, Taka-chan will do one of the machine. He wants to do with the angles. Plus I don't understand what they are talking about!!
-Left stick, speed and right/left
-Push button and max incline -> the max speed
-Just max incline -> usual speed
-Little incline -> slow speed
-
-L1/R2 -> turning?
-
-Lifting ->
-
-*/
-
-
-
-void UserLoopSetting()
-{
-    //一度だけ行いたい初期設定をここに書く
-    /*
-    I need to ask what to do with this!
-    Actually, do we have any LEDs?
-    */
-    led1.period_ms(20);
-    led3=1;
-}
-
-void UserLoop(char n,const u8* data)
-{
-    u16 ButtonState;
-    if(n==0) { //有線Ps3USB.cpp
-        RSX = ((ps3report*)data)->RightStickX;
-        RSY = ((ps3report*)data)->RightStickY;
-        LSX = ((ps3report*)data)->LeftStickX;
-        LSY = ((ps3report*)data)->LeftStickY;
-        BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff);
-        BSL = (u8)(((ps3report*)data)->ButtonState >> 8);
-        //ボタンの処理
-        ButtonState =  ((ps3report*)data)->ButtonState;
-    } else {//無線TestShell.cpp
-        RSX = ((ps3report*)(data + 1))->RightStickX;
-        RSY = ((ps3report*)(data + 1))->RightStickY;
-        LSX = ((ps3report*)(data + 1))->LeftStickX;
-        LSY = ((ps3report*)(data + 1))->LeftStickY;
-        BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff);
-        BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8);
-        //ボタンの処理
-        ButtonState =  ((ps3report*)(data + 1))->ButtonState;
-    }
-    //ここより下にプログラムを書く
-
-//足回り
-    /*
-     double thesOne = 64;
-     double thesTwo = 127;
-     double thesThree = 191;
-     double fastSpeed = 1;
-     double slowSpeed = 0.5;
-     */
-
-    if(RSY>140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) {//forward
-        motorRightOne = 0.4;
-        motorRightTwo = 0;
-        motorLeftOne = 0.4;
-        motorLeftTwo = 0;
-    } else if(RSY>140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 0) {//turn right
-        motorRightOne = 0.4;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4;
-    } else if(RSY>140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 1) {//turn left
-        motorRightOne = 0;
-        motorRightTwo = 0.4;
-        motorLeftOne = 0.4;
-        motorLeftTwo = 0;
-    } else if(RSY>140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) {//forward
-        motorRightOne = 0.4;
-        motorRightTwo = 0;
-        motorLeftOne = 0.4;
-        motorLeftTwo = 0;
-    } else if(RSY<110 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) { //back
-        motorRightOne = 0;
-        motorRightTwo = 0.4;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4;
-    } else if (RSY<110 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 0) { //turn right
-        motorRightOne = 0.4;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4;
-    } else if(RSY<110 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 1) {//turn left
-        motorRightOne = 0;
-        motorRightTwo = 0.4;
-        motorLeftOne = 0.4;
-        motorLeftTwo = 0;
-    } else if (RSY<110 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) {//back
-        motorRightOne = 0;
-        motorRightTwo = 0.4;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4;
-    } else if(RSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) {//stop
-        motorRightOne = 0;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0;
-    } else if(RSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) ==1  && ((ButtonState >> BUTTONR1)&1) == 0) { //turn right
-        motorRightOne = 0.4;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4;
-    } else if(RSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) ==0  && ((ButtonState >> BUTTONR1)&1) == 1) { //turn left
-        motorRightOne = 0;
-        motorRightTwo = 0.4;
-        motorLeftOne = 0.4;
-        motorLeftTwo = 0;
-    } else if(RSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) { //stop
-        motorRightOne = 0;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0;
-    }else{
-        motorRightOne = 0;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0;
-        }
-
-    if(((ButtonState >> BUTTONCIRCLE)&1) == 1 && ((ButtonState >> BUTTONCROSS)&1) == 0) { //つかむか放す
-        chocolateOne = 0.1;
-        chocolateTwo = 0;
-        brownieOne = 0.1;
-        brownieOne = 0;
-    } else if (((ButtonState >> BUTTONCIRCLE)&1) == 0 && ((ButtonState >> BUTTONCROSS)&1) == 1) {
-        chocolateOne = 0;
-        chocolateTwo = 0.1;
-        brownieOne = 0;
-        brownieOne = 0.1;
-    } else {
-        chocolateOne = 0;
-        chocolateTwo = 0;
-        brownieOne = 0;
-        brownieOne = 0;
-    };
-
-
-
-
-
-
-
-    /*
-    With oen if, put both arms and legs.
-
-    Use start and select??
-
-
-    */
-
-    //データ取得例
-
-    if((ButtonState >> BUTTONCIRCLE)&1) {
-        //○が押されたとき
-    }
-
-
-    led1=RSX/256.0f;
-    led2=RSY/256.0f;
-    /*
-        led3=ButtonState & 0x0400;  //L1の状態
-        led4=ButtonState & 0x0800;  //R1の状態
-      */  //値の取得はps3.hを参照
-
-
-
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kaida_taka.cpp	Thu Jun 09 11:49:20 2016 +0000
@@ -0,0 +1,293 @@
+#include "Utils.h"
+#include "USBHost.h"
+#include "hci.h"
+#include "ps3.h"
+#include "User.h"
+
+#include "mbed.h"
+
+int RSX,RSY,LSX,LSY,BSU,BSL;
+//これより下に関数外に書く要素を記入する
+/*PwmOut led1(LED1);
+PwmOut led2(LED2);
+DigitalOut led3(LED3); 
+DigitalOut led4(LED4);
+*/
+
+
+
+
+
+
+//MD1
+
+PwmOut motorRightOne (p26);
+PwmOut motorRightTwo (p25);
+
+//MD2
+PwmOut motorLeftOne (p23);
+PwmOut motorLeftTwo (p24);
+
+//MD3 Arm1
+PwmOut armOneJun(p21);
+DigitalOut chocolateOne (p19);
+DigitalOut chocolateTwo (p20);
+
+//MD4 Arm2
+PwmOut armTwoTaka(p22);
+DigitalOut brownieOne (p29);
+DigitalOut brownieTwo (p30);
+ 
+
+/*
+//momoi
+
+//MD1
+
+PwmOut motorRightOne (p23);
+PwmOut motorRightTwo (p24);
+
+//MD2
+PwmOut motorLeftOne (p21);
+PwmOut motorLeftTwo (p22);
+
+//MD3 Arm1
+PwmOut armOneJun(p26);
+DigitalOut chocolateOne (p30);
+DigitalOut chocolateTwo (p29);
+
+//MD4 Arm2
+PwmOut armTwoTaka(p25);
+DigitalOut brownieOne (p6);
+DigitalOut brownieTwo (p5);
+
+*/
+
+
+
+
+
+
+/*
+
+PWM->0.xxx 
+Digitals->0 and 0.xxx
+for arms(I guess...)
+
+For lergs, turn right or left, and just going go and back.->Probably using sticks.
+How to cha ge speed? Two different tyes of speed.
+
+Wow, Taka-chan will do one of the machine. He wants to do with the angles. Plus I don't understand what they are talking about!!
+Left stick, speed and right/left
+Push button and max incline -> the max speed
+Just max incline -> usual speed
+Little incline -> slow speed
+
+L1/R2 -> turning?
+
+Lifting ->
+
+*/
+
+
+
+void UserLoopSetting()
+{
+    //一度だけ行いたい初期設定をここに書く
+    /*
+    I need to ask what to do with this!
+    Actually, do we have any LEDs?
+    */
+ /*   led1.period_ms(20);
+    led3=1;
+*/
+
+}
+
+void UserLoop(char n,const u8* data)
+{
+    u16 ButtonState;
+    if(n==0) { //有線Ps3USB.cpp
+        RSX = ((ps3report*)data)->RightStickX;
+        RSY = ((ps3report*)data)->RightStickY;
+        LSX = ((ps3report*)data)->LeftStickX;
+        LSY = ((ps3report*)data)->LeftStickY;
+        BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff);
+        BSL = (u8)(((ps3report*)data)->ButtonState >> 8);
+        //ボタンの処理
+        ButtonState =  ((ps3report*)data)->ButtonState;
+    } else {//無線TestShell.cpp
+        RSX = ((ps3report*)(data + 1))->RightStickX;
+        RSY = ((ps3report*)(data + 1))->RightStickY;
+        LSX = ((ps3report*)(data + 1))->LeftStickX;
+        LSY = ((ps3report*)(data + 1))->LeftStickY;
+        BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff);
+        BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8);
+        //ボタンの処理
+        ButtonState =  ((ps3report*)(data + 1))->ButtonState;
+    }
+    //ここより下にプログラムを書く
+
+//足回り
+    /*
+     double thesOne = 64;
+     double thesTwo = 127;
+     double thesThree = 191;
+     double fastSpeed = 1;
+     double slowSpeed = 0.5;
+     */
+     
+     
+     
+     
+     
+    if(LSY>140 && ((ButtonState >> BUTTONLANALOG)&1) == 1) {
+         motorRightOne = 0.8;
+        motorRightTwo = 0;
+        motorLeftOne = 0.8;
+        motorLeftTwo = 0;
+    } else if(LSY<110 && ((ButtonState >> BUTTONLANALOG)&1) == 1) {
+         motorRightOne = 0;
+        motorRightTwo = 0.8;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.8;         
+     
+   } else if(LSY>140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) {//forward
+        motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    } else if(LSY>140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 0) {//turn right
+        motorRightOne = 0;
+        motorRightTwo = 0.4;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    } else if(LSY>140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 1) {//turn left
+        motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.4;
+    }else if(LSY>140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) {//forward
+        motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    } else if(LSY<110 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) { //back
+        motorRightOne = 0;
+        motorRightTwo = 0.4;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.4;
+    } else if (LSY<110 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 0) { //turn right
+        motorRightOne = 0;
+        motorRightTwo = 0.4;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    } else if(LSY<110 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 1) {//turn left
+        motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.4;
+    }else if (LSY<110 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) {//back
+        motorRightOne = 0;
+        motorRightTwo = 0.4;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.4;
+    } else if(LSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) == 0 && ((ButtonState >> BUTTONR1)&1) == 0) {//stop
+        motorRightOne = 0;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0;
+    } else if(LSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) ==1  && ((ButtonState >> BUTTONR1)&1) == 0) { //turn right
+        motorRightOne = 0;
+        motorRightTwo = 0.4;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    } else if(LSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) ==0  && ((ButtonState >> BUTTONR1)&1) == 1) { //turn left
+        motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.4;
+    } else if(LSY>=110 && RSY<= 140 && ((ButtonState >> BUTTONL1)&1) == 1 && ((ButtonState >> BUTTONR1)&1) == 1) { //stop
+        motorRightOne = 0;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0;
+    }else{
+        motorRightOne = 0;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0;
+        }
+
+    if(((ButtonState >> BUTTONDOWN)&1) == 1 && ((ButtonState >> BUTTONUP)&1) == 0) { 
+        armOneJun = 0.4;
+        chocolateOne = 1;
+        chocolateTwo = 0;
+    } else if (((ButtonState >> BUTTONDOWN)&1) == 0 && ((ButtonState >> BUTTONUP)&1) == 1) {
+        armOneJun = 0.8;
+        chocolateOne = 0;
+        chocolateTwo = 1;
+    } else {
+        armOneJun = 0;
+        chocolateOne = 0;
+        chocolateTwo = 0;
+    }
+    
+    
+    if( ((ButtonState >> BUTTONTRIANGEL)&1) == 1 && ((ButtonState >> BUTTONCROSS)&1) == 0 ) { //つかむか放す
+        armTwoTaka = 0.2;
+        brownieOne = 1;
+        brownieTwo = 0;
+    } else if ( ((ButtonState >> BUTTONTRIANGEL)&1) == 0 && ((ButtonState >> BUTTONCROSS)&1) == 1 ) {
+        armTwoTaka = 0.2;
+        brownieOne = 0;
+        brownieTwo = 1;
+    } else {
+        armTwoTaka = 0;
+        brownieOne = 0;
+        brownieTwo = 0;
+    }
+/*
+      
+
+if((ButtonState >> BUTTONCIRCLE)&1) {
+      motorRightOne = 0.4;
+        motorRightTwo = 0;
+        motorLeftOne = 0.4;
+        motorLeftTwo = 0;
+    }else{
+      motorRightOne = 0;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0;
+    }
+*/
+
+    /*
+    With oen if, put both arms and legs.
+
+    Use start and select??
+
+
+    */
+
+    //データ取得例
+
+    if((ButtonState >> BUTTONCIRCLE)&1) {
+        //○が押されたとき
+    }
+/*
+
+    led1=RSX/256.0f;
+    led2=RSY/256.0f;
+    
+    
+    */
+    /*
+        led3=ButtonState & 0x0400;  //L1の状態
+        led4=ButtonState & 0x0800;  //R1の状態
+      */  //値の取得はps3.hを参照
+
+
+
+}
\ No newline at end of file