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:
Tue May 01 06:38:42 2018 +0000
Revision:
29:4607c59702a1
Parent:
28:eab9de9eb81a
Child:
30:8ee22331bfaf
main??ver5 ?SW?????????

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