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@6:21b3fbe57b88, 2017-04-25 (annotated)
- Committer:
- alt0710
- Date:
- Tue Apr 25 16:08:47 2017 +0000
- Revision:
- 6:21b3fbe57b88
- Parent:
- 3:6f87cbec2ae8
- Child:
- 10:9cd22f673968
Kicker????????????; ????????
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 | 3:6f87cbec2ae8 | 47 | fireTime(0) |
alt0710 | 3:6f87cbec2ae8 | 48 | { |
alt0710 | 3:6f87cbec2ae8 | 49 | } |
alt0710 | 3:6f87cbec2ae8 | 50 | |
alt0710 | 3:6f87cbec2ae8 | 51 | void Kicker::setKick(char flag_kick, char kick_Type, char kick_power) |
alt0710 | 3:6f87cbec2ae8 | 52 | { |
alt0710 | 3:6f87cbec2ae8 | 53 | f_kick = flag_kick; |
alt0710 | 3:6f87cbec2ae8 | 54 | kickType = kick_Type; |
alt0710 | 3:6f87cbec2ae8 | 55 | power = kick_power; |
alt0710 | 3:6f87cbec2ae8 | 56 | |
alt0710 | 6:21b3fbe57b88 | 57 | checkBallSensor(); //ball |
alt0710 | 3:6f87cbec2ae8 | 58 | if(f_kick == 1) |
alt0710 | 3:6f87cbec2ae8 | 59 | { |
alt0710 | 3:6f87cbec2ae8 | 60 | checkKickEnable(); |
alt0710 | 3:6f87cbec2ae8 | 61 | if(kickPermit == ENABLE) |
alt0710 | 3:6f87cbec2ae8 | 62 | { |
alt0710 | 3:6f87cbec2ae8 | 63 | fireKick(); |
alt0710 | 3:6f87cbec2ae8 | 64 | } |
alt0710 | 3:6f87cbec2ae8 | 65 | } |
alt0710 | 3:6f87cbec2ae8 | 66 | } |
alt0710 | 3:6f87cbec2ae8 | 67 | |
alt0710 | 3:6f87cbec2ae8 | 68 | void Kicker::setCharge(char flag_charge) |
alt0710 | 3:6f87cbec2ae8 | 69 | { |
alt0710 | 3:6f87cbec2ae8 | 70 | if(flag_charge && (StatusManager::is_kicking == 0)) |
alt0710 | 3:6f87cbec2ae8 | 71 | { |
alt0710 | 3:6f87cbec2ae8 | 72 | f_charge = 1; |
alt0710 | 6:21b3fbe57b88 | 73 | InterfaceManager::charge_request = 1; |
alt0710 | 3:6f87cbec2ae8 | 74 | } |
alt0710 | 3:6f87cbec2ae8 | 75 | else |
alt0710 | 3:6f87cbec2ae8 | 76 | { |
alt0710 | 3:6f87cbec2ae8 | 77 | f_charge = 0; |
alt0710 | 6:21b3fbe57b88 | 78 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 79 | } |
alt0710 | 3:6f87cbec2ae8 | 80 | StatusManager::req_charge = f_charge; |
alt0710 | 3:6f87cbec2ae8 | 81 | } |
alt0710 | 3:6f87cbec2ae8 | 82 | |
alt0710 | 3:6f87cbec2ae8 | 83 | void Kicker::fireKick(void) |
alt0710 | 3:6f87cbec2ae8 | 84 | { |
alt0710 | 3:6f87cbec2ae8 | 85 | switch(kickType) |
alt0710 | 3:6f87cbec2ae8 | 86 | { |
alt0710 | 3:6f87cbec2ae8 | 87 | case STRAIGHT: |
alt0710 | 3:6f87cbec2ae8 | 88 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 89 | StatusManager::is_kicking = 1; |
alt0710 | 3:6f87cbec2ae8 | 90 | InterfaceManager::straight_kick = 1; |
alt0710 | 3:6f87cbec2ae8 | 91 | driveFireTimer(ParameterManager::kickpower.getChipPowerTime(power)); |
alt0710 | 3:6f87cbec2ae8 | 92 | break; |
alt0710 | 3:6f87cbec2ae8 | 93 | |
alt0710 | 3:6f87cbec2ae8 | 94 | case CHIP: |
alt0710 | 3:6f87cbec2ae8 | 95 | InterfaceManager::charge_request = 0; |
alt0710 | 3:6f87cbec2ae8 | 96 | StatusManager::is_kicking = 1; |
alt0710 | 3:6f87cbec2ae8 | 97 | InterfaceManager::chip_kick = 1; |
alt0710 | 3:6f87cbec2ae8 | 98 | driveFireTimer(ParameterManager::kickpower.getStraightPowerTime(power)); |
alt0710 | 3:6f87cbec2ae8 | 99 | break; |
alt0710 | 3:6f87cbec2ae8 | 100 | |
alt0710 | 3:6f87cbec2ae8 | 101 | default: |
alt0710 | 3:6f87cbec2ae8 | 102 | InterfaceManager::straight_kick = 0; |
alt0710 | 3:6f87cbec2ae8 | 103 | InterfaceManager::chip_kick = 0; |
alt0710 | 3:6f87cbec2ae8 | 104 | break; |
alt0710 | 3:6f87cbec2ae8 | 105 | } |
alt0710 | 3:6f87cbec2ae8 | 106 | } |
alt0710 | 3:6f87cbec2ae8 | 107 | |
alt0710 | 3:6f87cbec2ae8 | 108 | void Kicker::checkKickEnable(void) |
alt0710 | 3:6f87cbec2ae8 | 109 | { |
alt0710 | 3:6f87cbec2ae8 | 110 | checkChargeCompleted(); //f_charge_fin |
alt0710 | 3:6f87cbec2ae8 | 111 | |
alt0710 | 3:6f87cbec2ae8 | 112 | if( f_charge_fin && (ball == IS_EXIST) && !isRelease && !StatusManager::is_kicking) |
alt0710 | 3:6f87cbec2ae8 | 113 | { |
alt0710 | 3:6f87cbec2ae8 | 114 | kickPermit = ENABLE; |
alt0710 | 3:6f87cbec2ae8 | 115 | isRelease = 1; |
alt0710 | 3:6f87cbec2ae8 | 116 | f_charge_fin = 0; |
alt0710 | 3:6f87cbec2ae8 | 117 | } |
alt0710 | 3:6f87cbec2ae8 | 118 | else |
alt0710 | 3:6f87cbec2ae8 | 119 | { |
alt0710 | 3:6f87cbec2ae8 | 120 | kickPermit = DISABLE; |
alt0710 | 3:6f87cbec2ae8 | 121 | } |
alt0710 | 3:6f87cbec2ae8 | 122 | |
alt0710 | 3:6f87cbec2ae8 | 123 | } |
alt0710 | 3:6f87cbec2ae8 | 124 | |
alt0710 | 3:6f87cbec2ae8 | 125 | void Kicker::checkChargeCompleted(void) |
alt0710 | 3:6f87cbec2ae8 | 126 | { |
alt0710 | 3:6f87cbec2ae8 | 127 | //不論理 |
alt0710 | 3:6f87cbec2ae8 | 128 | if(InterfaceManager::charge_completed == 0) |
alt0710 | 3:6f87cbec2ae8 | 129 | { |
alt0710 | 3:6f87cbec2ae8 | 130 | f_charge_fin = 1; |
alt0710 | 3:6f87cbec2ae8 | 131 | } |
alt0710 | 3:6f87cbec2ae8 | 132 | else |
alt0710 | 3:6f87cbec2ae8 | 133 | { |
alt0710 | 3:6f87cbec2ae8 | 134 | f_charge_fin = 0; |
alt0710 | 3:6f87cbec2ae8 | 135 | } |
alt0710 | 3:6f87cbec2ae8 | 136 | } |
alt0710 | 3:6f87cbec2ae8 | 137 | |
alt0710 | 3:6f87cbec2ae8 | 138 | void Kicker::checkBallSensor(void) |
alt0710 | 3:6f87cbec2ae8 | 139 | { |
alt0710 | 3:6f87cbec2ae8 | 140 | if(InterfaceManager::ball_sensor == 0) |
alt0710 | 3:6f87cbec2ae8 | 141 | { |
alt0710 | 3:6f87cbec2ae8 | 142 | isRelease = 0; |
alt0710 | 6:21b3fbe57b88 | 143 | ball = IS_NOT_EXIST; |
alt0710 | 6:21b3fbe57b88 | 144 | StatusManager::ball = 0; |
alt0710 | 3:6f87cbec2ae8 | 145 | } |
alt0710 | 3:6f87cbec2ae8 | 146 | else if(InterfaceManager::ball_sensor == 1) |
alt0710 | 3:6f87cbec2ae8 | 147 | { |
alt0710 | 3:6f87cbec2ae8 | 148 | ball = IS_EXIST; //豆知識EXISTは、存在する(知らんかった;;) |
alt0710 | 6:21b3fbe57b88 | 149 | StatusManager::ball = 1; |
alt0710 | 6:21b3fbe57b88 | 150 | } |
alt0710 | 6:21b3fbe57b88 | 151 | |
alt0710 | 3:6f87cbec2ae8 | 152 | } |
alt0710 | 3:6f87cbec2ae8 | 153 | |
alt0710 | 3:6f87cbec2ae8 | 154 |