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:
Thu May 04 07:47:48 2017 +0000
Revision:
16:e8060a65ed23
Parent:
15:2bf8eafacef8
????;

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 3:6f87cbec2ae8 93 InterfaceManager::charge_request = 0;
alt0710 3:6f87cbec2ae8 94 StatusManager::is_kicking = 1;
alt0710 3:6f87cbec2ae8 95 InterfaceManager::straight_kick = 1;
alt0710 10:9cd22f673968 96 driveFireTimer(ParameterManager::kickpower.getChipPowerTime(t_power));
alt0710 3:6f87cbec2ae8 97 break;
alt0710 3:6f87cbec2ae8 98
alt0710 3:6f87cbec2ae8 99 case CHIP:
alt0710 3:6f87cbec2ae8 100 InterfaceManager::charge_request = 0;
alt0710 3:6f87cbec2ae8 101 StatusManager::is_kicking = 1;
alt0710 3:6f87cbec2ae8 102 InterfaceManager::chip_kick = 1;
alt0710 10:9cd22f673968 103 driveFireTimer(ParameterManager::kickpower.getStraightPowerTime(t_power));
alt0710 3:6f87cbec2ae8 104 break;
alt0710 3:6f87cbec2ae8 105
alt0710 3:6f87cbec2ae8 106 default:
alt0710 3:6f87cbec2ae8 107 InterfaceManager::straight_kick = 0;
alt0710 3:6f87cbec2ae8 108 InterfaceManager::chip_kick = 0;
alt0710 3:6f87cbec2ae8 109 break;
alt0710 3:6f87cbec2ae8 110 }
alt0710 3:6f87cbec2ae8 111 }
alt0710 3:6f87cbec2ae8 112
alt0710 10:9cd22f673968 113 void Kicker::forceFireKick(void)
alt0710 10:9cd22f673968 114 {
alt0710 10:9cd22f673968 115
alt0710 10:9cd22f673968 116
alt0710 10:9cd22f673968 117 if( InterfaceManager::button.getButtonStatus(CROSS_DOWN) == 1 ){
alt0710 10:9cd22f673968 118 mode_discharge = 1;
alt0710 10:9cd22f673968 119 }
alt0710 10:9cd22f673968 120
alt0710 10:9cd22f673968 121 if( mode_discharge == 0 ){
alt0710 10:9cd22f673968 122 count_continue_delay = 0;
alt0710 10:9cd22f673968 123 count_num_of_kick = 0;
alt0710 10:9cd22f673968 124 return;
alt0710 10:9cd22f673968 125 }
alt0710 10:9cd22f673968 126
alt0710 10:9cd22f673968 127 if( count_num_of_kick > NUM_OF_KICK ){
alt0710 10:9cd22f673968 128 mode_discharge = 0;
alt0710 10:9cd22f673968 129 return;
alt0710 10:9cd22f673968 130 }
alt0710 10:9cd22f673968 131
alt0710 10:9cd22f673968 132 if( StatusManager::is_kicking == 1 ){
alt0710 10:9cd22f673968 133 return;
alt0710 10:9cd22f673968 134 }
alt0710 10:9cd22f673968 135
alt0710 10:9cd22f673968 136 if( count_continue_delay < CONTINUE_DELAY ){
alt0710 10:9cd22f673968 137 count_continue_delay ++;
alt0710 10:9cd22f673968 138 return;
alt0710 10:9cd22f673968 139 }
alt0710 10:9cd22f673968 140
alt0710 10:9cd22f673968 141 count_continue_delay = 0;
alt0710 10:9cd22f673968 142 fireKick(STRAIGHT, 10);
alt0710 10:9cd22f673968 143 StatusManager::is_kicking = 1;
alt0710 10:9cd22f673968 144 InterfaceManager::charge_request = 0;
alt0710 10:9cd22f673968 145
alt0710 10:9cd22f673968 146 count_num_of_kick++;
alt0710 10:9cd22f673968 147
alt0710 10:9cd22f673968 148 }
alt0710 10:9cd22f673968 149
alt0710 3:6f87cbec2ae8 150 void Kicker::checkKickEnable(void)
alt0710 3:6f87cbec2ae8 151 {
alt0710 3:6f87cbec2ae8 152
alt0710 15:2bf8eafacef8 153 //if( f_charge_fin )
alt0710 3:6f87cbec2ae8 154 if( f_charge_fin && (ball == IS_EXIST) && !isRelease && !StatusManager::is_kicking)
alt0710 3:6f87cbec2ae8 155 {
alt0710 15:2bf8eafacef8 156
alt0710 3:6f87cbec2ae8 157 kickPermit = ENABLE;
alt0710 3:6f87cbec2ae8 158 isRelease = 1;
alt0710 3:6f87cbec2ae8 159 f_charge_fin = 0;
alt0710 15:2bf8eafacef8 160 //StatusManager::charge_end = InterfaceManager::charge_completed;
alt0710 3:6f87cbec2ae8 161 }
alt0710 3:6f87cbec2ae8 162 else
alt0710 3:6f87cbec2ae8 163 {
alt0710 3:6f87cbec2ae8 164 kickPermit = DISABLE;
alt0710 3:6f87cbec2ae8 165 }
alt0710 3:6f87cbec2ae8 166
alt0710 3:6f87cbec2ae8 167 }
alt0710 3:6f87cbec2ae8 168
alt0710 3:6f87cbec2ae8 169 void Kicker::checkChargeCompleted(void)
alt0710 3:6f87cbec2ae8 170 {
alt0710 3:6f87cbec2ae8 171 //不論理
alt0710 3:6f87cbec2ae8 172 if(InterfaceManager::charge_completed == 0)
alt0710 3:6f87cbec2ae8 173 {
alt0710 15:2bf8eafacef8 174 f_charge_fin = 1;
alt0710 3:6f87cbec2ae8 175 }
alt0710 3:6f87cbec2ae8 176 else
alt0710 3:6f87cbec2ae8 177 {
alt0710 3:6f87cbec2ae8 178 f_charge_fin = 0;
alt0710 3:6f87cbec2ae8 179 }
alt0710 15:2bf8eafacef8 180 StatusManager::charge_end = f_charge_fin;
alt0710 3:6f87cbec2ae8 181 }
alt0710 3:6f87cbec2ae8 182
alt0710 3:6f87cbec2ae8 183 void Kicker::checkBallSensor(void)
alt0710 3:6f87cbec2ae8 184 {
alt0710 3:6f87cbec2ae8 185 if(InterfaceManager::ball_sensor == 0)
alt0710 3:6f87cbec2ae8 186 {
alt0710 3:6f87cbec2ae8 187 isRelease = 0;
alt0710 6:21b3fbe57b88 188 ball = IS_NOT_EXIST;
alt0710 6:21b3fbe57b88 189 StatusManager::ball = 0;
alt0710 3:6f87cbec2ae8 190 }
alt0710 3:6f87cbec2ae8 191 else if(InterfaceManager::ball_sensor == 1)
alt0710 3:6f87cbec2ae8 192 {
alt0710 3:6f87cbec2ae8 193 ball = IS_EXIST; //豆知識EXISTは、存在する(知らんかった;;)
alt0710 6:21b3fbe57b88 194 StatusManager::ball = 1;
alt0710 6:21b3fbe57b88 195 }
alt0710 6:21b3fbe57b88 196
alt0710 3:6f87cbec2ae8 197 }
alt0710 3:6f87cbec2ae8 198
alt0710 3:6f87cbec2ae8 199