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:
Mon May 29 16:45:16 2017 +0000
Revision:
20:354ed2681d0a
Parent:
19:0bbd90be9aa3
Child:
21:d18c2dfaaba4
testMode???; ??????????????????????????????????; ??????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alt0710 14:f6cc949a8046 1
alt0710 14:f6cc949a8046 2 #include "mbed.h"
alt0710 14:f6cc949a8046 3 #include "comm.h"
alt0710 14:f6cc949a8046 4 #include "mode.h"
alt0710 14:f6cc949a8046 5 #include "interface_manager.h"
alt0710 14:f6cc949a8046 6 #include "status_manager.h"
alt0710 14:f6cc949a8046 7 #include "parameter_manager.h"
alt0710 14:f6cc949a8046 8 #include "operation_check.h"
alt0710 14:f6cc949a8046 9
alt0710 14:f6cc949a8046 10 /* **mbedクラス** */
alt0710 14:f6cc949a8046 11 #ifdef LPC4088
alt0710 14:f6cc949a8046 12
alt0710 14:f6cc949a8046 13 #elif STM32
alt0710 14:f6cc949a8046 14
alt0710 14:f6cc949a8046 15 #endif
alt0710 14:f6cc949a8046 16
alt0710 14:f6cc949a8046 17 /* **ローカル関数定義** */
alt0710 14:f6cc949a8046 18
alt0710 14:f6cc949a8046 19 /* **ローカル関数** */
alt0710 14:f6cc949a8046 20
alt0710 14:f6cc949a8046 21 /* **グルーバル関数** */
alt0710 14:f6cc949a8046 22
alt0710 14:f6cc949a8046 23 /* **クラス** */
alt0710 14:f6cc949a8046 24 class InterfaceManager;
alt0710 14:f6cc949a8046 25 class StatusManager;
alt0710 14:f6cc949a8046 26 class ParameterManager;
alt0710 14:f6cc949a8046 27
alt0710 14:f6cc949a8046 28
alt0710 14:f6cc949a8046 29 //メンバ変数の初期化は、定義順(Warningになる)
alt0710 14:f6cc949a8046 30 OperationCheck::OperationCheck()
alt0710 20:354ed2681d0a 31 :checkMode(SELECT),
alt0710 20:354ed2681d0a 32 button_count(0),
alt0710 20:354ed2681d0a 33 sideSW_num(0),
alt0710 15:2bf8eafacef8 34 charge_flag(0),
alt0710 15:2bf8eafacef8 35 kick_flag(0),
alt0710 19:0bbd90be9aa3 36 power(0),
alt0710 19:0bbd90be9aa3 37 ball(0)
alt0710 14:f6cc949a8046 38 {
alt0710 14:f6cc949a8046 39 }
alt0710 14:f6cc949a8046 40
alt0710 14:f6cc949a8046 41 void OperationCheck::run(void)
alt0710 14:f6cc949a8046 42 {
alt0710 20:354ed2681d0a 43 switch(checkMode)
alt0710 15:2bf8eafacef8 44 {
alt0710 20:354ed2681d0a 45 case SELECT:
alt0710 20:354ed2681d0a 46 selectCheckMode();
alt0710 20:354ed2681d0a 47 viewSelect();
alt0710 20:354ed2681d0a 48 break;
alt0710 20:354ed2681d0a 49
alt0710 20:354ed2681d0a 50 case WHEEL:
alt0710 20:354ed2681d0a 51 sprintf(str,"WHEEL");
alt0710 20:354ed2681d0a 52 checkBack();
alt0710 20:354ed2681d0a 53 break;
alt0710 20:354ed2681d0a 54
alt0710 20:354ed2681d0a 55 case DRIBBLE:
alt0710 20:354ed2681d0a 56 sprintf(str,"DRIBBLE");
alt0710 20:354ed2681d0a 57 checkBack();
alt0710 20:354ed2681d0a 58 break;
alt0710 20:354ed2681d0a 59
alt0710 20:354ed2681d0a 60 case STR_KICK:
alt0710 20:354ed2681d0a 61 sprintf(str,"STR_KICK");
alt0710 20:354ed2681d0a 62 checkBack();
alt0710 20:354ed2681d0a 63 break;
alt0710 20:354ed2681d0a 64
alt0710 20:354ed2681d0a 65 case CHIP_KICK:
alt0710 20:354ed2681d0a 66 sprintf(str,"CHO_KICK");
alt0710 20:354ed2681d0a 67 checkBack();
alt0710 20:354ed2681d0a 68 break;
alt0710 20:354ed2681d0a 69
alt0710 20:354ed2681d0a 70 default:
alt0710 20:354ed2681d0a 71 sprintf(str,"ERROR");
alt0710 20:354ed2681d0a 72 break;
alt0710 15:2bf8eafacef8 73 }
alt0710 20:354ed2681d0a 74 // //充電:左
alt0710 20:354ed2681d0a 75 // //強制放電:下
alt0710 20:354ed2681d0a 76 // //キック:上
alt0710 20:354ed2681d0a 77 // /* ***************** 充電 ******************************* */
alt0710 20:354ed2681d0a 78 // if(InterfaceManager::button.getButtonStatus(CROSS_LEFT))
alt0710 20:354ed2681d0a 79 // {
alt0710 20:354ed2681d0a 80 // charge_flag = 1;
alt0710 20:354ed2681d0a 81 // }
alt0710 20:354ed2681d0a 82 // if(StatusManager::is_kicking == 1)
alt0710 20:354ed2681d0a 83 // {
alt0710 20:354ed2681d0a 84 // charge_flag = 0;
alt0710 20:354ed2681d0a 85 // kick_flag = 0;
alt0710 20:354ed2681d0a 86 // }
alt0710 20:354ed2681d0a 87 //
alt0710 20:354ed2681d0a 88 // /* ***************** キック ******************************* */
alt0710 20:354ed2681d0a 89 // if(InterfaceManager::button.getButtonStatus(CROSS_UP))
alt0710 20:354ed2681d0a 90 // {
alt0710 20:354ed2681d0a 91 // kick_flag = 1;
alt0710 20:354ed2681d0a 92 // }
alt0710 20:354ed2681d0a 93 //
alt0710 20:354ed2681d0a 94 // /* ***************** 威力 ******************************* */
alt0710 20:354ed2681d0a 95 // if(InterfaceManager::button.getButtonStatus(CROSS_RIGHT))
alt0710 20:354ed2681d0a 96 // {
alt0710 20:354ed2681d0a 97 // power++;
alt0710 20:354ed2681d0a 98 // if(power > 15)
alt0710 20:354ed2681d0a 99 // {
alt0710 20:354ed2681d0a 100 // power = 0;
alt0710 20:354ed2681d0a 101 // }
alt0710 20:354ed2681d0a 102 // }
alt0710 20:354ed2681d0a 103 //
alt0710 20:354ed2681d0a 104 // if(InterfaceManager::button.getButtonStatus(CROSS_DOWN))
alt0710 20:354ed2681d0a 105 // {
alt0710 20:354ed2681d0a 106 // dribble.setdribble(1, power);
alt0710 20:354ed2681d0a 107 // }
alt0710 20:354ed2681d0a 108 // else
alt0710 20:354ed2681d0a 109 // {
alt0710 20:354ed2681d0a 110 // dribble.setdribble(0, 0);
alt0710 20:354ed2681d0a 111 // }
alt0710 20:354ed2681d0a 112 //
alt0710 20:354ed2681d0a 113 // if(InterfaceManager::ball_sensor)
alt0710 20:354ed2681d0a 114 // {
alt0710 20:354ed2681d0a 115 // ball = 1;
alt0710 20:354ed2681d0a 116 // }
alt0710 20:354ed2681d0a 117 // else
alt0710 20:354ed2681d0a 118 // {
alt0710 20:354ed2681d0a 119 // ball = 0;
alt0710 20:354ed2681d0a 120 // }
alt0710 20:354ed2681d0a 121 // /* ***************** 強制放電 ***************************** */
alt0710 20:354ed2681d0a 122 //// kicker.setCharge(charge_flag);
alt0710 20:354ed2681d0a 123 //// kicker.setKick(kick_flag, STRAIGHT, power);
alt0710 20:354ed2681d0a 124 //// kicker.forceFireKick();
alt0710 20:354ed2681d0a 125 //
alt0710 20:354ed2681d0a 126 // //createLcdData();
alt0710 20:354ed2681d0a 127 // sprintf(str,"F:%dP:%d\nB:%dK:%d",charge_flag,power,ball,kick_flag);
alt0710 20:354ed2681d0a 128 // //sprintf(str,"Hello");
alt0710 20:354ed2681d0a 129 InterfaceManager::i2c.setLCDMsg(str,sizeof(str));
alt0710 20:354ed2681d0a 130
alt0710 20:354ed2681d0a 131 }
alt0710 20:354ed2681d0a 132
alt0710 20:354ed2681d0a 133 void OperationCheck::selectCheckMode(void)
alt0710 20:354ed2681d0a 134 {
alt0710 20:354ed2681d0a 135 if(InterfaceManager::button.getButtonStatus(CROSS_RIGHT))
alt0710 15:2bf8eafacef8 136 {
alt0710 20:354ed2681d0a 137 button_count++;
alt0710 15:2bf8eafacef8 138 }
alt0710 14:f6cc949a8046 139
alt0710 20:354ed2681d0a 140 if(InterfaceManager::button.getButtonStatus(CROSS_LEFT))
alt0710 15:2bf8eafacef8 141 {
alt0710 20:354ed2681d0a 142 button_count--;
alt0710 20:354ed2681d0a 143 }
alt0710 20:354ed2681d0a 144
alt0710 20:354ed2681d0a 145 if(button_count > 3)
alt0710 20:354ed2681d0a 146 {
alt0710 20:354ed2681d0a 147 button_count = 0;
alt0710 20:354ed2681d0a 148 }
alt0710 20:354ed2681d0a 149 if(button_count < 0)
alt0710 20:354ed2681d0a 150 {
alt0710 20:354ed2681d0a 151 button_count = 3;
alt0710 15:2bf8eafacef8 152 }
alt0710 15:2bf8eafacef8 153
alt0710 20:354ed2681d0a 154 if(InterfaceManager::button.getButtonStatus(CROSS_UP))
alt0710 15:2bf8eafacef8 155 {
alt0710 20:354ed2681d0a 156 switch(button_count)
alt0710 15:2bf8eafacef8 157 {
alt0710 20:354ed2681d0a 158 case 0:
alt0710 20:354ed2681d0a 159 checkMode = WHEEL;
alt0710 20:354ed2681d0a 160 break;
alt0710 20:354ed2681d0a 161
alt0710 20:354ed2681d0a 162 case 1:
alt0710 20:354ed2681d0a 163 checkMode = DRIBBLE;
alt0710 20:354ed2681d0a 164 break;
alt0710 20:354ed2681d0a 165
alt0710 20:354ed2681d0a 166 case 2:
alt0710 20:354ed2681d0a 167 checkMode = STR_KICK;
alt0710 20:354ed2681d0a 168 break;
alt0710 20:354ed2681d0a 169
alt0710 20:354ed2681d0a 170 case 3:
alt0710 20:354ed2681d0a 171 checkMode = CHIP_KICK;
alt0710 20:354ed2681d0a 172 break;
alt0710 20:354ed2681d0a 173
alt0710 20:354ed2681d0a 174 default:
alt0710 20:354ed2681d0a 175 checkMode = SELECT;
alt0710 20:354ed2681d0a 176 break;
alt0710 15:2bf8eafacef8 177 }
alt0710 15:2bf8eafacef8 178 }
alt0710 20:354ed2681d0a 179
alt0710 20:354ed2681d0a 180 }
alt0710 19:0bbd90be9aa3 181
alt0710 20:354ed2681d0a 182 void OperationCheck::viewSelect(void)
alt0710 20:354ed2681d0a 183 {
alt0710 20:354ed2681d0a 184 switch(button_count)
alt0710 19:0bbd90be9aa3 185 {
alt0710 20:354ed2681d0a 186 case 0:
alt0710 20:354ed2681d0a 187 sprintf(str,"CHECK\nWHEEL");
alt0710 20:354ed2681d0a 188 break;
alt0710 20:354ed2681d0a 189
alt0710 20:354ed2681d0a 190 case 1:
alt0710 20:354ed2681d0a 191 sprintf(str,"CHECK\nDRIBBLE");
alt0710 20:354ed2681d0a 192 break;
alt0710 20:354ed2681d0a 193
alt0710 20:354ed2681d0a 194 case 2:
alt0710 20:354ed2681d0a 195 sprintf(str,"CHECK\nSTR_KICK");
alt0710 20:354ed2681d0a 196 break;
alt0710 20:354ed2681d0a 197
alt0710 20:354ed2681d0a 198 case 3:
alt0710 20:354ed2681d0a 199 sprintf(str,"CHECK\nCHP_KICK");
alt0710 20:354ed2681d0a 200 break;
alt0710 20:354ed2681d0a 201
alt0710 20:354ed2681d0a 202 default:
alt0710 20:354ed2681d0a 203 sprintf(str,"ERROR");
alt0710 20:354ed2681d0a 204 break;
alt0710 20:354ed2681d0a 205 }
alt0710 20:354ed2681d0a 206 }
alt0710 20:354ed2681d0a 207
alt0710 20:354ed2681d0a 208 void OperationCheck::checkBack(void)
alt0710 20:354ed2681d0a 209 {
alt0710 20:354ed2681d0a 210 if(InterfaceManager::button.getButtonStatus(CROSS_UP))
alt0710 20:354ed2681d0a 211 {
alt0710 20:354ed2681d0a 212 checkMode = SELECT;
alt0710 19:0bbd90be9aa3 213 }
alt0710 15:2bf8eafacef8 214
alt0710 14:f6cc949a8046 215 }
alt0710 14:f6cc949a8046 216
alt0710 14:f6cc949a8046 217 void OperationCheck::createLcdData(void)
alt0710 14:f6cc949a8046 218 {
alt0710 14:f6cc949a8046 219
alt0710 14:f6cc949a8046 220 /*
alt0710 14:f6cc949a8046 221
alt0710 14:f6cc949a8046 222 * 0 : 正常終了
alt0710 14:f6cc949a8046 223
alt0710 14:f6cc949a8046 224 * -1 : タイムアウト
alt0710 14:f6cc949a8046 225
alt0710 14:f6cc949a8046 226 * -2 : オーバーランエラー
alt0710 14:f6cc949a8046 227
alt0710 14:f6cc949a8046 228 * -3 : フレーミングエラー
alt0710 14:f6cc949a8046 229
alt0710 14:f6cc949a8046 230 * 1 : 受信中
alt0710 14:f6cc949a8046 231
alt0710 14:f6cc949a8046 232 * 2 : フレームリーダー1まで受信
alt0710 14:f6cc949a8046 233
alt0710 14:f6cc949a8046 234 * 3 : フレームリーダー2まで受信
alt0710 14:f6cc949a8046 235
alt0710 14:f6cc949a8046 236 * 4 : マシンIDまで受信
alt0710 14:f6cc949a8046 237
alt0710 14:f6cc949a8046 238 */
alt0710 14:f6cc949a8046 239 switch(StatusManager::uart){
alt0710 14:f6cc949a8046 240 case 0:
alt0710 14:f6cc949a8046 241 sprintf(str,"ID%d EN:\nComplete",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 242
alt0710 14:f6cc949a8046 243 break;
alt0710 14:f6cc949a8046 244
alt0710 14:f6cc949a8046 245 case 1:
alt0710 14:f6cc949a8046 246 break;
alt0710 14:f6cc949a8046 247
alt0710 14:f6cc949a8046 248 case 2:
alt0710 14:f6cc949a8046 249 sprintf(str,"ID%d EN:\nHeader1",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 250
alt0710 14:f6cc949a8046 251 break;
alt0710 14:f6cc949a8046 252
alt0710 14:f6cc949a8046 253 case 3:
alt0710 14:f6cc949a8046 254 sprintf(str,"ID%d EN:\nHeader2",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 255
alt0710 14:f6cc949a8046 256 break;
alt0710 14:f6cc949a8046 257
alt0710 14:f6cc949a8046 258 case 4:
alt0710 14:f6cc949a8046 259 sprintf(str,"ID%d EN:\nCheckER1",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 260
alt0710 14:f6cc949a8046 261 break;
alt0710 14:f6cc949a8046 262
alt0710 14:f6cc949a8046 263 case 5:
alt0710 14:f6cc949a8046 264 sprintf(str,"ID%d EN:\nCheckER2",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 265
alt0710 14:f6cc949a8046 266 break;
alt0710 14:f6cc949a8046 267
alt0710 14:f6cc949a8046 268 case -1:
alt0710 14:f6cc949a8046 269 sprintf(str,"ID%d EN:\nTimeOut",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 270
alt0710 14:f6cc949a8046 271 break;
alt0710 14:f6cc949a8046 272
alt0710 14:f6cc949a8046 273 case -2:
alt0710 14:f6cc949a8046 274 sprintf(str,"ID%d EN:\nOERR",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 275
alt0710 14:f6cc949a8046 276 break;
alt0710 14:f6cc949a8046 277
alt0710 14:f6cc949a8046 278 case -3:
alt0710 14:f6cc949a8046 279 sprintf(str,"ID%d EN:\nFERR",ParameterManager::machine_id);
alt0710 14:f6cc949a8046 280
alt0710 14:f6cc949a8046 281 break;
alt0710 14:f6cc949a8046 282
alt0710 14:f6cc949a8046 283 default:
alt0710 14:f6cc949a8046 284 sprintf(str,"ID%d EN: \n %d",ParameterManager::machine_id, StatusManager::uart);
alt0710 14:f6cc949a8046 285 break;
alt0710 14:f6cc949a8046 286 }
alt0710 14:f6cc949a8046 287
alt0710 14:f6cc949a8046 288 }