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 Apr 25 11:45:41 2017 +0000
Revision:
4:8c6f6b687303
Parent:
0:d4b98dbcb767
Child:
5:4be30999853f
?????????????

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