kourobo
Dependencies: Controller ikarashiMDC
Revision 3:e8f08f2be311, committed 2019-03-13
- Comitter:
- ec30109b
- Date:
- Wed Mar 13 05:26:53 2019 +0000
- Parent:
- 2:a583ad08d3d6
- Commit message:
- kourobo2019_nagaokaBteam
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r a583ad08d3d6 -r e8f08f2be311 main.cpp --- a/main.cpp Sat Mar 09 08:39:58 2019 +0000 +++ b/main.cpp Wed Mar 13 05:26:53 2019 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "ikarashiMDC.h" #include "controller.h" +#define PI 3.141592653589 Serial serial(PC_6, PC_7); DigitalOut serialcontrol(D2); @@ -43,63 +44,64 @@ if(pad.receiveState()){ for(int i = 0; i < 13; i++){ button[i] = pad.getButton1(i); - pc.printf("%d ", button[i]); + // pc.printf("%d ", button[i]); } for(int i = 0; i < 2; i++){ stickRadian[i] = pad.getRadian(i); stickNorn[i] = pad.getNorm(i); - pc.printf("%f %f\t", stickRadian[i], stickNorn[i]); + //pc.printf("%f %f\t", stickRadian[i], stickNorn[i]); } //足回り if(stickNorn[0] != 0){ - SPe[0] = sin(change(stickRadian[0]) - PI * 7/4); - SPe[1] = sin(change(stickRadian[0]) - PI * 1/4); - SPe[2] = sin(change(stickRadian[0]) - PI * 3/4); - SPe[3] = sin(change(stickRadian[0]) - PI * 5/4); + SPe[0] = sin(change(stickRadian[0]) - PI * 1/4); + SPe[1] = sin(change(stickRadian[0]) - PI * 7/4); + SPe[2] = sin(change(stickRadian[0]) - PI * 5/4); + SPe[3] = sin(change(stickRadian[0]) - PI * 3/4); + } //微調整 - if((button[0] == button[1] == button[2] == button[3] == button[4] == button[5] == button[7] == button[8]) && stickNorn[0] == 0){ + if((button[0] == 1 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1) && stickNorn[0] == 0){ SPe[0] = 0; SPe[1] = 0; SPe[2] = 0; SPe[3] = 0; } - if(button[3] == 0 && button[0] == button[1] == button[2] == button[4] == button[5] == button[7] == button[8]){ //前 + if(button[3] == 0 && button[0] == 1 && button[1] == 1 && button[2] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ //前 SPe[0] = 0.4; SPe[1] = 0.4; SPe[2] = -0.4; SPe[3] = -0.4; } - if(button[5] == 0 && button[0] == button[1] == button[2] == button[3] == button[4] == button[7] == button[8]){ //後ろ + if(button[5] == 0 && button[0] == 1 == button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[7] == 1 && button[8] == 1){ //後ろ SPe[0] = -0.4; SPe[1] = -0.4; SPe[2] = 0.4; SPe[3] = 0.4; } - if(button[4] == 0 && button[0] == button[1] == button[2] == button[3] == button[5] == button[7] == button[8]){ //右 - SPe[0] = -0.4; - SPe[1] = 0.4; - SPe[2] = -0.4; - SPe[3] = 0.4; + if(button[4] == 0 && button[0] == 1 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ //右 + SPe[0] = -0.5; + SPe[1] = 0.3; + SPe[2] = 0.3; + SPe[3] = -0.4; } - if(button[2] == 0 && button[0] == button[1] == button[3] == button[4] == button[5] == button[7] == button[8]){ //左 - SPe[0] = 0.4; - SPe[1] = -0.4; - SPe[2] = 0.4; - SPe[3] = -0.4; + if(button[2] == 0 && button[0] == 1 && button[1] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ //左 + SPe[0] = 0.5; + SPe[1] = -0.3; + SPe[2] = -0.3; + SPe[3] = 0.4; } //右回転 - if(button[7] == 0 && button[0] == button[1] == button[2] == button[3] == button[4] == button[5] == button[8]){ + if(button[7] == 0 && button[0] == 1 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[8] == 1){ SPe[0] = -0.4; SPe[1] = -0.4; SPe[2] = -0.4; SPe[3] = -0.4; } //左回転 - if(button[8] == 0 && button[0] == button[1] == button[2] == button[3] == button[4] == button[5] == button[7]){ + if(button[8] == 0 && button[0] == 1 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1){ SPe[0] = 0.4; SPe[1] = 0.4; SPe[2] = 0.4; @@ -107,17 +109,21 @@ } //機構 - if(button[0] == button[1] == button[2] == button[3] == button[4] == button[5] == button[7] == button[8] == 1){ + if(button[0] == 1 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ ikarashi[4].setSpeed(0); } - if(button[1] == 0 && button[0] == button[2] == button[3] == button[4] == button[5] == button[7] == button[8]){ //閉じる - ikarashi[4].setSpeed(-0.15); + else if(button[1] == 0 && button[0] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ //閉じる + ikarashi[4].setSpeed(-0.17); } - if(button[0] == 0 && button[1] == button[2] == button[3] == button[4] == button[5] == button[7] == button[8]){ //開く - ikarashi[4].setSpeed(0.15); + else if(button[0] == 0 && button[1] == 1 && button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 1 && button[7] == 1 && button[8] == 1){ //開く + ikarashi[4].setSpeed(0.17); } + else{ + ikarashi[4].setSpeed(0); + } + ikarashi[0].setSpeed(SPe[0]); @@ -125,14 +131,14 @@ ikarashi[2].setSpeed(SPe[2]); ikarashi[3].setSpeed(SPe[3]); - pc.printf("%.2f ",SPe[0]); - pc.printf("%.2f ",SPe[1]); - pc.printf("%.2f ",SPe[2]); - pc.printf("%.2f ",SPe[3]); + //pc.printf("%.2f ",SPe[0]); +// pc.printf("%.2f ",SPe[1]); +// pc.printf("%.2f ",SPe[2]); +// pc.printf("%.2f ",SPe[3]); - pc.printf("%.3f ",change(stickRadian[0])); + //pc.printf("%.3f ",change(stickRadian[0])); - pc.printf("\r\n"); + // pc.printf("\r\n"); }else{ pc.printf("error\n\r");
diff -r a583ad08d3d6 -r e8f08f2be311 mbed-os.lib --- a/mbed-os.lib Sat Mar 09 08:39:58 2019 +0000 +++ b/mbed-os.lib Wed Mar 13 05:26:53 2019 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2 +https://github.com/ARMmbed/mbed-os/#51d55508e8400b60af467005646c4e2164738d48