2017ロボコンはやとブーメランプログラム
Dependencies: PID QEI ikarashiMDC recieveController omni
Diff: main.cpp
- Revision:
- 6:0bee4b2bb400
- Parent:
- 5:9c52e6c14c87
- Child:
- 7:baf16d0c14e7
--- a/main.cpp Wed Aug 30 03:44:00 2017 +0900 +++ b/main.cpp Fri Sep 01 10:42:27 2017 +0900 @@ -1,6 +1,8 @@ #include "mbed.h" #include "hayatoBoomerang.h" #include "recieveController.h" +#include "omni.h" + Serial rs485(PC_10,PC_11,38400); Serial serial(USBTX,USBRX); @@ -11,9 +13,6 @@ recieveController con(PA_0,PA_1,198); // Serial con(PA_0,PA_1,115200); -typedef struct { - char data[4]; -} mail_t; void init() { @@ -22,30 +21,59 @@ serial.baud(115200); //boom.calibrateArm(); boom.setTargetMotorSpeed(0); - boom.setTargetArmAngle(10); + boom.setTargetArmAngle(40); } void comm() { wait_ms(10); } +void updater() +{ + boom.update(); +} int main() { init(); + int angle = 5; char data[20],*data2,*data3; // commThread.start(&comm); + // ticker.attach(&updater,0.01); while(true) { - if(con.buttons[0] == 1024 ) + if(con.buttons[0] == 0x1000 ) + boom.fire(); + + if(con.buttons[0] == 0x1800 ) + { boom.fire(); + boom.setTargetMotorSpeed(8000); + }else if(con.buttons[0] == 0x800) + boom.setTargetMotorSpeed(8000); + else + boom.setTargetMotorSpeed(0); + + if(con.buttons[0] == 0x80) + angle += 10; + if(con.buttons[0] == 0x100) + angle -= 10; + + if(angle < 5){ + angle = 5; + } + if(angle > 80 ){ + angle = 80; + } + + boom.setTargetArmAngle(angle); + led = boom.beltSpeed; + boom.move(con.buttons[1],con.buttons[2],con.buttons[3]); boom.update(); - led = boom.beltSpeed; - wait_ms(50); - // printf("hi\n" ); + printf("SPPED:%f\n",boom.armAngle); + wait_ms(20); /* code */ con.update(); // printf("whats up\n" ); - serial.printf("circle:%d\n",con.buttons[0]); }