Ryo Ogata
/
jumpROBO6_2_1
kairyou sita
Fork of jumpROBO6_2 by
main.h@0:4c7c138f3891, 2013-10-19 (annotated)
- Committer:
- OGA
- Date:
- Sat Oct 19 04:50:26 2013 +0000
- Revision:
- 0:4c7c138f3891
- Child:
- 1:b81c22891370
10/19;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OGA | 0:4c7c138f3891 | 1 | ///////////////////////////////////////OGATA////////////////////////////////////////// |
OGA | 0:4c7c138f3891 | 2 | ////////////////////////////////////////////////////////////////////////////////////// |
OGA | 0:4c7c138f3891 | 3 | //センサの数 |
OGA | 0:4c7c138f3891 | 4 | #define COLOR_NUM 6 |
OGA | 0:4c7c138f3891 | 5 | |
OGA | 0:4c7c138f3891 | 6 | //閾値 |
OGA | 0:4c7c138f3891 | 7 | #define R_THR 65 |
OGA | 0:4c7c138f3891 | 8 | #define G_THR 65 |
OGA | 0:4c7c138f3891 | 9 | #define B_THR 65 |
OGA | 0:4c7c138f3891 | 10 | #define PINR_THR 2000 |
OGA | 0:4c7c138f3891 | 11 | |
OGA | 0:4c7c138f3891 | 12 | |
OGA | 0:4c7c138f3891 | 13 | enum{ |
OGA | 0:4c7c138f3891 | 14 | GO, |
OGA | 0:4c7c138f3891 | 15 | STOP |
OGA | 0:4c7c138f3891 | 16 | }; |
OGA | 0:4c7c138f3891 | 17 | |
OGA | 0:4c7c138f3891 | 18 | //TextLCD lcd(p30, p29, p28, p27, p26, p25, TextLCD::LCD20x4); // rs, e, d4-d7 |
OGA | 0:4c7c138f3891 | 19 | ColorSensor color0(p20, p17, p18, p19, 10); |
OGA | 0:4c7c138f3891 | 20 | ColorSensor color1(p16, p13, p14, p15, 10); |
OGA | 0:4c7c138f3891 | 21 | ColorSensor color2(p12, p9, p10, p11, 10); |
OGA | 0:4c7c138f3891 | 22 | ColorSensor color3(p8, p5, p6, p7, 10); |
OGA | 0:4c7c138f3891 | 23 | |
OGA | 0:4c7c138f3891 | 24 | ColorSensor color4(p24, p21, p22, p23, 10); |
OGA | 0:4c7c138f3891 | 25 | ColorSensor color5(p30, p25, p26, p29, 10); |
OGA | 0:4c7c138f3891 | 26 | //ColorSensor color4(p26, p23, p24, p25, 10); |
OGA | 0:4c7c138f3891 | 27 | //ColorSensor color5(p30, p27, p28, p29, 10); |
OGA | 0:4c7c138f3891 | 28 | |
OGA | 0:4c7c138f3891 | 29 | Serial pc(USBTX, USBRX); // tx, rx |
OGA | 0:4c7c138f3891 | 30 | DigitalOut led[4] = {LED1,LED2,LED3,LED4}; |
OGA | 0:4c7c138f3891 | 31 | //DigitalOut air[2] = {p7,p8}; |
OGA | 0:4c7c138f3891 | 32 | |
OGA | 0:4c7c138f3891 | 33 | |
OGA | 0:4c7c138f3891 | 34 | //Servo myservo1(p21); |
OGA | 0:4c7c138f3891 | 35 | //DigitalIn sw1(p22); |
OGA | 0:4c7c138f3891 | 36 | |
OGA | 0:4c7c138f3891 | 37 | |
OGA | 0:4c7c138f3891 | 38 | |
OGA | 0:4c7c138f3891 | 39 | Timer color_t[COLOR_NUM]; |
OGA | 0:4c7c138f3891 | 40 | Timer jump_t; |
OGA | 0:4c7c138f3891 | 41 | Ticker interrupt0; |
OGA | 0:4c7c138f3891 | 42 | |
OGA | 0:4c7c138f3891 | 43 | |
OGA | 0:4c7c138f3891 | 44 | void rivisedate (); |
OGA | 0:4c7c138f3891 | 45 | void colorUpdate (uint8_t mode); |
OGA | 0:4c7c138f3891 | 46 | uint16_t moving_ave(uint8_t num, uint16_t data); |
OGA | 0:4c7c138f3891 | 47 | uint8_t robotFront(); |
OGA | 0:4c7c138f3891 | 48 | uint8_t jumpInstruction(uint8_t front); |
OGA | 0:4c7c138f3891 | 49 | uint8_t robotoStop(); |
OGA | 0:4c7c138f3891 | 50 | |
OGA | 0:4c7c138f3891 | 51 | |
OGA | 0:4c7c138f3891 | 52 | double proportional = 0; |
OGA | 0:4c7c138f3891 | 53 | uint16_t com_val = 0; |
OGA | 0:4c7c138f3891 | 54 | unsigned redp[COLOR_NUM], greenp[COLOR_NUM], bluep[COLOR_NUM]; |
OGA | 0:4c7c138f3891 | 55 | double rir,rib ; |
OGA | 0:4c7c138f3891 | 56 | |
OGA | 0:4c7c138f3891 | 57 | |
OGA | 0:4c7c138f3891 | 58 | |
OGA | 0:4c7c138f3891 | 59 | enum{ |
OGA | 0:4c7c138f3891 | 60 | WAIT, |
OGA | 0:4c7c138f3891 | 61 | STRAIGHT, |
OGA | 0:4c7c138f3891 | 62 | TURN, |
OGA | 0:4c7c138f3891 | 63 | COMP |
OGA | 0:4c7c138f3891 | 64 | }; |