ジャパンオープン用のメインプログラム

Dependencies:   mbed AQM1602 HMC6352 PID

Committer:
lilac0112_1
Date:
Sun Mar 27 13:04:39 2016 +0000
Revision:
38:67bc78f3c0ab
Parent:
32:367b16d69a32
JapanSoccerOpen2016 CatPot Program(main)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lilac0112_1 0:ea35c18c85fc 1 #ifndef _MAIN_H_
lilac0112_1 0:ea35c18c85fc 2 #define _MAIN_H_
lilac0112_1 0:ea35c18c85fc 3
lilac0112_1 0:ea35c18c85fc 4 #include "def.h"
lilac0112_1 0:ea35c18c85fc 5
lilac0112_1 0:ea35c18c85fc 6 //pc(Computer)
lilac0112_1 0:ea35c18c85fc 7 RawSerial pc(monitor_tx, monitor_rx);
lilac0112_1 0:ea35c18c85fc 8 //led(main)
lilac0112_1 14:b510adcb6065 9 //DigitalOut LED[4]={led1, led2, led3, led4};
lilac0112_1 14:b510adcb6065 10 BusOut LED(led1, led2, led3, led4);
lilac0112_1 0:ea35c18c85fc 11 //line(bottom)
lilac0112_1 2:635947de1583 12 BusOut LineKeeper(lineInA, lineInB, lineInC);
lilac0112_1 2:635947de1583 13 BusIn LineRaw(lineA2, lineB2, lineC2);
lilac0112_1 2:635947de1583 14 BusIn LineHold(lineA1, lineB1, lineC1);
lilac0112_1 0:ea35c18c85fc 15 InterruptIn Line[3]={lineA2, lineB2, lineC2};
lilac0112_1 9:c966191926c5 16 InterruptIn LineHolding[3]={lineA1, lineB1, lineC1};
lilac0112_1 0:ea35c18c85fc 17 //ballcheck(bottom)
lilac0112_1 32:367b16d69a32 18 InterruptIn BallChecker(ballcheck);
lilac0112_1 0:ea35c18c85fc 19 AnalogIn BallCheckerA(ballcheck);
lilac0112_1 0:ea35c18c85fc 20 //debug_switch(debug_board)
lilac0112_1 0:ea35c18c85fc 21 DigitalIn Sw[4] = {selectsw1, selectsw2, debugsw1, debugsw2};
lilac0112_1 0:ea35c18c85fc 22 //motor(main)
lilac0112_1 0:ea35c18c85fc 23 Serial motor(motor_tx, motor_rx);
lilac0112_1 0:ea35c18c85fc 24 //spi(main)
lilac0112_1 0:ea35c18c85fc 25 SPI spi(SPI_mosi, SPI_miso, SPI_slck);
lilac0112_1 0:ea35c18c85fc 26 DigitalOut spi_ss[4]={SPI_ss_sd, SPI_ss_sonic, SPI_ss_color, SPI_ss_ir};
lilac0112_1 0:ea35c18c85fc 27 //bluetooth(debug_board)
lilac0112_1 0:ea35c18c85fc 28 RawSerial RN42(blue_rxd, blue_txd);
lilac0112_1 0:ea35c18c85fc 29 DigitalOut hmc_reset(blue_reset);
lilac0112_1 0:ea35c18c85fc 30 //lcd(debug_board)
lilac0112_1 0:ea35c18c85fc 31 AQM1602 Lcd(lcd_sda, lcd_scl);
lilac0112_1 0:ea35c18c85fc 32 //cmps(debug_board)
lilac0112_1 0:ea35c18c85fc 33 HMC6352 hmc(sens_sda, sens_scl);
lilac0112_1 0:ea35c18c85fc 34 //mouse(bottom)
lilac0112_1 0:ea35c18c85fc 35 adns_9800 mouse_sensor(mouse_mosi, mouse_miso, mouse_slck, mouse_ss);
lilac0112_1 0:ea35c18c85fc 36 //solenoid(bottom)
lilac0112_1 0:ea35c18c85fc 37 DigitalOut kicker(solenoid);
lilac0112_1 0:ea35c18c85fc 38
lilac0112_1 0:ea35c18c85fc 39 //Serial for motors
lilac0112_1 0:ea35c18c85fc 40 int speed[4]={0};
lilac0112_1 0:ea35c18c85fc 41 string StringFIN;
lilac0112_1 0:ea35c18c85fc 42 //PID
lilac0112_1 0:ea35c18c85fc 43 PID pid(P_GAIN,I_GAIN,D_GAIN, RATE);
lilac0112_1 21:378470320524 44 //Ticker pidupdate;
lilac0112_1 0:ea35c18c85fc 45 //for Serial
lilac0112_1 0:ea35c18c85fc 46 volatile uint8_t INdata[DATA_NUM]={0}, EXdata[DATA_NUM]={0};
lilac0112_1 0:ea35c18c85fc 47 //for DataSet
lilac0112_1 0:ea35c18c85fc 48 //Record data;
lilac0112_1 0:ea35c18c85fc 49 //NewStruct
lilac0112_1 0:ea35c18c85fc 50 CompassVal cmps_set;
lilac0112_1 2:635947de1583 51 SensorVal data;
lilac0112_1 0:ea35c18c85fc 52 SystemVal sys;
lilac0112_1 0:ea35c18c85fc 53 //for transition
lilac0112_1 0:ea35c18c85fc 54 Ticker Sw_ticker;
lilac0112_1 0:ea35c18c85fc 55 Timeout button;
lilac0112_1 0:ea35c18c85fc 56 bool state[4]={0,0,0,0};
lilac0112_1 0:ea35c18c85fc 57 uint8_t statesum=0, last_statesum=0;
lilac0112_1 0:ea35c18c85fc 58 // for Time
lilac0112_1 0:ea35c18c85fc 59 Ticker Motor_ticker;
lilac0112_1 30:5998ba42237e 60 //Ticker Line_ticker;
lilac0112_1 19:967207de919d 61 Ticker Info_ticker;
lilac0112_1 30:5998ba42237e 62 //Ticker Hmc_ticker;
lilac0112_1 27:825c6835e3db 63
lilac0112_1 27:825c6835e3db 64 //Timeout Line_timeout[3];
lilac0112_1 27:825c6835e3db 65 Timeout Line_reset;
lilac0112_1 21:378470320524 66
lilac0112_1 25:a7460e23e02e 67 Timeout Solenoid_timeout;
lilac0112_1 25:a7460e23e02e 68 Timeout Kick_stop;
lilac0112_1 13:b20921316f3c 69
lilac0112_1 24:34ef6379b0df 70 Timeout Turn_timeout;
lilac0112_1 24:34ef6379b0df 71 Timeout Turn_stop;
lilac0112_1 13:b20921316f3c 72
lilac0112_1 25:a7460e23e02e 73 Timeout Ball_judge;
lilac0112_1 25:a7460e23e02e 74
lilac0112_1 30:5998ba42237e 75 //Timeout Kick_now;
lilac0112_1 30:5998ba42237e 76 //Timeout Front_now;
lilac0112_1 27:825c6835e3db 77 //Timeout Line_home;
lilac0112_1 25:a7460e23e02e 78
lilac0112_1 0:ea35c18c85fc 79 Ticker Duty[DUTY_NUM];
lilac0112_1 0:ea35c18c85fc 80 Timeout Stp;
lilac0112_1 0:ea35c18c85fc 81 double dutycycle[DUTY_NUM] ={//[s]
lilac0112_1 0:ea35c18c85fc 82 0.2
lilac0112_1 0:ea35c18c85fc 83 };
lilac0112_1 0:ea35c18c85fc 84
lilac0112_1 0:ea35c18c85fc 85 #endif /*_MAIN_H_*/