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:
Sun Sep 22 10:23:42 2019 +0000
Revision:
35:b1b00cfaa163
Parent:
25:15f75825fc36
2019JapanOpenSoft

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