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:
15:2bf8eafacef8
Child:
25:15f75825fc36
testMode???; ??????????????????????????????????; ??????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alt0710 3:6f87cbec2ae8 1
alt0710 3:6f87cbec2ae8 2 #include "mbed.h"
alt0710 3:6f87cbec2ae8 3 #include "comm.h"
alt0710 3:6f87cbec2ae8 4 #include "interface_manager.h"
alt0710 3:6f87cbec2ae8 5 #include "parameter_manager.h"
alt0710 3:6f87cbec2ae8 6 #include "kicker.h"
alt0710 3:6f87cbec2ae8 7
alt0710 3:6f87cbec2ae8 8 /* **mbedクラス** */
alt0710 3:6f87cbec2ae8 9 #ifdef LPC4088
alt0710 3:6f87cbec2ae8 10
alt0710 3:6f87cbec2ae8 11 #elif STM32
alt0710 3:6f87cbec2ae8 12 Ticker kickTimer;
alt0710 3:6f87cbec2ae8 13 #endif
alt0710 3:6f87cbec2ae8 14
alt0710 3:6f87cbec2ae8 15 /* **ローカル関数定義** */
alt0710 3:6f87cbec2ae8 16 void fireTimer(void);
alt0710 3:6f87cbec2ae8 17 void driveFireTimer(double firetime);
alt0710 3:6f87cbec2ae8 18
alt0710 3:6f87cbec2ae8 19 /* **ローカル関数** */
alt0710 3:6f87cbec2ae8 20 void fireTimer(void)
alt0710 3:6f87cbec2ae8 21 {
alt0710 3:6f87cbec2ae8 22 InterfaceManager::straight_kick = 0;
alt0710 3:6f87cbec2ae8 23 InterfaceManager::chip_kick = 0;
alt0710 3:6f87cbec2ae8 24 StatusManager::is_kicking = 0;
alt0710 3:6f87cbec2ae8 25 kickTimer.detach();
alt0710 3:6f87cbec2ae8 26 return;
alt0710 3:6f87cbec2ae8 27 }
alt0710 3:6f87cbec2ae8 28
alt0710 3:6f87cbec2ae8 29 void driveFireTimer(double firetime)
alt0710 3:6f87cbec2ae8 30 {
alt0710 3:6f87cbec2ae8 31 kickTimer.attach(&fireTimer,firetime);
alt0710 3:6f87cbec2ae8 32 }
alt0710 3:6f87cbec2ae8 33
alt0710 3:6f87cbec2ae8 34 /* **グルーバル関数** */
alt0710 3:6f87cbec2ae8 35
alt0710 3:6f87cbec2ae8 36 /* **クラス** */
alt0710 3:6f87cbec2ae8 37 //メンバ変数の初期化は、定義順(Warningになる)
alt0710 3:6f87cbec2ae8 38 Kicker::Kicker()
alt0710 3:6f87cbec2ae8 39 :ball(IS_NOT_EXIST),
alt0710 3:6f87cbec2ae8 40 kickPermit(DISABLE),
alt0710 3:6f87cbec2ae8 41 f_kick(0),
alt0710 3:6f87cbec2ae8 42 f_charge_fin(0),
alt0710 3:6f87cbec2ae8 43 kickType(STRAIGHT),
alt0710 3:6f87cbec2ae8 44 power(0),
alt0710 3:6f87cbec2ae8 45 f_charge(0),
alt0710 3:6f87cbec2ae8 46 isRelease(0),
alt0710 10:9cd22f673968 47 fireTime(0),
alt0710 10:9cd22f673968 48 count_continue_delay(0),
alt0710 10:9cd22f673968 49 count_num_of_kick(0),
alt0710 10:9cd22f673968 50 mode_discharge(0)
alt0710 3:6f87cbec2ae8 51 {
alt0710 3:6f87cbec2ae8 52 }
alt0710 3:6f87cbec2ae8 53
alt0710 3:6f87cbec2ae8 54 void Kicker::setKick(char flag_kick, char kick_Type, char kick_power)
alt0710 3:6f87cbec2ae8 55 {
alt0710 15:2bf8eafacef8 56
alt0710 3:6f87cbec2ae8 57 f_kick = flag_kick;
alt0710 3:6f87cbec2ae8 58 kickType = kick_Type;
alt0710 3:6f87cbec2ae8 59 power = kick_power;
alt0710 3:6f87cbec2ae8 60
alt0710 6:21b3fbe57b88 61 checkBallSensor(); //ball
alt0710 15:2bf8eafacef8 62 checkChargeCompleted(); //f_charge_fin
alt0710 3:6f87cbec2ae8 63 if(f_kick == 1)
alt0710 3:6f87cbec2ae8 64 {
alt0710 3:6f87cbec2ae8 65 checkKickEnable();
alt0710 3:6f87cbec2ae8 66 if(kickPermit == ENABLE)
alt0710 3:6f87cbec2ae8 67 {
alt0710 10:9cd22f673968 68 fireKick(kickType, power);
alt0710 3:6f87cbec2ae8 69 }
alt0710 3:6f87cbec2ae8 70 }
alt0710 3:6f87cbec2ae8 71 }
alt0710 3:6f87cbec2ae8 72
alt0710 3:6f87cbec2ae8 73 void Kicker::setCharge(char flag_charge)
alt0710 3:6f87cbec2ae8 74 {
alt0710 3:6f87cbec2ae8 75 if(flag_charge && (StatusManager::is_kicking == 0))
alt0710 3:6f87cbec2ae8 76 {
alt0710 3:6f87cbec2ae8 77 f_charge = 1;
alt0710 6:21b3fbe57b88 78 InterfaceManager::charge_request = 1;
alt0710 3:6f87cbec2ae8 79 }
alt0710 3:6f87cbec2ae8 80 else
alt0710 3:6f87cbec2ae8 81 {
alt0710 3:6f87cbec2ae8 82 f_charge = 0;
alt0710 6:21b3fbe57b88 83 InterfaceManager::charge_request = 0;
alt0710 3:6f87cbec2ae8 84 }
alt0710 3:6f87cbec2ae8 85 StatusManager::req_charge = f_charge;
alt0710 3:6f87cbec2ae8 86 }
alt0710 3:6f87cbec2ae8 87
alt0710 10:9cd22f673968 88 void Kicker::fireKick(char t_KickType,char t_power)
alt0710 3:6f87cbec2ae8 89 {
alt0710 10:9cd22f673968 90 switch(t_KickType)
alt0710 3:6f87cbec2ae8 91 {
alt0710 3:6f87cbec2ae8 92 case STRAIGHT:
alt0710 15:2bf8eafacef8 93 InterfaceManager::LED = 1;
alt0710 3:6f87cbec2ae8 94 InterfaceManager::charge_request = 0;
alt0710 3:6f87cbec2ae8 95 StatusManager::is_kicking = 1;
alt0710 3:6f87cbec2ae8 96 InterfaceManager::straight_kick = 1;
alt0710 10:9cd22f673968 97 driveFireTimer(ParameterManager::kickpower.getChipPowerTime(t_power));
alt0710 3:6f87cbec2ae8 98 break;
alt0710 3:6f87cbec2ae8 99
alt0710 3:6f87cbec2ae8 100 case CHIP:
alt0710 3:6f87cbec2ae8 101 InterfaceManager::charge_request = 0;
alt0710 3:6f87cbec2ae8 102 StatusManager::is_kicking = 1;
alt0710 3:6f87cbec2ae8 103 InterfaceManager::chip_kick = 1;
alt0710 10:9cd22f673968 104 driveFireTimer(ParameterManager::kickpower.getStraightPowerTime(t_power));
alt0710 3:6f87cbec2ae8 105 break;
alt0710 3:6f87cbec2ae8 106
alt0710 3:6f87cbec2ae8 107 default:
alt0710 3:6f87cbec2ae8 108 InterfaceManager::straight_kick = 0;
alt0710 3:6f87cbec2ae8 109 InterfaceManager::chip_kick = 0;
alt0710 3:6f87cbec2ae8 110 break;
alt0710 3:6f87cbec2ae8 111 }
alt0710 3:6f87cbec2ae8 112 }
alt0710 3:6f87cbec2ae8 113
alt0710 10:9cd22f673968 114 void Kicker::forceFireKick(void)
alt0710 10:9cd22f673968 115 {
alt0710 10:9cd22f673968 116
alt0710 10:9cd22f673968 117
alt0710 10:9cd22f673968 118 if( InterfaceManager::button.getButtonStatus(CROSS_DOWN) == 1 ){
alt0710 10:9cd22f673968 119 mode_discharge = 1;
alt0710 10:9cd22f673968 120 }
alt0710 10:9cd22f673968 121
alt0710 10:9cd22f673968 122 if( mode_discharge == 0 ){
alt0710 10:9cd22f673968 123 count_continue_delay = 0;
alt0710 10:9cd22f673968 124 count_num_of_kick = 0;
alt0710 10:9cd22f673968 125 return;
alt0710 10:9cd22f673968 126 }
alt0710 10:9cd22f673968 127
alt0710 10:9cd22f673968 128 if( count_num_of_kick > NUM_OF_KICK ){
alt0710 10:9cd22f673968 129 mode_discharge = 0;
alt0710 10:9cd22f673968 130 return;
alt0710 10:9cd22f673968 131 }
alt0710 10:9cd22f673968 132
alt0710 10:9cd22f673968 133 if( StatusManager::is_kicking == 1 ){
alt0710 10:9cd22f673968 134 return;
alt0710 10:9cd22f673968 135 }
alt0710 10:9cd22f673968 136
alt0710 10:9cd22f673968 137 if( count_continue_delay < CONTINUE_DELAY ){
alt0710 10:9cd22f673968 138 count_continue_delay ++;
alt0710 10:9cd22f673968 139 return;
alt0710 10:9cd22f673968 140 }
alt0710 10:9cd22f673968 141
alt0710 10:9cd22f673968 142 count_continue_delay = 0;
alt0710 20:354ed2681d0a 143 fireKick(STRAIGHT, 2);
alt0710 10:9cd22f673968 144 StatusManager::is_kicking = 1;
alt0710 10:9cd22f673968 145 InterfaceManager::charge_request = 0;
alt0710 10:9cd22f673968 146
alt0710 10:9cd22f673968 147 count_num_of_kick++;
alt0710 10:9cd22f673968 148
alt0710 10:9cd22f673968 149 }
alt0710 10:9cd22f673968 150
alt0710 3:6f87cbec2ae8 151 void Kicker::checkKickEnable(void)
alt0710 3:6f87cbec2ae8 152 {
alt0710 3:6f87cbec2ae8 153
alt0710 15:2bf8eafacef8 154 //if( f_charge_fin )
alt0710 3:6f87cbec2ae8 155 if( f_charge_fin && (ball == IS_EXIST) && !isRelease && !StatusManager::is_kicking)
alt0710 3:6f87cbec2ae8 156 {
alt0710 15:2bf8eafacef8 157
alt0710 3:6f87cbec2ae8 158 kickPermit = ENABLE;
alt0710 3:6f87cbec2ae8 159 isRelease = 1;
alt0710 3:6f87cbec2ae8 160 f_charge_fin = 0;
alt0710 15:2bf8eafacef8 161 //StatusManager::charge_end = InterfaceManager::charge_completed;
alt0710 3:6f87cbec2ae8 162 }
alt0710 3:6f87cbec2ae8 163 else
alt0710 3:6f87cbec2ae8 164 {
alt0710 3:6f87cbec2ae8 165 kickPermit = DISABLE;
alt0710 3:6f87cbec2ae8 166 }
alt0710 3:6f87cbec2ae8 167
alt0710 3:6f87cbec2ae8 168 }
alt0710 3:6f87cbec2ae8 169
alt0710 3:6f87cbec2ae8 170 void Kicker::checkChargeCompleted(void)
alt0710 3:6f87cbec2ae8 171 {
alt0710 3:6f87cbec2ae8 172 //不論理
alt0710 3:6f87cbec2ae8 173 if(InterfaceManager::charge_completed == 0)
alt0710 3:6f87cbec2ae8 174 {
alt0710 15:2bf8eafacef8 175 f_charge_fin = 1;
alt0710 3:6f87cbec2ae8 176 }
alt0710 3:6f87cbec2ae8 177 else
alt0710 3:6f87cbec2ae8 178 {
alt0710 3:6f87cbec2ae8 179 f_charge_fin = 0;
alt0710 3:6f87cbec2ae8 180 }
alt0710 15:2bf8eafacef8 181 StatusManager::charge_end = f_charge_fin;
alt0710 3:6f87cbec2ae8 182 }
alt0710 3:6f87cbec2ae8 183
alt0710 3:6f87cbec2ae8 184 void Kicker::checkBallSensor(void)
alt0710 3:6f87cbec2ae8 185 {
alt0710 3:6f87cbec2ae8 186 if(InterfaceManager::ball_sensor == 0)
alt0710 3:6f87cbec2ae8 187 {
alt0710 3:6f87cbec2ae8 188 isRelease = 0;
alt0710 6:21b3fbe57b88 189 ball = IS_NOT_EXIST;
alt0710 6:21b3fbe57b88 190 StatusManager::ball = 0;
alt0710 3:6f87cbec2ae8 191 }
alt0710 3:6f87cbec2ae8 192 else if(InterfaceManager::ball_sensor == 1)
alt0710 3:6f87cbec2ae8 193 {
alt0710 3:6f87cbec2ae8 194 ball = IS_EXIST; //豆知識EXISTは、存在する(知らんかった;;)
alt0710 6:21b3fbe57b88 195 StatusManager::ball = 1;
alt0710 6:21b3fbe57b88 196 }
alt0710 6:21b3fbe57b88 197
alt0710 3:6f87cbec2ae8 198 }
alt0710 3:6f87cbec2ae8 199
alt0710 3:6f87cbec2ae8 200