sub2 MDC and enc
Dependencies: 2022_NHK_B_canTR FEP_RX22 QEI ikarashiMDC_2byte_ver mbed HOSOKIkikou R1370 SEKIkikou
Diff: main.cpp
- Revision:
- 7:4e43530672df
- Parent:
- 6:b426dcaa7c78
- Child:
- 8:cccc03be9714
--- a/main.cpp Wed Oct 12 00:24:34 2022 +0000 +++ b/main.cpp Thu Oct 13 03:23:21 2022 +0000 @@ -5,7 +5,7 @@ #include "QEI.h" #include "can_tr.h" #include "HOSOKIkikou.h" -#include "SEKIkikou.h" +//#include "SEKIkikou.h" #include "R1370.h" FEP_RX22 mycon(fepTX, fepRX, fepad); @@ -71,15 +71,19 @@ // mycon.StartReceive(); led = 1; pc.printf("success!\r\n"); - int bc=0,bn=0; - int currentMode=1; - HOSOKIkikou hosoki(&motor[6],&motor[7], &motor[4], &motor[5], &b[0], &b[1], &b[2], &b[3], &encoderValue[2], &encoderValue[3]); + + for(int i=0; i < 8; i++){ + motor[i].setSpeed(0); + } +// int bc=0,bn=0; +// int currentMode=1; + HOSOKIkikou hosoki(&motor[6],&motor[7], &motor[4], &motor[5], &b[4], NULL, NULL, NULL, NULL, NULL); while(1) { // recieveController(); Reset=0; updateenc(); updatejyro(); - + /* bc=b[7]-bn; bn=b[7]; @@ -104,13 +108,14 @@ hosoki.runAll(-0.9,0.9,0.3,0.3); } } + */ canTR(); - - if(stick[2]>100||stick[2]<-100||stick[3]>100||stick[3]<-100){//機構回転 - if(stick[2]>100){ - motorSpeed[1] = 0.8; - }else if(stick[2]<-100){ - motorSpeed[1] = -0.8; + /* + if(stick[2]>80||stick[2]<-80||stick[3]>80||stick[3]<-80){//機構回転 + if(stick[2]>80){ + motorSpeed[1] = 0.5; + }else if(stick[2]<-80){ + motorSpeed[1] = -0.5; } if(stick[3]>100){ motorSpeed[2] = 0.8; @@ -120,30 +125,35 @@ } else { motorSpeed[2]=0; motorSpeed[1]=0; - } + }*/ + hosoki.runAll(-0.9,0.9,0,0); +// for(int i=1; i < 3; i++){ +// motor[i].setSpeed(motorSpeed[i]); +// } - for(int i=1; i < 3; i++){ - motor[i].setSpeed(motorSpeed[i]); + pc.printf("|wheel: "); + for(int i=8; i < 12; i++){ + pc.printf("%.2f ",motorSpeed[i]); } - + pc.printf("|spin: %.2f ",motorSpeed[1]); + pc.printf("|updown: %.2f ",motorSpeed[2]); + pc.printf("|enc: "); + for(int i=0; i < 7; i++){ + pc.printf("%d ",encoderValue[i]); + + } + pc.printf("| "); + pc.printf("R1370:%.3f",jyroValue); + pc.printf("| "); for(int i=0; i < 8; i++){ - pc.printf("%d ",b[i]); + pc.printf("%d ",b[i]); } pc.printf("| "); for(int i=0; i < 4; i++){ pc.printf("%d ",stick[i]); } - pc.printf("| "); - for(int i=2; i < 15; i++){ - pc.printf("%.3f ",motorSpeed[i]); - } - pc.printf("| "); - for(int i=0; i < 12; i++){ - pc.printf("%d ",encoderValue[i]); - } - pc.printf("| "); - pc.printf("%.4f\r\n",jyroValue); + pc.printf("\r\n"); } } \ No newline at end of file