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:
Sat Apr 28 07:18:22 2018 +0000
Revision:
23:0bb032ef1880
Parent:
20:354ed2681d0a
Child:
28:eab9de9eb81a
???????????????????????

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