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 02:52:12 2018 +0000
Revision:
28:eab9de9eb81a
Parent:
23:0bb032ef1880
Child:
29:4607c59702a1
main??ver???SW????????; ????????????????? ? ? ??ver4???????

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 28:eab9de9eb81a 12 #ifdef MAIN_BORD_Ver_4
alt0710 28:eab9de9eb81a 13 //CrossSelectSW
alt0710 28:eab9de9eb81a 14 DigitalIn Mode_SW1(A2);
alt0710 28:eab9de9eb81a 15 DigitalIn Mode_SW2(A3);
alt0710 28:eab9de9eb81a 16 InterruptIn CrossSW_UP(D9); //EXT2
alt0710 28:eab9de9eb81a 17 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 28:eab9de9eb81a 18 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 28:eab9de9eb81a 19 DigitalIn DUMY(D8); //KICK
alt0710 28:eab9de9eb81a 20 InterruptIn CrossSW_RIGHT(A1); //EXT
alt0710 28:eab9de9eb81a 21 #elif 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 28:eab9de9eb81a 26 InterruptIn CrossSW_UP(D9); //EXT2
alt0710 28:eab9de9eb81a 27 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 28:eab9de9eb81a 28 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 28:eab9de9eb81a 29 DigitalIn DUMY(A1); //KICK
alt0710 28:eab9de9eb81a 30 InterruptIn CrossSW_RIGHT(D8); //EXT
alt0710 28:eab9de9eb81a 31 #else
alt0710 23:0bb032ef1880 32 //ModeSelectSW
alt0710 23:0bb032ef1880 33 DigitalIn Mode_SW1(A3);
alt0710 23:0bb032ef1880 34 DigitalIn Mode_SW2(A2);
alt0710 23:0bb032ef1880 35 //CrossSelectSW
alt0710 23:0bb032ef1880 36 InterruptIn CrossSW_UP(D11); //EXT2
alt0710 23:0bb032ef1880 37 InterruptIn CrossSW_LEFT(D7); //PUSH D7
alt0710 23:0bb032ef1880 38 //InterruptIn CrossSW_DOWN(D9); //KICK
alt0710 23:0bb032ef1880 39 DigitalIn DUMY(D8); //KICK
alt0710 23:0bb032ef1880 40 InterruptIn CrossSW_RIGHT(A1); //EXT
alt0710 23:0bb032ef1880 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 0:d4b98dbcb767 52
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 12:b7d7523733cd 67 //void check_click_down(void)
alt0710 12:b7d7523733cd 68 //{
alt0710 12:b7d7523733cd 69 // if(InterfaceManager::button.count_click[1] == 1)
alt0710 12:b7d7523733cd 70 // {
alt0710 12:b7d7523733cd 71 // InterfaceManager::button.setButtunStatus(CROSS_DOWN, SINGLE_CLICK);
alt0710 12:b7d7523733cd 72 // }
alt0710 12:b7d7523733cd 73 // else if(InterfaceManager::button.count_click[1] == 2)
alt0710 12:b7d7523733cd 74 // {
alt0710 12:b7d7523733cd 75 // InterfaceManager::button.setButtunStatus(CROSS_DOWN, DOUBLE_CLICK);
alt0710 12:b7d7523733cd 76 // }
alt0710 12:b7d7523733cd 77 // InterfaceManager::button.count_click[1] = 0;
alt0710 12:b7d7523733cd 78 // t_down.detach();
alt0710 12:b7d7523733cd 79 //}
alt0710 0:d4b98dbcb767 80 void check_click_left(void)
alt0710 0:d4b98dbcb767 81 {
alt0710 0:d4b98dbcb767 82 if(InterfaceManager::button.count_click[2] == 1)
alt0710 0:d4b98dbcb767 83 {
alt0710 0:d4b98dbcb767 84 InterfaceManager::button.setButtunStatus(CROSS_LEFT, SINGLE_CLICK);
alt0710 0:d4b98dbcb767 85 }
alt0710 0:d4b98dbcb767 86 else if(InterfaceManager::button.count_click[2] == 2)
alt0710 0:d4b98dbcb767 87 {
alt0710 0:d4b98dbcb767 88 InterfaceManager::button.setButtunStatus(CROSS_LEFT, DOUBLE_CLICK);
alt0710 0:d4b98dbcb767 89 }
alt0710 0:d4b98dbcb767 90 InterfaceManager::button.count_click[2] = 0;
alt0710 0:d4b98dbcb767 91 t_left.detach();
alt0710 0:d4b98dbcb767 92 }
alt0710 0:d4b98dbcb767 93 void check_click_right(void)
alt0710 0:d4b98dbcb767 94 {
alt0710 0:d4b98dbcb767 95 if(InterfaceManager::button.count_click[3] == 1)
alt0710 0:d4b98dbcb767 96 {
alt0710 0:d4b98dbcb767 97 InterfaceManager::button.setButtunStatus(CROSS_RIGHT, SINGLE_CLICK);
alt0710 0:d4b98dbcb767 98 }
alt0710 0:d4b98dbcb767 99 else if(InterfaceManager::button.count_click[3] == 2)
alt0710 0:d4b98dbcb767 100 {
alt0710 0:d4b98dbcb767 101 InterfaceManager::button.setButtunStatus(CROSS_RIGHT, DOUBLE_CLICK);
alt0710 0:d4b98dbcb767 102 }
alt0710 0:d4b98dbcb767 103 InterfaceManager::button.count_click[3] = 0;
alt0710 0:d4b98dbcb767 104 t_right.detach();
alt0710 0:d4b98dbcb767 105
alt0710 0:d4b98dbcb767 106 }
alt0710 0:d4b98dbcb767 107
alt0710 20:354ed2681d0a 108 void click_up(void)
alt0710 20:354ed2681d0a 109 {
alt0710 20:354ed2681d0a 110 myled = !myled;
alt0710 20:354ed2681d0a 111 switch(InterfaceManager::button.count_click[0]){
alt0710 20:354ed2681d0a 112 case 0:
alt0710 20:354ed2681d0a 113 t_up.attach(check_click_up, CHECK_TIME);
alt0710 20:354ed2681d0a 114 InterfaceManager::button.count_click[0]++;
alt0710 20:354ed2681d0a 115 break;
alt0710 20:354ed2681d0a 116
alt0710 20:354ed2681d0a 117 case 1:
alt0710 20:354ed2681d0a 118 InterfaceManager::button.count_click[0]++;
alt0710 20:354ed2681d0a 119 break;
alt0710 20:354ed2681d0a 120
alt0710 20:354ed2681d0a 121 default:
alt0710 20:354ed2681d0a 122 InterfaceManager::button.count_click[0] = 0;
alt0710 20:354ed2681d0a 123 break;
alt0710 20:354ed2681d0a 124 }
alt0710 20:354ed2681d0a 125
alt0710 20:354ed2681d0a 126 }
alt0710 12:b7d7523733cd 127 //void click_down(void)
alt0710 12:b7d7523733cd 128 //{
alt0710 12:b7d7523733cd 129 // myled = !myled;
alt0710 12:b7d7523733cd 130 // switch(InterfaceManager::button.count_click[1]){
alt0710 12:b7d7523733cd 131 // case 0:
alt0710 12:b7d7523733cd 132 // t_down.attach(check_click_down, CHECK_TIME);
alt0710 12:b7d7523733cd 133 // InterfaceManager::button.count_click[1]++;
alt0710 12:b7d7523733cd 134 // break;
alt0710 12:b7d7523733cd 135 //
alt0710 12:b7d7523733cd 136 // case 1:
alt0710 12:b7d7523733cd 137 // InterfaceManager::button.count_click[1]++;
alt0710 12:b7d7523733cd 138 // break;
alt0710 12:b7d7523733cd 139 //
alt0710 12:b7d7523733cd 140 // default:
alt0710 12:b7d7523733cd 141 // InterfaceManager::button.count_click[1] = 0;
alt0710 12:b7d7523733cd 142 // break;
alt0710 12:b7d7523733cd 143 // }
alt0710 12:b7d7523733cd 144 //
alt0710 12:b7d7523733cd 145 //}
alt0710 0:d4b98dbcb767 146 void click_left(void)
alt0710 0:d4b98dbcb767 147 {
alt0710 5:4be30999853f 148 myled = !myled;
alt0710 0:d4b98dbcb767 149 switch(InterfaceManager::button.count_click[2]){
alt0710 0:d4b98dbcb767 150 case 0:
alt0710 0:d4b98dbcb767 151 t_left.attach(check_click_left, CHECK_TIME);
alt0710 0:d4b98dbcb767 152 InterfaceManager::button.count_click[2]++;
alt0710 0:d4b98dbcb767 153 break;
alt0710 0:d4b98dbcb767 154
alt0710 0:d4b98dbcb767 155 case 1:
alt0710 0:d4b98dbcb767 156 InterfaceManager::button.count_click[2]++;
alt0710 0:d4b98dbcb767 157 break;
alt0710 0:d4b98dbcb767 158
alt0710 0:d4b98dbcb767 159 default:
alt0710 0:d4b98dbcb767 160 InterfaceManager::button.count_click[2] = 0;
alt0710 0:d4b98dbcb767 161 break;
alt0710 0:d4b98dbcb767 162 }
alt0710 0:d4b98dbcb767 163
alt0710 0:d4b98dbcb767 164 }
alt0710 0:d4b98dbcb767 165 void click_right(void)
alt0710 0:d4b98dbcb767 166 {
alt0710 5:4be30999853f 167 myled = !myled;
alt0710 0:d4b98dbcb767 168 switch(InterfaceManager::button.count_click[3]){
alt0710 0:d4b98dbcb767 169 case 0:
alt0710 0:d4b98dbcb767 170 t_right.attach(check_click_right, CHECK_TIME);
alt0710 0:d4b98dbcb767 171 InterfaceManager::button.count_click[3]++;
alt0710 0:d4b98dbcb767 172 break;
alt0710 0:d4b98dbcb767 173
alt0710 0:d4b98dbcb767 174 case 1:
alt0710 0:d4b98dbcb767 175 InterfaceManager::button.count_click[3]++;
alt0710 0:d4b98dbcb767 176 break;
alt0710 0:d4b98dbcb767 177
alt0710 0:d4b98dbcb767 178 default:
alt0710 0:d4b98dbcb767 179 InterfaceManager::button.count_click[3] = 0;
alt0710 0:d4b98dbcb767 180 break;
alt0710 0:d4b98dbcb767 181 }
alt0710 0:d4b98dbcb767 182
alt0710 0:d4b98dbcb767 183 }
alt0710 0:d4b98dbcb767 184
alt0710 0:d4b98dbcb767 185
alt0710 0:d4b98dbcb767 186 /* **グルーバル関数** */
alt0710 0:d4b98dbcb767 187 void initButton(void)
alt0710 0:d4b98dbcb767 188 {
alt0710 4:8c6f6b687303 189 Mode_SW1.mode(PullDown);
alt0710 4:8c6f6b687303 190 Mode_SW2.mode(PullDown);
alt0710 0:d4b98dbcb767 191
alt0710 20:354ed2681d0a 192 CrossSW_UP.mode(PullNone);
alt0710 12:b7d7523733cd 193 //CrossSW_DOWN.mode(PullNone);
alt0710 5:4be30999853f 194 DUMY.mode(PullNone);
alt0710 5:4be30999853f 195 CrossSW_LEFT.mode(PullNone);
alt0710 5:4be30999853f 196 CrossSW_RIGHT.mode(PullNone);
alt0710 0:d4b98dbcb767 197
alt0710 0:d4b98dbcb767 198 //入力割り込み設定
alt0710 20:354ed2681d0a 199 CrossSW_UP.fall(&click_up);
alt0710 5:4be30999853f 200 CrossSW_LEFT.fall(&click_left);
alt0710 12:b7d7523733cd 201 //CrossSW_DOWN.rise(&click_down);
alt0710 5:4be30999853f 202 CrossSW_RIGHT.fall(&click_right);
alt0710 0:d4b98dbcb767 203
alt0710 0:d4b98dbcb767 204 }
alt0710 0:d4b98dbcb767 205
alt0710 0:d4b98dbcb767 206 /* **クラス** */
alt0710 0:d4b98dbcb767 207 Button_Roots::Button_Roots()
alt0710 0:d4b98dbcb767 208 {
alt0710 0:d4b98dbcb767 209 modeSW1 = 0;
alt0710 0:d4b98dbcb767 210 modeSW2 = 0;
alt0710 0:d4b98dbcb767 211 modeSW = 0;
alt0710 0:d4b98dbcb767 212 crossUp = 0;
alt0710 0:d4b98dbcb767 213 crossDown = 0;
alt0710 0:d4b98dbcb767 214 crossLeft = 0;
alt0710 0:d4b98dbcb767 215 crossRight = 0;
alt0710 0:d4b98dbcb767 216
alt0710 0:d4b98dbcb767 217 }
alt0710 0:d4b98dbcb767 218 char Button_Roots::getButtonStatus(char ButtonNames)
alt0710 0:d4b98dbcb767 219 {
alt0710 0:d4b98dbcb767 220 switch(ButtonNames){
alt0710 0:d4b98dbcb767 221 case MODE_SW1:
alt0710 4:8c6f6b687303 222 return !Mode_SW1;
alt0710 0:d4b98dbcb767 223
alt0710 0:d4b98dbcb767 224 case MODE_SW2:
alt0710 4:8c6f6b687303 225 return !Mode_SW2;
alt0710 0:d4b98dbcb767 226
alt0710 0:d4b98dbcb767 227 case MODE_SW:
alt0710 4:8c6f6b687303 228 modeSW = !Mode_SW1 + (!Mode_SW2 << 1);
alt0710 0:d4b98dbcb767 229 return modeSW;
alt0710 0:d4b98dbcb767 230
alt0710 0:d4b98dbcb767 231 case CROSS_UP:
alt0710 5:4be30999853f 232 button_status = crossUp;
alt0710 5:4be30999853f 233 crossUp = 0;
alt0710 5:4be30999853f 234 return button_status;
alt0710 0:d4b98dbcb767 235
alt0710 0:d4b98dbcb767 236 case CROSS_DOWN:
alt0710 5:4be30999853f 237 if( (!DUMY) && (cross_down_old == 1) ){
alt0710 5:4be30999853f 238 is_button_pushed = 1;
alt0710 5:4be30999853f 239 }else{
alt0710 5:4be30999853f 240 is_button_pushed = 0;
alt0710 5:4be30999853f 241 }
alt0710 5:4be30999853f 242 cross_down_old = !DUMY;
alt0710 5:4be30999853f 243 button_status = is_button_pushed;
alt0710 5:4be30999853f 244 //crossDown = 0;
alt0710 5:4be30999853f 245 return button_status;
alt0710 0:d4b98dbcb767 246
alt0710 0:d4b98dbcb767 247 case CROSS_LEFT:
alt0710 5:4be30999853f 248 button_status = crossLeft;
alt0710 5:4be30999853f 249 crossLeft = 0;
alt0710 5:4be30999853f 250 return button_status;
alt0710 0:d4b98dbcb767 251
alt0710 0:d4b98dbcb767 252 case CROSS_RIGHT:
alt0710 5:4be30999853f 253 button_status = crossRight;
alt0710 5:4be30999853f 254 crossRight = 0;
alt0710 5:4be30999853f 255 return button_status;
alt0710 0:d4b98dbcb767 256
alt0710 0:d4b98dbcb767 257 default:
alt0710 0:d4b98dbcb767 258 return 99;
alt0710 0:d4b98dbcb767 259
alt0710 0:d4b98dbcb767 260 }
alt0710 0:d4b98dbcb767 261
alt0710 0:d4b98dbcb767 262 }
alt0710 0:d4b98dbcb767 263 char Button_Roots::setButtunStatus(char ButtonNames, char ButtonStatus)
alt0710 0:d4b98dbcb767 264 {
alt0710 0:d4b98dbcb767 265 switch(ButtonNames){
alt0710 0:d4b98dbcb767 266 case MODE_SW1:
alt0710 0:d4b98dbcb767 267 return modeSW1 = ButtonStatus;
alt0710 0:d4b98dbcb767 268
alt0710 0:d4b98dbcb767 269 case MODE_SW2:
alt0710 0:d4b98dbcb767 270 return modeSW2 = ButtonStatus;
alt0710 0:d4b98dbcb767 271
alt0710 0:d4b98dbcb767 272 case CROSS_UP:
alt0710 0:d4b98dbcb767 273 return crossUp = ButtonStatus;
alt0710 0:d4b98dbcb767 274
alt0710 0:d4b98dbcb767 275 case CROSS_DOWN:
alt0710 0:d4b98dbcb767 276 return crossDown = ButtonStatus;
alt0710 0:d4b98dbcb767 277
alt0710 0:d4b98dbcb767 278 case CROSS_LEFT:
alt0710 0:d4b98dbcb767 279 return crossLeft = ButtonStatus;
alt0710 0:d4b98dbcb767 280
alt0710 0:d4b98dbcb767 281 case CROSS_RIGHT:
alt0710 0:d4b98dbcb767 282 return crossRight = ButtonStatus;
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 }