RobocupSSLのメイン基板白mbedのプログラム

Dependencies:   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は,ロボットとボールの座標,審判の判定を元にロボットの移動,キックなどの作戦を決定し,無線によってロボットに指令を送信する. 700


ロボット機能紹介


●オムニホイールによる方向転換不要の全方位移動

オムニホイールは,自由に回転可能なローラをホイールの外周上に配置した車輪である.ローラの回転により,車輪の回転と垂直の方向に駆動力を発することはできないが移動は可能となる.各車輪の角速度を調整することによって全方向への移動を可能にする.
400

●ドリブルバーのバックスピンによるボール保持

●電磁力を利用したキッカー

●キッカーの電磁力エネルギーを充電する充電回路

●ロボット情報が一目でわかるLCD

Committer:
alt0710
Date:
Wed May 02 02:47:35 2018 +0000
Revision:
30:8ee22331bfaf
Parent:
29:4607c59702a1
ifdef???ver????????????LCD?BoardNo.???????????; ;

Who changed what in which revision?

UserRevisionLine numberNew 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 30:8ee22331bfaf 12 #if defined(MAIN_BORD_Ver_4)
alt0710 30:8ee22331bfaf 13 //CrossSelectSW
alt0710 30:8ee22331bfaf 14 DigitalIn Mode_SW1(A2);
alt0710 30:8ee22331bfaf 15 DigitalIn Mode_SW2(A3);
alt0710 30:8ee22331bfaf 16 InterruptIn CrossSW_UP(D9); //EXT2
alt0710 30:8ee22331bfaf 17 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 30:8ee22331bfaf 18 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 30:8ee22331bfaf 19 DigitalIn DUMY(D8); //KICK
alt0710 30:8ee22331bfaf 20 InterruptIn CrossSW_RIGHT(A1); //EXT
alt0710 30:8ee22331bfaf 21 #elif defined(MAIN_BORD_Ver_5)
alt0710 30:8ee22331bfaf 22 //SWの配置が変わったので使いやすい構成にかえる
alt0710 30:8ee22331bfaf 23 //CrossSelectSW
alt0710 30:8ee22331bfaf 24 DigitalIn Mode_SW1(A2);
alt0710 30:8ee22331bfaf 25 DigitalIn Mode_SW2(A3);
alt0710 30:8ee22331bfaf 26 InterruptIn CrossSW_UP(D9); //EXT2
alt0710 30:8ee22331bfaf 27 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 30:8ee22331bfaf 28 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 30:8ee22331bfaf 29 DigitalIn DUMY(A1); //KICK
alt0710 30:8ee22331bfaf 30 InterruptIn CrossSW_RIGHT(D8); //EXT
alt0710 30:8ee22331bfaf 31 #elif defined(MAIN_BORD_Ver_3)
alt0710 30:8ee22331bfaf 32 //ModeSelectSW
alt0710 30:8ee22331bfaf 33 DigitalIn Mode_SW1(A3);
alt0710 30:8ee22331bfaf 34 DigitalIn Mode_SW2(A2);
alt0710 30:8ee22331bfaf 35 //CrossSelectSW
alt0710 30:8ee22331bfaf 36 InterruptIn CrossSW_UP(D11); //EXT2
alt0710 30:8ee22331bfaf 37 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 30:8ee22331bfaf 38 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 30:8ee22331bfaf 39 DigitalIn DUMY(D8); //KICK
alt0710 30:8ee22331bfaf 40 InterruptIn CrossSW_RIGHT(A1); //EXT
alt0710 29:4607c59702a1 41 #endif
alt0710 0:d4b98dbcb767 42 #endif
alt0710 0:d4b98dbcb767 43
alt0710 5:4be30999853f 44 DigitalOut myled(LED1);
alt0710 5:4be30999853f 45
alt0710 0:d4b98dbcb767 46 Ticker t_up;
alt0710 5:4be30999853f 47 Ticker t_left;
alt0710 0:d4b98dbcb767 48 Ticker t_down;
alt0710 0:d4b98dbcb767 49 Ticker t_right;
alt0710 0:d4b98dbcb767 50
alt0710 0:d4b98dbcb767 51 /* **ローカル割り込み関数** */
alt0710 30:8ee22331bfaf 52 //#ifndef MAIN_BORD_Ver_5
alt0710 20:354ed2681d0a 53 void check_click_up(void)
alt0710 20:354ed2681d0a 54 {
alt0710 20:354ed2681d0a 55 if(InterfaceManager::button.count_click[0] == 1)
alt0710 20:354ed2681d0a 56 {
alt0710 20:354ed2681d0a 57 InterfaceManager::button.setButtunStatus(CROSS_UP, SINGLE_CLICK);
alt0710 20:354ed2681d0a 58 }
alt0710 20:354ed2681d0a 59 else if(InterfaceManager::button.count_click[0] == 2)
alt0710 20:354ed2681d0a 60 {
alt0710 20:354ed2681d0a 61 InterfaceManager::button.setButtunStatus(CROSS_UP, DOUBLE_CLICK);
alt0710 20:354ed2681d0a 62 }
alt0710 20:354ed2681d0a 63 InterfaceManager::button.count_click[0] = 0;
alt0710 20:354ed2681d0a 64 t_up.detach();
alt0710 20:354ed2681d0a 65
alt0710 20:354ed2681d0a 66 }
alt0710 30:8ee22331bfaf 67 //#endif
alt0710 12:b7d7523733cd 68 //void check_click_down(void)
alt0710 12:b7d7523733cd 69 //{
alt0710 12:b7d7523733cd 70 // if(InterfaceManager::button.count_click[1] == 1)
alt0710 12:b7d7523733cd 71 // {
alt0710 12:b7d7523733cd 72 // InterfaceManager::button.setButtunStatus(CROSS_DOWN, SINGLE_CLICK);
alt0710 12:b7d7523733cd 73 // }
alt0710 12:b7d7523733cd 74 // else if(InterfaceManager::button.count_click[1] == 2)
alt0710 12:b7d7523733cd 75 // {
alt0710 12:b7d7523733cd 76 // InterfaceManager::button.setButtunStatus(CROSS_DOWN, DOUBLE_CLICK);
alt0710 12:b7d7523733cd 77 // }
alt0710 12:b7d7523733cd 78 // InterfaceManager::button.count_click[1] = 0;
alt0710 12:b7d7523733cd 79 // t_down.detach();
alt0710 12:b7d7523733cd 80 //}
alt0710 0:d4b98dbcb767 81 void check_click_left(void)
alt0710 0:d4b98dbcb767 82 {
alt0710 0:d4b98dbcb767 83 if(InterfaceManager::button.count_click[2] == 1)
alt0710 0:d4b98dbcb767 84 {
alt0710 0:d4b98dbcb767 85 InterfaceManager::button.setButtunStatus(CROSS_LEFT, SINGLE_CLICK);
alt0710 0:d4b98dbcb767 86 }
alt0710 0:d4b98dbcb767 87 else if(InterfaceManager::button.count_click[2] == 2)
alt0710 0:d4b98dbcb767 88 {
alt0710 0:d4b98dbcb767 89 InterfaceManager::button.setButtunStatus(CROSS_LEFT, DOUBLE_CLICK);
alt0710 0:d4b98dbcb767 90 }
alt0710 0:d4b98dbcb767 91 InterfaceManager::button.count_click[2] = 0;
alt0710 0:d4b98dbcb767 92 t_left.detach();
alt0710 0:d4b98dbcb767 93 }
alt0710 0:d4b98dbcb767 94 void check_click_right(void)
alt0710 0:d4b98dbcb767 95 {
alt0710 0:d4b98dbcb767 96 if(InterfaceManager::button.count_click[3] == 1)
alt0710 0:d4b98dbcb767 97 {
alt0710 0:d4b98dbcb767 98 InterfaceManager::button.setButtunStatus(CROSS_RIGHT, SINGLE_CLICK);
alt0710 0:d4b98dbcb767 99 }
alt0710 0:d4b98dbcb767 100 else if(InterfaceManager::button.count_click[3] == 2)
alt0710 0:d4b98dbcb767 101 {
alt0710 0:d4b98dbcb767 102 InterfaceManager::button.setButtunStatus(CROSS_RIGHT, DOUBLE_CLICK);
alt0710 0:d4b98dbcb767 103 }
alt0710 0:d4b98dbcb767 104 InterfaceManager::button.count_click[3] = 0;
alt0710 0:d4b98dbcb767 105 t_right.detach();
alt0710 0:d4b98dbcb767 106
alt0710 0:d4b98dbcb767 107 }
alt0710 0:d4b98dbcb767 108
alt0710 30:8ee22331bfaf 109 //#ifndef MAIN_BORD_Ver_5
alt0710 20:354ed2681d0a 110 void click_up(void)
alt0710 20:354ed2681d0a 111 {
alt0710 20:354ed2681d0a 112 myled = !myled;
alt0710 20:354ed2681d0a 113 switch(InterfaceManager::button.count_click[0]){
alt0710 20:354ed2681d0a 114 case 0:
alt0710 20:354ed2681d0a 115 t_up.attach(check_click_up, CHECK_TIME);
alt0710 20:354ed2681d0a 116 InterfaceManager::button.count_click[0]++;
alt0710 20:354ed2681d0a 117 break;
alt0710 20:354ed2681d0a 118
alt0710 20:354ed2681d0a 119 case 1:
alt0710 20:354ed2681d0a 120 InterfaceManager::button.count_click[0]++;
alt0710 20:354ed2681d0a 121 break;
alt0710 20:354ed2681d0a 122
alt0710 20:354ed2681d0a 123 default:
alt0710 20:354ed2681d0a 124 InterfaceManager::button.count_click[0] = 0;
alt0710 20:354ed2681d0a 125 break;
alt0710 20:354ed2681d0a 126 }
alt0710 20:354ed2681d0a 127
alt0710 20:354ed2681d0a 128 }
alt0710 30:8ee22331bfaf 129 //#endif
alt0710 12:b7d7523733cd 130 //void click_down(void)
alt0710 12:b7d7523733cd 131 //{
alt0710 12:b7d7523733cd 132 // myled = !myled;
alt0710 12:b7d7523733cd 133 // switch(InterfaceManager::button.count_click[1]){
alt0710 12:b7d7523733cd 134 // case 0:
alt0710 12:b7d7523733cd 135 // t_down.attach(check_click_down, CHECK_TIME);
alt0710 12:b7d7523733cd 136 // InterfaceManager::button.count_click[1]++;
alt0710 12:b7d7523733cd 137 // break;
alt0710 12:b7d7523733cd 138 //
alt0710 12:b7d7523733cd 139 // case 1:
alt0710 12:b7d7523733cd 140 // InterfaceManager::button.count_click[1]++;
alt0710 12:b7d7523733cd 141 // break;
alt0710 12:b7d7523733cd 142 //
alt0710 12:b7d7523733cd 143 // default:
alt0710 12:b7d7523733cd 144 // InterfaceManager::button.count_click[1] = 0;
alt0710 12:b7d7523733cd 145 // break;
alt0710 12:b7d7523733cd 146 // }
alt0710 12:b7d7523733cd 147 //
alt0710 12:b7d7523733cd 148 //}
alt0710 0:d4b98dbcb767 149 void click_left(void)
alt0710 0:d4b98dbcb767 150 {
alt0710 5:4be30999853f 151 myled = !myled;
alt0710 0:d4b98dbcb767 152 switch(InterfaceManager::button.count_click[2]){
alt0710 0:d4b98dbcb767 153 case 0:
alt0710 0:d4b98dbcb767 154 t_left.attach(check_click_left, CHECK_TIME);
alt0710 0:d4b98dbcb767 155 InterfaceManager::button.count_click[2]++;
alt0710 0:d4b98dbcb767 156 break;
alt0710 0:d4b98dbcb767 157
alt0710 0:d4b98dbcb767 158 case 1:
alt0710 0:d4b98dbcb767 159 InterfaceManager::button.count_click[2]++;
alt0710 0:d4b98dbcb767 160 break;
alt0710 0:d4b98dbcb767 161
alt0710 0:d4b98dbcb767 162 default:
alt0710 0:d4b98dbcb767 163 InterfaceManager::button.count_click[2] = 0;
alt0710 0:d4b98dbcb767 164 break;
alt0710 0:d4b98dbcb767 165 }
alt0710 0:d4b98dbcb767 166
alt0710 0:d4b98dbcb767 167 }
alt0710 0:d4b98dbcb767 168 void click_right(void)
alt0710 0:d4b98dbcb767 169 {
alt0710 5:4be30999853f 170 myled = !myled;
alt0710 0:d4b98dbcb767 171 switch(InterfaceManager::button.count_click[3]){
alt0710 0:d4b98dbcb767 172 case 0:
alt0710 0:d4b98dbcb767 173 t_right.attach(check_click_right, CHECK_TIME);
alt0710 0:d4b98dbcb767 174 InterfaceManager::button.count_click[3]++;
alt0710 0:d4b98dbcb767 175 break;
alt0710 0:d4b98dbcb767 176
alt0710 0:d4b98dbcb767 177 case 1:
alt0710 0:d4b98dbcb767 178 InterfaceManager::button.count_click[3]++;
alt0710 0:d4b98dbcb767 179 break;
alt0710 0:d4b98dbcb767 180
alt0710 0:d4b98dbcb767 181 default:
alt0710 0:d4b98dbcb767 182 InterfaceManager::button.count_click[3] = 0;
alt0710 0:d4b98dbcb767 183 break;
alt0710 0:d4b98dbcb767 184 }
alt0710 0:d4b98dbcb767 185
alt0710 0:d4b98dbcb767 186 }
alt0710 0:d4b98dbcb767 187
alt0710 0:d4b98dbcb767 188
alt0710 0:d4b98dbcb767 189 /* **グルーバル関数** */
alt0710 0:d4b98dbcb767 190 void initButton(void)
alt0710 0:d4b98dbcb767 191 {
alt0710 4:8c6f6b687303 192 Mode_SW1.mode(PullDown);
alt0710 4:8c6f6b687303 193 Mode_SW2.mode(PullDown);
alt0710 0:d4b98dbcb767 194
alt0710 30:8ee22331bfaf 195 //#ifndef MAIN_BORD_Ver_5
alt0710 20:354ed2681d0a 196 CrossSW_UP.mode(PullNone);
alt0710 30:8ee22331bfaf 197 //#else
alt0710 30:8ee22331bfaf 198 //UP.mode(PullNone);
alt0710 30:8ee22331bfaf 199 //#endif
alt0710 12:b7d7523733cd 200 //CrossSW_DOWN.mode(PullNone);
alt0710 5:4be30999853f 201 DUMY.mode(PullNone);
alt0710 5:4be30999853f 202 CrossSW_LEFT.mode(PullNone);
alt0710 5:4be30999853f 203 CrossSW_RIGHT.mode(PullNone);
alt0710 0:d4b98dbcb767 204
alt0710 0:d4b98dbcb767 205 //入力割り込み設定
alt0710 30:8ee22331bfaf 206 //#ifndef MAIN_BORD_Ver_5
alt0710 20:354ed2681d0a 207 CrossSW_UP.fall(&click_up);
alt0710 30:8ee22331bfaf 208 //#else
alt0710 29:4607c59702a1 209
alt0710 30:8ee22331bfaf 210 //#endif
alt0710 5:4be30999853f 211 CrossSW_LEFT.fall(&click_left);
alt0710 29:4607c59702a1 212
alt0710 12:b7d7523733cd 213 //CrossSW_DOWN.rise(&click_down);
alt0710 5:4be30999853f 214 CrossSW_RIGHT.fall(&click_right);
alt0710 0:d4b98dbcb767 215
alt0710 0:d4b98dbcb767 216 }
alt0710 0:d4b98dbcb767 217
alt0710 0:d4b98dbcb767 218 /* **クラス** */
alt0710 0:d4b98dbcb767 219 Button_Roots::Button_Roots()
alt0710 0:d4b98dbcb767 220 {
alt0710 0:d4b98dbcb767 221 modeSW1 = 0;
alt0710 0:d4b98dbcb767 222 modeSW2 = 0;
alt0710 0:d4b98dbcb767 223 modeSW = 0;
alt0710 0:d4b98dbcb767 224 crossUp = 0;
alt0710 0:d4b98dbcb767 225 crossDown = 0;
alt0710 0:d4b98dbcb767 226 crossLeft = 0;
alt0710 0:d4b98dbcb767 227 crossRight = 0;
alt0710 0:d4b98dbcb767 228
alt0710 0:d4b98dbcb767 229 }
alt0710 0:d4b98dbcb767 230 char Button_Roots::getButtonStatus(char ButtonNames)
alt0710 0:d4b98dbcb767 231 {
alt0710 0:d4b98dbcb767 232 switch(ButtonNames){
alt0710 0:d4b98dbcb767 233 case MODE_SW1:
alt0710 4:8c6f6b687303 234 return !Mode_SW1;
alt0710 0:d4b98dbcb767 235
alt0710 0:d4b98dbcb767 236 case MODE_SW2:
alt0710 4:8c6f6b687303 237 return !Mode_SW2;
alt0710 0:d4b98dbcb767 238
alt0710 0:d4b98dbcb767 239 case MODE_SW:
alt0710 4:8c6f6b687303 240 modeSW = !Mode_SW1 + (!Mode_SW2 << 1);
alt0710 0:d4b98dbcb767 241 return modeSW;
alt0710 0:d4b98dbcb767 242
alt0710 0:d4b98dbcb767 243 case CROSS_UP:
alt0710 30:8ee22331bfaf 244 // #ifndef MAIN_BORD_Ver_5
alt0710 5:4be30999853f 245 button_status = crossUp;
alt0710 5:4be30999853f 246 crossUp = 0;
alt0710 30:8ee22331bfaf 247 // #else
alt0710 30:8ee22331bfaf 248 // if( (!UP) && (cross_up_old == 1) ){
alt0710 30:8ee22331bfaf 249 // is_button_pushed_up = 1;
alt0710 30:8ee22331bfaf 250 // }else{
alt0710 30:8ee22331bfaf 251 // is_button_pushed_up = 0;
alt0710 30:8ee22331bfaf 252 // }
alt0710 30:8ee22331bfaf 253 // cross_up_old = !UP;
alt0710 30:8ee22331bfaf 254 // button_status = is_button_pushed_up;
alt0710 30:8ee22331bfaf 255 // #endif
alt0710 5:4be30999853f 256 return button_status;
alt0710 0:d4b98dbcb767 257
alt0710 0:d4b98dbcb767 258 case CROSS_DOWN:
alt0710 5:4be30999853f 259 if( (!DUMY) && (cross_down_old == 1) ){
alt0710 5:4be30999853f 260 is_button_pushed = 1;
alt0710 5:4be30999853f 261 }else{
alt0710 5:4be30999853f 262 is_button_pushed = 0;
alt0710 5:4be30999853f 263 }
alt0710 5:4be30999853f 264 cross_down_old = !DUMY;
alt0710 5:4be30999853f 265 button_status = is_button_pushed;
alt0710 5:4be30999853f 266 //crossDown = 0;
alt0710 5:4be30999853f 267 return button_status;
alt0710 0:d4b98dbcb767 268
alt0710 0:d4b98dbcb767 269 case CROSS_LEFT:
alt0710 5:4be30999853f 270 button_status = crossLeft;
alt0710 5:4be30999853f 271 crossLeft = 0;
alt0710 5:4be30999853f 272 return button_status;
alt0710 0:d4b98dbcb767 273
alt0710 0:d4b98dbcb767 274 case CROSS_RIGHT:
alt0710 5:4be30999853f 275 button_status = crossRight;
alt0710 5:4be30999853f 276 crossRight = 0;
alt0710 5:4be30999853f 277 return button_status;
alt0710 0:d4b98dbcb767 278
alt0710 0:d4b98dbcb767 279 default:
alt0710 0:d4b98dbcb767 280 return 99;
alt0710 0:d4b98dbcb767 281
alt0710 0:d4b98dbcb767 282 }
alt0710 0:d4b98dbcb767 283
alt0710 0:d4b98dbcb767 284 }
alt0710 0:d4b98dbcb767 285 char Button_Roots::setButtunStatus(char ButtonNames, char ButtonStatus)
alt0710 0:d4b98dbcb767 286 {
alt0710 0:d4b98dbcb767 287 switch(ButtonNames){
alt0710 0:d4b98dbcb767 288 case MODE_SW1:
alt0710 0:d4b98dbcb767 289 return modeSW1 = ButtonStatus;
alt0710 0:d4b98dbcb767 290
alt0710 0:d4b98dbcb767 291 case MODE_SW2:
alt0710 0:d4b98dbcb767 292 return modeSW2 = ButtonStatus;
alt0710 0:d4b98dbcb767 293
alt0710 0:d4b98dbcb767 294 case CROSS_UP:
alt0710 0:d4b98dbcb767 295 return crossUp = ButtonStatus;
alt0710 0:d4b98dbcb767 296
alt0710 0:d4b98dbcb767 297 case CROSS_DOWN:
alt0710 0:d4b98dbcb767 298 return crossDown = ButtonStatus;
alt0710 0:d4b98dbcb767 299
alt0710 0:d4b98dbcb767 300 case CROSS_LEFT:
alt0710 0:d4b98dbcb767 301 return crossLeft = ButtonStatus;
alt0710 0:d4b98dbcb767 302
alt0710 0:d4b98dbcb767 303 case CROSS_RIGHT:
alt0710 0:d4b98dbcb767 304 return crossRight = ButtonStatus;
alt0710 0:d4b98dbcb767 305
alt0710 0:d4b98dbcb767 306 default:
alt0710 0:d4b98dbcb767 307 return 99;
alt0710 0:d4b98dbcb767 308
alt0710 0:d4b98dbcb767 309 }
alt0710 0:d4b98dbcb767 310
alt0710 0:d4b98dbcb767 311 }