RobocupSSLのメイン基板白mbedのプログラム
Rootsロボット mainプログラム
~ Robocup SSL(小型車輪リーグ)ロボット ~
Robocup SSLとは
●試合構成
Robocup小型ロボットリーグ(Small Size League)は,直径180[mm],高さ150[mm]以内のサイズのロボット6台が1チームとなり,オレンジ色のゴルフボールを使ってサッカー競技を行う自立型ロボットコンテストである.
フィールドの上には2台のWebカメラが設置され,フィールド上のロボットとボールを撮影する.Visionサーバは,フィールドの画像データよりロボットとボールの座標データを算出し,LANを用い各チームのAI用PCに送信する.Webカメラの撮影速度は,60[fps]である.レフリーボックスは,ファウルやフリーキック,スローインなどの審判の判定を入力し,LANを通じて各チームのAI用PCに送信する.それぞれのチームのAI用PCは,ロボットとボールの座標,審判の判定を元にロボットの移動,キックなどの作戦を決定し,無線によってロボットに指令を送信する.
ロボット機能紹介
●オムニホイールによる方向転換不要の全方位移動
オムニホイールは,自由に回転可能なローラをホイールの外周上に配置した車輪である.ローラの回転により,車輪の回転と垂直の方向に駆動力を発することはできないが移動は可能となる.各車輪の角速度を調整することによって全方向への移動を可能にする.
●ドリブルバーのバックスピンによるボール保持
●電磁力を利用したキッカー
●キッカーの電磁力エネルギーを充電する充電回路
●ロボット情報が一目でわかるLCD
interface/button/button_roots.cpp@16:e8060a65ed23, 2017-05-04 (annotated)
- Committer:
- alt0710
- Date:
- Thu May 04 07:47:48 2017 +0000
- Revision:
- 16:e8060a65ed23
- Parent:
- 15:2bf8eafacef8
- Child:
- 23:0bb032ef1880
????;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alt0710 | 0:d4b98dbcb767 | 1 | |
alt0710 | 0:d4b98dbcb767 | 2 | #include "mbed.h" |
alt0710 | 0:d4b98dbcb767 | 3 | #include "comm.h" |
alt0710 | 0:d4b98dbcb767 | 4 | #include "interface_manager.h" |
alt0710 | 0:d4b98dbcb767 | 5 | #include "button_roots.h" |
alt0710 | 0:d4b98dbcb767 | 6 | |
alt0710 | 0:d4b98dbcb767 | 7 | |
alt0710 | 0:d4b98dbcb767 | 8 | /* **mbedクラス** */ |
alt0710 | 0:d4b98dbcb767 | 9 | #ifdef LPC4088 |
alt0710 | 0:d4b98dbcb767 | 10 | |
alt0710 | 0:d4b98dbcb767 | 11 | #elif STM32 |
alt0710 | 0:d4b98dbcb767 | 12 | //ModeSelectSW |
alt0710 | 0:d4b98dbcb767 | 13 | DigitalIn Mode_SW1(A3); |
alt0710 | 0:d4b98dbcb767 | 14 | DigitalIn Mode_SW2(A2); |
alt0710 | 0:d4b98dbcb767 | 15 | |
alt0710 | 0:d4b98dbcb767 | 16 | //CrossSelectSW |
alt0710 | 16:e8060a65ed23 | 17 | InterruptIn CrossSW_UP(D11); //EXT2 |
alt0710 | 6:21b3fbe57b88 | 18 | InterruptIn CrossSW_LEFT(D7); //PUSH D7 |
alt0710 | 12:b7d7523733cd | 19 | //InterruptIn CrossSW_DOWN(D9); //KICK |
alt0710 | 5:4be30999853f | 20 | DigitalIn DUMY(D8); //KICK |
alt0710 | 0:d4b98dbcb767 | 21 | InterruptIn CrossSW_RIGHT(A1); //EXT |
alt0710 | 0:d4b98dbcb767 | 22 | #endif |
alt0710 | 0:d4b98dbcb767 | 23 | |
alt0710 | 5:4be30999853f | 24 | DigitalOut myled(LED1); |
alt0710 | 5:4be30999853f | 25 | |
alt0710 | 0:d4b98dbcb767 | 26 | Ticker t_up; |
alt0710 | 5:4be30999853f | 27 | Ticker t_left; |
alt0710 | 0:d4b98dbcb767 | 28 | Ticker t_down; |
alt0710 | 0:d4b98dbcb767 | 29 | Ticker t_right; |
alt0710 | 0:d4b98dbcb767 | 30 | |
alt0710 | 0:d4b98dbcb767 | 31 | /* **ローカル割り込み関数** */ |
alt0710 | 0:d4b98dbcb767 | 32 | |
alt0710 | 16:e8060a65ed23 | 33 | void check_click_up(void) |
alt0710 | 16:e8060a65ed23 | 34 | { |
alt0710 | 16:e8060a65ed23 | 35 | if(InterfaceManager::button.count_click[0] == 1) |
alt0710 | 16:e8060a65ed23 | 36 | { |
alt0710 | 16:e8060a65ed23 | 37 | InterfaceManager::button.setButtunStatus(CROSS_UP, SINGLE_CLICK); |
alt0710 | 16:e8060a65ed23 | 38 | } |
alt0710 | 16:e8060a65ed23 | 39 | else if(InterfaceManager::button.count_click[0] == 2) |
alt0710 | 16:e8060a65ed23 | 40 | { |
alt0710 | 16:e8060a65ed23 | 41 | InterfaceManager::button.setButtunStatus(CROSS_UP, DOUBLE_CLICK); |
alt0710 | 16:e8060a65ed23 | 42 | } |
alt0710 | 16:e8060a65ed23 | 43 | InterfaceManager::button.count_click[0] = 0; |
alt0710 | 16:e8060a65ed23 | 44 | t_up.detach(); |
alt0710 | 16:e8060a65ed23 | 45 | |
alt0710 | 16:e8060a65ed23 | 46 | } |
alt0710 | 12:b7d7523733cd | 47 | //void check_click_down(void) |
alt0710 | 12:b7d7523733cd | 48 | //{ |
alt0710 | 12:b7d7523733cd | 49 | // if(InterfaceManager::button.count_click[1] == 1) |
alt0710 | 12:b7d7523733cd | 50 | // { |
alt0710 | 12:b7d7523733cd | 51 | // InterfaceManager::button.setButtunStatus(CROSS_DOWN, SINGLE_CLICK); |
alt0710 | 12:b7d7523733cd | 52 | // } |
alt0710 | 12:b7d7523733cd | 53 | // else if(InterfaceManager::button.count_click[1] == 2) |
alt0710 | 12:b7d7523733cd | 54 | // { |
alt0710 | 12:b7d7523733cd | 55 | // InterfaceManager::button.setButtunStatus(CROSS_DOWN, DOUBLE_CLICK); |
alt0710 | 12:b7d7523733cd | 56 | // } |
alt0710 | 12:b7d7523733cd | 57 | // InterfaceManager::button.count_click[1] = 0; |
alt0710 | 12:b7d7523733cd | 58 | // t_down.detach(); |
alt0710 | 12:b7d7523733cd | 59 | //} |
alt0710 | 0:d4b98dbcb767 | 60 | void check_click_left(void) |
alt0710 | 0:d4b98dbcb767 | 61 | { |
alt0710 | 0:d4b98dbcb767 | 62 | if(InterfaceManager::button.count_click[2] == 1) |
alt0710 | 0:d4b98dbcb767 | 63 | { |
alt0710 | 0:d4b98dbcb767 | 64 | InterfaceManager::button.setButtunStatus(CROSS_LEFT, SINGLE_CLICK); |
alt0710 | 0:d4b98dbcb767 | 65 | } |
alt0710 | 0:d4b98dbcb767 | 66 | else if(InterfaceManager::button.count_click[2] == 2) |
alt0710 | 0:d4b98dbcb767 | 67 | { |
alt0710 | 0:d4b98dbcb767 | 68 | InterfaceManager::button.setButtunStatus(CROSS_LEFT, DOUBLE_CLICK); |
alt0710 | 0:d4b98dbcb767 | 69 | } |
alt0710 | 0:d4b98dbcb767 | 70 | InterfaceManager::button.count_click[2] = 0; |
alt0710 | 0:d4b98dbcb767 | 71 | t_left.detach(); |
alt0710 | 0:d4b98dbcb767 | 72 | } |
alt0710 | 0:d4b98dbcb767 | 73 | void check_click_right(void) |
alt0710 | 0:d4b98dbcb767 | 74 | { |
alt0710 | 0:d4b98dbcb767 | 75 | if(InterfaceManager::button.count_click[3] == 1) |
alt0710 | 0:d4b98dbcb767 | 76 | { |
alt0710 | 0:d4b98dbcb767 | 77 | InterfaceManager::button.setButtunStatus(CROSS_RIGHT, SINGLE_CLICK); |
alt0710 | 0:d4b98dbcb767 | 78 | } |
alt0710 | 0:d4b98dbcb767 | 79 | else if(InterfaceManager::button.count_click[3] == 2) |
alt0710 | 0:d4b98dbcb767 | 80 | { |
alt0710 | 0:d4b98dbcb767 | 81 | InterfaceManager::button.setButtunStatus(CROSS_RIGHT, DOUBLE_CLICK); |
alt0710 | 0:d4b98dbcb767 | 82 | } |
alt0710 | 0:d4b98dbcb767 | 83 | InterfaceManager::button.count_click[3] = 0; |
alt0710 | 0:d4b98dbcb767 | 84 | t_right.detach(); |
alt0710 | 0:d4b98dbcb767 | 85 | |
alt0710 | 0:d4b98dbcb767 | 86 | } |
alt0710 | 0:d4b98dbcb767 | 87 | |
alt0710 | 16:e8060a65ed23 | 88 | void click_up(void) |
alt0710 | 16:e8060a65ed23 | 89 | { |
alt0710 | 16:e8060a65ed23 | 90 | myled = !myled; |
alt0710 | 16:e8060a65ed23 | 91 | switch(InterfaceManager::button.count_click[0]){ |
alt0710 | 16:e8060a65ed23 | 92 | case 0: |
alt0710 | 16:e8060a65ed23 | 93 | t_up.attach(check_click_up, CHECK_TIME); |
alt0710 | 16:e8060a65ed23 | 94 | InterfaceManager::button.count_click[0]++; |
alt0710 | 16:e8060a65ed23 | 95 | break; |
alt0710 | 16:e8060a65ed23 | 96 | |
alt0710 | 16:e8060a65ed23 | 97 | case 1: |
alt0710 | 16:e8060a65ed23 | 98 | InterfaceManager::button.count_click[0]++; |
alt0710 | 16:e8060a65ed23 | 99 | break; |
alt0710 | 16:e8060a65ed23 | 100 | |
alt0710 | 16:e8060a65ed23 | 101 | default: |
alt0710 | 16:e8060a65ed23 | 102 | InterfaceManager::button.count_click[0] = 0; |
alt0710 | 16:e8060a65ed23 | 103 | break; |
alt0710 | 16:e8060a65ed23 | 104 | } |
alt0710 | 16:e8060a65ed23 | 105 | |
alt0710 | 16:e8060a65ed23 | 106 | } |
alt0710 | 12:b7d7523733cd | 107 | //void click_down(void) |
alt0710 | 12:b7d7523733cd | 108 | //{ |
alt0710 | 12:b7d7523733cd | 109 | // myled = !myled; |
alt0710 | 12:b7d7523733cd | 110 | // switch(InterfaceManager::button.count_click[1]){ |
alt0710 | 12:b7d7523733cd | 111 | // case 0: |
alt0710 | 12:b7d7523733cd | 112 | // t_down.attach(check_click_down, CHECK_TIME); |
alt0710 | 12:b7d7523733cd | 113 | // InterfaceManager::button.count_click[1]++; |
alt0710 | 12:b7d7523733cd | 114 | // break; |
alt0710 | 12:b7d7523733cd | 115 | // |
alt0710 | 12:b7d7523733cd | 116 | // case 1: |
alt0710 | 12:b7d7523733cd | 117 | // InterfaceManager::button.count_click[1]++; |
alt0710 | 12:b7d7523733cd | 118 | // break; |
alt0710 | 12:b7d7523733cd | 119 | // |
alt0710 | 12:b7d7523733cd | 120 | // default: |
alt0710 | 12:b7d7523733cd | 121 | // InterfaceManager::button.count_click[1] = 0; |
alt0710 | 12:b7d7523733cd | 122 | // break; |
alt0710 | 12:b7d7523733cd | 123 | // } |
alt0710 | 12:b7d7523733cd | 124 | // |
alt0710 | 12:b7d7523733cd | 125 | //} |
alt0710 | 0:d4b98dbcb767 | 126 | void click_left(void) |
alt0710 | 0:d4b98dbcb767 | 127 | { |
alt0710 | 5:4be30999853f | 128 | myled = !myled; |
alt0710 | 0:d4b98dbcb767 | 129 | switch(InterfaceManager::button.count_click[2]){ |
alt0710 | 0:d4b98dbcb767 | 130 | case 0: |
alt0710 | 0:d4b98dbcb767 | 131 | t_left.attach(check_click_left, CHECK_TIME); |
alt0710 | 0:d4b98dbcb767 | 132 | InterfaceManager::button.count_click[2]++; |
alt0710 | 0:d4b98dbcb767 | 133 | break; |
alt0710 | 0:d4b98dbcb767 | 134 | |
alt0710 | 0:d4b98dbcb767 | 135 | case 1: |
alt0710 | 0:d4b98dbcb767 | 136 | InterfaceManager::button.count_click[2]++; |
alt0710 | 0:d4b98dbcb767 | 137 | break; |
alt0710 | 0:d4b98dbcb767 | 138 | |
alt0710 | 0:d4b98dbcb767 | 139 | default: |
alt0710 | 0:d4b98dbcb767 | 140 | InterfaceManager::button.count_click[2] = 0; |
alt0710 | 0:d4b98dbcb767 | 141 | break; |
alt0710 | 0:d4b98dbcb767 | 142 | } |
alt0710 | 0:d4b98dbcb767 | 143 | |
alt0710 | 0:d4b98dbcb767 | 144 | } |
alt0710 | 0:d4b98dbcb767 | 145 | void click_right(void) |
alt0710 | 0:d4b98dbcb767 | 146 | { |
alt0710 | 5:4be30999853f | 147 | myled = !myled; |
alt0710 | 0:d4b98dbcb767 | 148 | switch(InterfaceManager::button.count_click[3]){ |
alt0710 | 0:d4b98dbcb767 | 149 | case 0: |
alt0710 | 0:d4b98dbcb767 | 150 | t_right.attach(check_click_right, CHECK_TIME); |
alt0710 | 0:d4b98dbcb767 | 151 | InterfaceManager::button.count_click[3]++; |
alt0710 | 0:d4b98dbcb767 | 152 | break; |
alt0710 | 0:d4b98dbcb767 | 153 | |
alt0710 | 0:d4b98dbcb767 | 154 | case 1: |
alt0710 | 0:d4b98dbcb767 | 155 | InterfaceManager::button.count_click[3]++; |
alt0710 | 0:d4b98dbcb767 | 156 | break; |
alt0710 | 0:d4b98dbcb767 | 157 | |
alt0710 | 0:d4b98dbcb767 | 158 | default: |
alt0710 | 0:d4b98dbcb767 | 159 | InterfaceManager::button.count_click[3] = 0; |
alt0710 | 0:d4b98dbcb767 | 160 | break; |
alt0710 | 0:d4b98dbcb767 | 161 | } |
alt0710 | 0:d4b98dbcb767 | 162 | |
alt0710 | 0:d4b98dbcb767 | 163 | } |
alt0710 | 0:d4b98dbcb767 | 164 | |
alt0710 | 0:d4b98dbcb767 | 165 | |
alt0710 | 0:d4b98dbcb767 | 166 | /* **グルーバル関数** */ |
alt0710 | 0:d4b98dbcb767 | 167 | void initButton(void) |
alt0710 | 0:d4b98dbcb767 | 168 | { |
alt0710 | 4:8c6f6b687303 | 169 | Mode_SW1.mode(PullDown); |
alt0710 | 4:8c6f6b687303 | 170 | Mode_SW2.mode(PullDown); |
alt0710 | 0:d4b98dbcb767 | 171 | |
alt0710 | 16:e8060a65ed23 | 172 | CrossSW_UP.mode(PullNone); |
alt0710 | 12:b7d7523733cd | 173 | //CrossSW_DOWN.mode(PullNone); |
alt0710 | 5:4be30999853f | 174 | DUMY.mode(PullNone); |
alt0710 | 5:4be30999853f | 175 | CrossSW_LEFT.mode(PullNone); |
alt0710 | 5:4be30999853f | 176 | CrossSW_RIGHT.mode(PullNone); |
alt0710 | 0:d4b98dbcb767 | 177 | |
alt0710 | 0:d4b98dbcb767 | 178 | //入力割り込み設定 |
alt0710 | 16:e8060a65ed23 | 179 | CrossSW_UP.fall(&click_up); |
alt0710 | 5:4be30999853f | 180 | CrossSW_LEFT.fall(&click_left); |
alt0710 | 12:b7d7523733cd | 181 | //CrossSW_DOWN.rise(&click_down); |
alt0710 | 5:4be30999853f | 182 | CrossSW_RIGHT.fall(&click_right); |
alt0710 | 0:d4b98dbcb767 | 183 | |
alt0710 | 0:d4b98dbcb767 | 184 | } |
alt0710 | 0:d4b98dbcb767 | 185 | |
alt0710 | 0:d4b98dbcb767 | 186 | /* **クラス** */ |
alt0710 | 0:d4b98dbcb767 | 187 | Button_Roots::Button_Roots() |
alt0710 | 0:d4b98dbcb767 | 188 | { |
alt0710 | 0:d4b98dbcb767 | 189 | modeSW1 = 0; |
alt0710 | 0:d4b98dbcb767 | 190 | modeSW2 = 0; |
alt0710 | 0:d4b98dbcb767 | 191 | modeSW = 0; |
alt0710 | 0:d4b98dbcb767 | 192 | crossUp = 0; |
alt0710 | 0:d4b98dbcb767 | 193 | crossDown = 0; |
alt0710 | 0:d4b98dbcb767 | 194 | crossLeft = 0; |
alt0710 | 0:d4b98dbcb767 | 195 | crossRight = 0; |
alt0710 | 0:d4b98dbcb767 | 196 | |
alt0710 | 0:d4b98dbcb767 | 197 | } |
alt0710 | 0:d4b98dbcb767 | 198 | char Button_Roots::getButtonStatus(char ButtonNames) |
alt0710 | 0:d4b98dbcb767 | 199 | { |
alt0710 | 0:d4b98dbcb767 | 200 | switch(ButtonNames){ |
alt0710 | 0:d4b98dbcb767 | 201 | case MODE_SW1: |
alt0710 | 4:8c6f6b687303 | 202 | return !Mode_SW1; |
alt0710 | 0:d4b98dbcb767 | 203 | |
alt0710 | 0:d4b98dbcb767 | 204 | case MODE_SW2: |
alt0710 | 4:8c6f6b687303 | 205 | return !Mode_SW2; |
alt0710 | 0:d4b98dbcb767 | 206 | |
alt0710 | 0:d4b98dbcb767 | 207 | case MODE_SW: |
alt0710 | 4:8c6f6b687303 | 208 | modeSW = !Mode_SW1 + (!Mode_SW2 << 1); |
alt0710 | 0:d4b98dbcb767 | 209 | return modeSW; |
alt0710 | 0:d4b98dbcb767 | 210 | |
alt0710 | 0:d4b98dbcb767 | 211 | case CROSS_UP: |
alt0710 | 5:4be30999853f | 212 | button_status = crossUp; |
alt0710 | 5:4be30999853f | 213 | crossUp = 0; |
alt0710 | 5:4be30999853f | 214 | return button_status; |
alt0710 | 0:d4b98dbcb767 | 215 | |
alt0710 | 0:d4b98dbcb767 | 216 | case CROSS_DOWN: |
alt0710 | 5:4be30999853f | 217 | if( (!DUMY) && (cross_down_old == 1) ){ |
alt0710 | 5:4be30999853f | 218 | is_button_pushed = 1; |
alt0710 | 5:4be30999853f | 219 | }else{ |
alt0710 | 5:4be30999853f | 220 | is_button_pushed = 0; |
alt0710 | 5:4be30999853f | 221 | } |
alt0710 | 5:4be30999853f | 222 | cross_down_old = !DUMY; |
alt0710 | 5:4be30999853f | 223 | button_status = is_button_pushed; |
alt0710 | 5:4be30999853f | 224 | //crossDown = 0; |
alt0710 | 5:4be30999853f | 225 | return button_status; |
alt0710 | 0:d4b98dbcb767 | 226 | |
alt0710 | 0:d4b98dbcb767 | 227 | case CROSS_LEFT: |
alt0710 | 5:4be30999853f | 228 | button_status = crossLeft; |
alt0710 | 5:4be30999853f | 229 | crossLeft = 0; |
alt0710 | 5:4be30999853f | 230 | return button_status; |
alt0710 | 0:d4b98dbcb767 | 231 | |
alt0710 | 0:d4b98dbcb767 | 232 | case CROSS_RIGHT: |
alt0710 | 5:4be30999853f | 233 | button_status = crossRight; |
alt0710 | 5:4be30999853f | 234 | crossRight = 0; |
alt0710 | 5:4be30999853f | 235 | return button_status; |
alt0710 | 0:d4b98dbcb767 | 236 | |
alt0710 | 0:d4b98dbcb767 | 237 | default: |
alt0710 | 0:d4b98dbcb767 | 238 | return 99; |
alt0710 | 0:d4b98dbcb767 | 239 | |
alt0710 | 0:d4b98dbcb767 | 240 | } |
alt0710 | 0:d4b98dbcb767 | 241 | |
alt0710 | 0:d4b98dbcb767 | 242 | } |
alt0710 | 0:d4b98dbcb767 | 243 | char Button_Roots::setButtunStatus(char ButtonNames, char ButtonStatus) |
alt0710 | 0:d4b98dbcb767 | 244 | { |
alt0710 | 0:d4b98dbcb767 | 245 | switch(ButtonNames){ |
alt0710 | 0:d4b98dbcb767 | 246 | case MODE_SW1: |
alt0710 | 0:d4b98dbcb767 | 247 | return modeSW1 = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 248 | |
alt0710 | 0:d4b98dbcb767 | 249 | case MODE_SW2: |
alt0710 | 0:d4b98dbcb767 | 250 | return modeSW2 = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 251 | |
alt0710 | 0:d4b98dbcb767 | 252 | case CROSS_UP: |
alt0710 | 0:d4b98dbcb767 | 253 | return crossUp = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 254 | |
alt0710 | 0:d4b98dbcb767 | 255 | case CROSS_DOWN: |
alt0710 | 0:d4b98dbcb767 | 256 | return crossDown = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 257 | |
alt0710 | 0:d4b98dbcb767 | 258 | case CROSS_LEFT: |
alt0710 | 0:d4b98dbcb767 | 259 | return crossLeft = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 260 | |
alt0710 | 0:d4b98dbcb767 | 261 | case CROSS_RIGHT: |
alt0710 | 0:d4b98dbcb767 | 262 | return crossRight = ButtonStatus; |
alt0710 | 0:d4b98dbcb767 | 263 | |
alt0710 | 0:d4b98dbcb767 | 264 | default: |
alt0710 | 0:d4b98dbcb767 | 265 | return 99; |
alt0710 | 0:d4b98dbcb767 | 266 | |
alt0710 | 0:d4b98dbcb767 | 267 | } |
alt0710 | 0:d4b98dbcb767 | 268 | |
alt0710 | 0:d4b98dbcb767 | 269 | } |