RobocupSSLのメイン基板白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は,ロボットとボールの座標,審判の判定を元にロボットの移動,キックなどの作戦を決定し,無線によってロボットに指令を送信する.
ロボット機能紹介
●オムニホイールによる方向転換不要の全方位移動
オムニホイールは,自由に回転可能なローラをホイールの外周上に配置した車輪である.ローラの回転により,車輪の回転と垂直の方向に駆動力を発することはできないが移動は可能となる.各車輪の角速度を調整することによって全方向への移動を可能にする.
●ドリブルバーのバックスピンによるボール保持
●電磁力を利用したキッカー
●キッカーの電磁力エネルギーを充電する充電回路
●ロボット情報が一目でわかるLCD
actuator/kicker.cpp@10:9cd22f673968, 2017-05-02 (annotated)
- Committer:
- alt0710
- Date:
- Tue May 02 07:54:05 2017 +0000
- Revision:
- 10:9cd22f673968
- Parent:
- 6:21b3fbe57b88
- Child:
- 15:2bf8eafacef8
???????; ?????????????????????????; ??????????
Who changed what in which revision?
User | Revision | Line number | New 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 | 3:6f87cbec2ae8 | 56 | f_kick = flag_kick; |
alt0710 | 3:6f87cbec2ae8 | 57 | kickType = kick_Type; |
alt0710 | 3:6f87cbec2ae8 | 58 | power = kick_power; |
alt0710 | 3:6f87cbec2ae8 | 59 | |
alt0710 | 6:21b3fbe57b88 | 60 | checkBallSensor(); //ball |
alt0710 | 3:6f87cbec2ae8 | 61 | if(f_kick == 1) |
alt0710 | 3:6f87cbec2ae8 | 62 | { |
alt0710 | 3:6f87cbec2ae8 | 63 | checkKickEnable(); |
alt0710 | 3:6f87cbec2ae8 | 64 | if(kickPermit == ENABLE) |
alt0710 | 3:6f87cbec2ae8 | 65 | { |
alt0710 | 10:9cd22f673968 | 66 | fireKick(kickType, power); |
alt0710 | 3:6f87cbec2ae8 | 67 | } |
alt0710 | 3:6f87cbec2ae8 | 68 | } |
alt0710 | 3:6f87cbec2ae8 | 69 | } |
alt0710 | 3:6f87cbec2ae8 | 70 | |
alt0710 | 3:6f87cbec2ae8 | 71 | void Kicker::setCharge(char flag_charge) |
alt0710 | 3:6f87cbec2ae8 | 72 | { |
alt0710 | 3:6f87cbec2ae8 | 73 | if(flag_charge && (StatusManager::is_kicking == 0)) |
alt0710 | 3:6f87cbec2ae8 | 74 | { |
alt0710 | 3:6f87cbec2ae8 | 75 | f_charge = 1; |
alt0710 | 6:21b3fbe57b88 | 76 | InterfaceManager::charge_request = 1; |
alt0710 | 3:6f87cbec2ae8 | 77 | } |
alt0710 | 3:6f87cbec2ae8 | 78 | else |
alt0710 | 3:6f87cbec2ae8 | 79 | { |
alt0710 | 3:6f87cbec2ae8 | 80 | f_charge = 0; |
alt0710 | 6:21b3fbe57b88 | 81 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 82 | } |
alt0710 | 3:6f87cbec2ae8 | 83 | StatusManager::req_charge = f_charge; |
alt0710 | 3:6f87cbec2ae8 | 84 | } |
alt0710 | 3:6f87cbec2ae8 | 85 | |
alt0710 | 10:9cd22f673968 | 86 | void Kicker::fireKick(char t_KickType,char t_power) |
alt0710 | 3:6f87cbec2ae8 | 87 | { |
alt0710 | 10:9cd22f673968 | 88 | switch(t_KickType) |
alt0710 | 3:6f87cbec2ae8 | 89 | { |
alt0710 | 3:6f87cbec2ae8 | 90 | case STRAIGHT: |
alt0710 | 3:6f87cbec2ae8 | 91 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 92 | StatusManager::is_kicking = 1; |
alt0710 | 3:6f87cbec2ae8 | 93 | InterfaceManager::straight_kick = 1; |
alt0710 | 10:9cd22f673968 | 94 | driveFireTimer(ParameterManager::kickpower.getChipPowerTime(t_power)); |
alt0710 | 3:6f87cbec2ae8 | 95 | break; |
alt0710 | 3:6f87cbec2ae8 | 96 | |
alt0710 | 3:6f87cbec2ae8 | 97 | case CHIP: |
alt0710 | 3:6f87cbec2ae8 | 98 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 99 | StatusManager::is_kicking = 1; |
alt0710 | 3:6f87cbec2ae8 | 100 | InterfaceManager::chip_kick = 1; |
alt0710 | 10:9cd22f673968 | 101 | driveFireTimer(ParameterManager::kickpower.getStraightPowerTime(t_power)); |
alt0710 | 3:6f87cbec2ae8 | 102 | break; |
alt0710 | 3:6f87cbec2ae8 | 103 | |
alt0710 | 3:6f87cbec2ae8 | 104 | default: |
alt0710 | 3:6f87cbec2ae8 | 105 | InterfaceManager::straight_kick = 0; |
alt0710 | 3:6f87cbec2ae8 | 106 | InterfaceManager::chip_kick = 0; |
alt0710 | 3:6f87cbec2ae8 | 107 | break; |
alt0710 | 3:6f87cbec2ae8 | 108 | } |
alt0710 | 3:6f87cbec2ae8 | 109 | } |
alt0710 | 3:6f87cbec2ae8 | 110 | |
alt0710 | 10:9cd22f673968 | 111 | void Kicker::forceFireKick(void) |
alt0710 | 10:9cd22f673968 | 112 | { |
alt0710 | 10:9cd22f673968 | 113 | |
alt0710 | 10:9cd22f673968 | 114 | |
alt0710 | 10:9cd22f673968 | 115 | if( InterfaceManager::button.getButtonStatus(CROSS_DOWN) == 1 ){ |
alt0710 | 10:9cd22f673968 | 116 | mode_discharge = 1; |
alt0710 | 10:9cd22f673968 | 117 | } |
alt0710 | 10:9cd22f673968 | 118 | |
alt0710 | 10:9cd22f673968 | 119 | if( mode_discharge == 0 ){ |
alt0710 | 10:9cd22f673968 | 120 | count_continue_delay = 0; |
alt0710 | 10:9cd22f673968 | 121 | count_num_of_kick = 0; |
alt0710 | 10:9cd22f673968 | 122 | return; |
alt0710 | 10:9cd22f673968 | 123 | } |
alt0710 | 10:9cd22f673968 | 124 | |
alt0710 | 10:9cd22f673968 | 125 | if( count_num_of_kick > NUM_OF_KICK ){ |
alt0710 | 10:9cd22f673968 | 126 | mode_discharge = 0; |
alt0710 | 10:9cd22f673968 | 127 | return; |
alt0710 | 10:9cd22f673968 | 128 | } |
alt0710 | 10:9cd22f673968 | 129 | |
alt0710 | 10:9cd22f673968 | 130 | if( StatusManager::is_kicking == 1 ){ |
alt0710 | 10:9cd22f673968 | 131 | return; |
alt0710 | 10:9cd22f673968 | 132 | } |
alt0710 | 10:9cd22f673968 | 133 | |
alt0710 | 10:9cd22f673968 | 134 | if( count_continue_delay < CONTINUE_DELAY ){ |
alt0710 | 10:9cd22f673968 | 135 | count_continue_delay ++; |
alt0710 | 10:9cd22f673968 | 136 | return; |
alt0710 | 10:9cd22f673968 | 137 | } |
alt0710 | 10:9cd22f673968 | 138 | |
alt0710 | 10:9cd22f673968 | 139 | count_continue_delay = 0; |
alt0710 | 10:9cd22f673968 | 140 | fireKick(STRAIGHT, 10); |
alt0710 | 10:9cd22f673968 | 141 | StatusManager::is_kicking = 1; |
alt0710 | 10:9cd22f673968 | 142 | InterfaceManager::charge_request = 0; |
alt0710 | 10:9cd22f673968 | 143 | |
alt0710 | 10:9cd22f673968 | 144 | count_num_of_kick++; |
alt0710 | 10:9cd22f673968 | 145 | |
alt0710 | 10:9cd22f673968 | 146 | } |
alt0710 | 10:9cd22f673968 | 147 | |
alt0710 | 3:6f87cbec2ae8 | 148 | void Kicker::checkKickEnable(void) |
alt0710 | 3:6f87cbec2ae8 | 149 | { |
alt0710 | 3:6f87cbec2ae8 | 150 | checkChargeCompleted(); //f_charge_fin |
alt0710 | 3:6f87cbec2ae8 | 151 | |
alt0710 | 3:6f87cbec2ae8 | 152 | if( f_charge_fin && (ball == IS_EXIST) && !isRelease && !StatusManager::is_kicking) |
alt0710 | 3:6f87cbec2ae8 | 153 | { |
alt0710 | 3:6f87cbec2ae8 | 154 | kickPermit = ENABLE; |
alt0710 | 3:6f87cbec2ae8 | 155 | isRelease = 1; |
alt0710 | 3:6f87cbec2ae8 | 156 | f_charge_fin = 0; |
alt0710 | 3:6f87cbec2ae8 | 157 | } |
alt0710 | 3:6f87cbec2ae8 | 158 | else |
alt0710 | 3:6f87cbec2ae8 | 159 | { |
alt0710 | 3:6f87cbec2ae8 | 160 | kickPermit = DISABLE; |
alt0710 | 3:6f87cbec2ae8 | 161 | } |
alt0710 | 3:6f87cbec2ae8 | 162 | |
alt0710 | 3:6f87cbec2ae8 | 163 | } |
alt0710 | 3:6f87cbec2ae8 | 164 | |
alt0710 | 3:6f87cbec2ae8 | 165 | void Kicker::checkChargeCompleted(void) |
alt0710 | 3:6f87cbec2ae8 | 166 | { |
alt0710 | 3:6f87cbec2ae8 | 167 | //不論理 |
alt0710 | 3:6f87cbec2ae8 | 168 | if(InterfaceManager::charge_completed == 0) |
alt0710 | 3:6f87cbec2ae8 | 169 | { |
alt0710 | 3:6f87cbec2ae8 | 170 | f_charge_fin = 1; |
alt0710 | 3:6f87cbec2ae8 | 171 | } |
alt0710 | 3:6f87cbec2ae8 | 172 | else |
alt0710 | 3:6f87cbec2ae8 | 173 | { |
alt0710 | 3:6f87cbec2ae8 | 174 | f_charge_fin = 0; |
alt0710 | 3:6f87cbec2ae8 | 175 | } |
alt0710 | 3:6f87cbec2ae8 | 176 | } |
alt0710 | 3:6f87cbec2ae8 | 177 | |
alt0710 | 3:6f87cbec2ae8 | 178 | void Kicker::checkBallSensor(void) |
alt0710 | 3:6f87cbec2ae8 | 179 | { |
alt0710 | 3:6f87cbec2ae8 | 180 | if(InterfaceManager::ball_sensor == 0) |
alt0710 | 3:6f87cbec2ae8 | 181 | { |
alt0710 | 3:6f87cbec2ae8 | 182 | isRelease = 0; |
alt0710 | 6:21b3fbe57b88 | 183 | ball = IS_NOT_EXIST; |
alt0710 | 6:21b3fbe57b88 | 184 | StatusManager::ball = 0; |
alt0710 | 3:6f87cbec2ae8 | 185 | } |
alt0710 | 3:6f87cbec2ae8 | 186 | else if(InterfaceManager::ball_sensor == 1) |
alt0710 | 3:6f87cbec2ae8 | 187 | { |
alt0710 | 3:6f87cbec2ae8 | 188 | ball = IS_EXIST; //豆知識EXISTは、存在する(知らんかった;;) |
alt0710 | 6:21b3fbe57b88 | 189 | StatusManager::ball = 1; |
alt0710 | 6:21b3fbe57b88 | 190 | } |
alt0710 | 6:21b3fbe57b88 | 191 | |
alt0710 | 3:6f87cbec2ae8 | 192 | } |
alt0710 | 3:6f87cbec2ae8 | 193 | |
alt0710 | 3:6f87cbec2ae8 | 194 |