fep209 208
Dependencies: Controller ikarashiMDC
Revision 0:8f324e7a7491, committed 2019-03-07
- Comitter:
- THtakahiro702286
- Date:
- Thu Mar 07 07:50:15 2019 +0000
- Commit message:
- fep209 208
Changed in this revision
diff -r 000000000000 -r 8f324e7a7491 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Mar 07 07:50:15 2019 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r 8f324e7a7491 Controller.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Controller.lib Thu Mar 07 07:50:15 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/Controller/#875532e626ee
diff -r 000000000000 -r 8f324e7a7491 ikarashiMDC.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ikarashiMDC.lib Thu Mar 07 07:50:15 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/NHK-Robocon2016_Nagaoka_B_Team/code/ikarashiMDC/#ea34af94e90c
diff -r 000000000000 -r 8f324e7a7491 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 07 07:50:15 2019 +0000 @@ -0,0 +1,107 @@ +#include "mbed.h" +#include "ikarashiMDC.h" +#include "controller.h" +Controller pad(PC_10, PC_11, 208); +Serial pc(USBTX, USBRX, 115200); +Serial serial(PC_6,PC_7); +DigitalOut serialcontrol(D2); +DigitalOut stop(PB_12,PB_2); + +ikarashiMDC ikarashi[] { + ikarashiMDC(&serialcontrol,2,0,SM,&serial), + ikarashiMDC(&serialcontrol,2,1,SM,&serial), + ikarashiMDC(&serialcontrol,2,2,SM,&serial), + ikarashiMDC(&serialcontrol,2,3,SM,&serial) +}; + +int main() +{ + serial.baud(115200); + ikarashi[0].braking = true; + int button[11]; + float stickRadian[2],stickNorn[2]; + double acc[4]; + while(1){ + //コントローラー通信 + if(pad.receiveState()){ + for(int i = 0; i < 13; i++){ + button[i] = pad.getButton1(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("\n\r"); + + //十字移動 + if(button[2] == 1 && button[3] == 0 && button[4] == 1 && button[5] == 1){ + stickNorn[0] = 1; + stickRadian[0] = 1.570796; + }else if(button[2] == 0 && button[3] == 1 && button[4] == 1 && button[5] == 1){ + stickNorn[0] = 1; + stickRadian[0] = 0; + }else if(button[2] == 1 && button[3] == 1 && button[4] == 0 && button[5] == 1){ + stickNorn[0] = 1; + stickRadian[0] = 3.141593; + }else if(button[2] == 1 && button[3] == 1 && button[4] == 1 && button[5] == 0){ + stickNorn[0] = 1; + stickRadian[0] = -1.570796; + }else if(stickNorn[0] == 0 && button[7] == 1 && button[9] == 1) { + acc[0] = 0; + acc[1] = 0; + acc[2] = 0; + } + //全方位移動 + if(stickNorn[0] != 0){ + acc[0] = sin(stickRadian[0] - PI * 11 / 6); + acc[1] = sin(stickRadian[0] - PI * 1 / 2); + acc[2] = sin(stickRadian[0] - PI * 7 / 6); + } + //左右旋回 + if(button[9] == 0 && button[7] == 1 && stickNorn[0] == 0) { + acc[0] = -0.5; + acc[1] = -0.5; + acc[2] = -0.5; + } + if(button[7] == 0 && button[9] == 1 && stickNorn[0] == 0) { + acc[0] = 0.5; + acc[1] = 0.5; + acc[2] = 0.5; + } + //機構制御 + if(button[10] == 0 && button[8] == 1){ + acc[3] = -0.4; + } + if(button[8] == 0 && button[10] == 1){ + acc[3] = 0.4; + } + if(button[8] == button[10]) { + acc[3] = 0; + } + //減速 + if(button[0] == 0) { + for(int i = 0;i < 4;i++) { + if(acc[i] >= 0.5){ + acc[i] = 0.5; + } + if(acc[i] <= -0.5) { + acc[i] = -0.5; + } + } + } + pc.printf("%f %f %f %f",acc[0],acc[1],acc[2],acc[3]); + ikarashi[0].setSpeed(acc[0]); + ikarashi[1].setSpeed(acc[1]); + ikarashi[2].setSpeed(acc[2]); + ikarashi[3].setSpeed(acc[3]); + }else{ + pc.printf("error\n\r"); + ikarashi[0].setSpeed(acc[0]); + ikarashi[1].setSpeed(0); + ikarashi[2].setSpeed(0); + ikarashi[3].setSpeed(0); + } + } +}
diff -r 000000000000 -r 8f324e7a7491 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Mar 07 07:50:15 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#c9e63f14085f5751ff5ead79a7c0382d50a813a2