NHK2019ROBOCON team A manual robot program 9/28 version
Dependencies: mbed 2019ROBOKONmanualProgram
Diff: main.cpp
- Revision:
- 3:82008ebeb93c
- Parent:
- 2:830db42bae7e
--- a/main.cpp Tue Sep 17 08:54:21 2019 +0000 +++ b/main.cpp Fri Sep 27 23:53:04 2019 +0000 @@ -32,7 +32,6 @@ DigitalOut led1(LED1); Timer timer; Timer timer2; -Timer timer3; //変数 char data1;//右上 @@ -102,9 +101,9 @@ void send_data(char address,char data); void emergency(); void change_rack_2(); -//void sequence_kaisyu(); -void kaisyu(); -void kaisyu_short(); +void sequence_kaisyu(); +//void kaisyu(); +//void sequence_kaisyu_short(); //void sequence_hakidashi(); void hakidashi(); void mode_change(); @@ -126,9 +125,9 @@ change_data(); //change_rack(); change_rack_2(); - //sequence_kaisyu(); - kaisyu(); - kaisyu_short(); + sequence_kaisyu(); + //kaisyu(); + //sequence_kaisyu_short(); //sequence_hakidashi(); hakidashi(); change_fan(); @@ -191,7 +190,11 @@ send_data(0x40,data10); } - timer.reset(); + /*data_servo=0x03; + send_data(0x18,data_servo); + data_servo=0x04; + send_data(0x18,data_servo);*/ + timer2.reset(); } @@ -217,6 +220,7 @@ hidari1=ps3.getButtonState(hidari); migi1=ps3.getButtonState(migi); get_data_rs232=slave.getc(); + if(get_data_rs232) { @@ -263,6 +267,10 @@ if(q==0){ //送風モード q=1; + /* data_servo=0x03; + send_data(0x18,data_servo); + data_servo=0x04; + send_data(0x18,data_servo);*/ data10=0xcf; send_data(0x40,data10); }else if(q==1){ @@ -606,6 +614,11 @@ if(ue1==1&&start==0){ data5=0x00; data6=0xff; + + /*data_servo=0x03; + send_data(0x18,data_servo); + data_servo=0x04; + send_data(0x18,data_servo);*/ } }else if(shita!=old_shita){ old_shita=shita; @@ -635,18 +648,19 @@ } //回収機構 -/* + void sequence_kaisyu() { if(q==0){ if(square!=old_square) { old_square=square; - if(square==1) { - + if(square==1&&select==0) { + data_servo=0x07; send_data(0x18,data_servo); - wait(1.5); + wait(1.3); data7=0x00; + get_data_rs232=get_data_rs232 & 0b11101111; while(!(get_data_rs232 & 0x10)) { send_data(0x24,data7); get_data_rs232=slave.getc(); @@ -655,22 +669,46 @@ send_data(0x24,data7); data_servo=0x08; send_data(0x18,data_servo); - wait(1.5); + wait(1.3); data7=0xff; + get_data_rs232=get_data_rs232 & 0b11011111; while(!(get_data_rs232 & 0x20)) { send_data(0x24,data7); get_data_rs232=slave.getc(); } data7=0x10; send_data(0x24,data7); - + + } + }else if(triangle!=old_triangle){ + if(triangle==1&&select==0){ + + data_servo=0x07; + send_data(0x18,data_servo); + wait(1.3); + data7=0x00; + send_data(0x24,data7); + wait(0.3); + data7=0x10; + send_data(0x24,data7); + data_servo=0x08; + send_data(0x18,data_servo); + wait(1.3); + data7=0xff; + get_data_rs232=get_data_rs232 & 0b11011111; + while(!(get_data_rs232 & 0x20)) { + send_data(0x24,data7); + get_data_rs232=slave.getc(); + } + data7=0x10; + send_data(0x24,data7); } } } } -*/ +/* void kaisyu(){ if(q==0){ if(old_square!=square){ @@ -730,7 +768,7 @@ } } } - +*/ /* void sequence_hakidashi() @@ -775,12 +813,43 @@ } */ +/* +void sequence_kaisyu_short(){ + if(q==0){ + if(old_triangle!=triangle){ + old_triangle=triangle; + if(triangle==1){ + + data_servo=0x07; + send_data(0x18,data_servo); + wait(1.3); + data7=0x00; + send_data(0x24,data7); + wait(0.3); + data7=0x10; + send_data(0x24,data7); + data_servo=0x08; + send_data(0x18,data_servo); + wait(1.3); + data7=0xff; + get_data_rs232=get_data_rs232 & 0x; + while(!(get_data_rs232 & 0x20)) { + send_data(0x24,data7); + get_data_rs232=slave.getc(); + } + data7=0x10; + send_data(0x24,data7); + + } + } + } +}*/ void hakidashi(){ if(q==0){ if(old_migi1!=migi1){ old_migi1=migi1; - if(migi1==1){ + if(migi1==1&&select==0){ r=1; } } @@ -847,63 +916,7 @@ } } -void kaisyu_short(){ - if(q==0){ - if(triangle!=old_triangle){ - old_triangle=triangle; - if(triangle==1){ - s=1; - } - } - - switch(s){ - case 1: - data_servo=0x07; - send_data(0x18,data_servo); - timer3.start(); - if(timer3.read()>3.5){ - timer3.stop(); - timer3.reset(); - s=2; - } - break; - - case 2: - data7=0x00; - send_data(0x24,data7); - timer3.start(); - if(timer3.read()>0.5){ - data7=0x10; - send_data(0x24,data7); - s=3; - } - break; - - case 3: - data_servo=0x08; - send_data(0x18,data_servo); - timer3.start(); - if(timer3.read()>1.3){ - s=4; - } - break; - - case 4: - data7=0xff; - send_data(0x24,data7); - if(get_data_rs232 & 0x20){ - data7=0x10; - send_data(0x24,data7); - s=5; - } - break; - - default: - s=5; - break; - } - } -} + //ファン void change_fan() @@ -945,9 +958,6 @@ } - - - //i2c void send_data(char address,char data) {