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
mode/normal_routine/normal_routine.cpp@23:0bb032ef1880, 2018-04-28 (annotated)
- Committer:
- alt0710
- Date:
- Sat Apr 28 07:18:22 2018 +0000
- Revision:
- 23:0bb032ef1880
- Parent:
- 18:8db19ccf7e02
- Child:
- 24:37a074e767c8
???????????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alt0710 | 6:21b3fbe57b88 | 1 | |
alt0710 | 6:21b3fbe57b88 | 2 | #include "mbed.h" |
alt0710 | 6:21b3fbe57b88 | 3 | #include "comm.h" |
alt0710 | 6:21b3fbe57b88 | 4 | #include "mode.h" |
alt0710 | 6:21b3fbe57b88 | 5 | #include "interface_manager.h" |
alt0710 | 6:21b3fbe57b88 | 6 | #include "status_manager.h" |
alt0710 | 6:21b3fbe57b88 | 7 | #include "parameter_manager.h" |
alt0710 | 6:21b3fbe57b88 | 8 | #include "normal_routine.h" |
alt0710 | 6:21b3fbe57b88 | 9 | |
alt0710 | 6:21b3fbe57b88 | 10 | /* **mbedクラス** */ |
alt0710 | 6:21b3fbe57b88 | 11 | #ifdef LPC4088 |
alt0710 | 6:21b3fbe57b88 | 12 | |
alt0710 | 6:21b3fbe57b88 | 13 | #elif STM32 |
alt0710 | 6:21b3fbe57b88 | 14 | |
alt0710 | 6:21b3fbe57b88 | 15 | #endif |
alt0710 | 6:21b3fbe57b88 | 16 | |
alt0710 | 6:21b3fbe57b88 | 17 | /* **ローカル関数定義** */ |
alt0710 | 6:21b3fbe57b88 | 18 | |
alt0710 | 6:21b3fbe57b88 | 19 | /* **ローカル関数** */ |
alt0710 | 6:21b3fbe57b88 | 20 | |
alt0710 | 6:21b3fbe57b88 | 21 | /* **グルーバル関数** */ |
alt0710 | 6:21b3fbe57b88 | 22 | |
alt0710 | 6:21b3fbe57b88 | 23 | /* **クラス** */ |
alt0710 | 6:21b3fbe57b88 | 24 | class InterfaceManager; |
alt0710 | 7:1f1bdb4e4f33 | 25 | class StatusManager; |
alt0710 | 7:1f1bdb4e4f33 | 26 | class ParameterManager; |
alt0710 | 7:1f1bdb4e4f33 | 27 | |
alt0710 | 23:0bb032ef1880 | 28 | |
alt0710 | 23:0bb032ef1880 | 29 | |
alt0710 | 6:21b3fbe57b88 | 30 | //メンバ変数の初期化は、定義順(Warningになる) |
alt0710 | 6:21b3fbe57b88 | 31 | NormalRoutine::NormalRoutine() |
alt0710 | 23:0bb032ef1880 | 32 | { |
alt0710 | 23:0bb032ef1880 | 33 | failsafe.init(); |
alt0710 | 6:21b3fbe57b88 | 34 | } |
alt0710 | 6:21b3fbe57b88 | 35 | |
alt0710 | 6:21b3fbe57b88 | 36 | void NormalRoutine::run(void) |
alt0710 | 6:21b3fbe57b88 | 37 | { |
alt0710 | 7:1f1bdb4e4f33 | 38 | packet.splitPacket(); |
alt0710 | 7:1f1bdb4e4f33 | 39 | |
alt0710 | 7:1f1bdb4e4f33 | 40 | //Kick |
alt0710 | 7:1f1bdb4e4f33 | 41 | kicker.setCharge(ParameterManager::machine_data.charge_flag); |
alt0710 | 7:1f1bdb4e4f33 | 42 | kicker.setKick(ParameterManager::machine_data.kick_flag,ParameterManager::machine_data.kick_type,ParameterManager::machine_data.kickers_power); |
alt0710 | 10:9cd22f673968 | 43 | kicker.forceFireKick(); |
alt0710 | 7:1f1bdb4e4f33 | 44 | |
alt0710 | 7:1f1bdb4e4f33 | 45 | //Wheel |
alt0710 | 15:2bf8eafacef8 | 46 | wheel.setVelocity(ParameterManager::machine_data.v_mm_per_sec,ParameterManager::machine_data.angle_degree,ParameterManager::machine_data.vw_mrad_per_sec); |
alt0710 | 15:2bf8eafacef8 | 47 | //wheel.setVelocity(5000,0,0); |
alt0710 | 14:f6cc949a8046 | 48 | |
alt0710 | 11:7f5259ad738c | 49 | //Drible |
alt0710 | 14:f6cc949a8046 | 50 | dribble.setdribble(ParameterManager::machine_data.dribble_flag, ParameterManager::machine_data.dribbler_power); |
alt0710 | 18:8db19ccf7e02 | 51 | //dribble.setdribble(1, 3); |
alt0710 | 7:1f1bdb4e4f33 | 52 | |
alt0710 | 23:0bb032ef1880 | 53 | StatusManager::supply_voltage = InterfaceManager::batVoltage.read(); |
alt0710 | 23:0bb032ef1880 | 54 | StatusManager::supply_voltage *= 3.3 * 5.977; |
alt0710 | 23:0bb032ef1880 | 55 | |
alt0710 | 23:0bb032ef1880 | 56 | |
alt0710 | 23:0bb032ef1880 | 57 | |
alt0710 | 23:0bb032ef1880 | 58 | //sprintf(str,"DC:%f",StatusManager::dribbleMotor_current); |
alt0710 | 7:1f1bdb4e4f33 | 59 | createLcdData(); |
alt0710 | 6:21b3fbe57b88 | 60 | InterfaceManager::i2c.setLCDMsg(str,sizeof(str)); |
alt0710 | 6:21b3fbe57b88 | 61 | |
alt0710 | 6:21b3fbe57b88 | 62 | } |
alt0710 | 6:21b3fbe57b88 | 63 | |
alt0710 | 7:1f1bdb4e4f33 | 64 | void NormalRoutine::createLcdData(void) |
alt0710 | 7:1f1bdb4e4f33 | 65 | { |
alt0710 | 7:1f1bdb4e4f33 | 66 | |
alt0710 | 7:1f1bdb4e4f33 | 67 | /* |
alt0710 | 7:1f1bdb4e4f33 | 68 | |
alt0710 | 7:1f1bdb4e4f33 | 69 | * 0 : 正常終了 |
alt0710 | 7:1f1bdb4e4f33 | 70 | |
alt0710 | 7:1f1bdb4e4f33 | 71 | * -1 : タイムアウト |
alt0710 | 7:1f1bdb4e4f33 | 72 | |
alt0710 | 7:1f1bdb4e4f33 | 73 | * -2 : オーバーランエラー |
alt0710 | 7:1f1bdb4e4f33 | 74 | |
alt0710 | 7:1f1bdb4e4f33 | 75 | * -3 : フレーミングエラー |
alt0710 | 7:1f1bdb4e4f33 | 76 | |
alt0710 | 7:1f1bdb4e4f33 | 77 | * 1 : 受信中 |
alt0710 | 7:1f1bdb4e4f33 | 78 | |
alt0710 | 7:1f1bdb4e4f33 | 79 | * 2 : フレームリーダー1まで受信 |
alt0710 | 7:1f1bdb4e4f33 | 80 | |
alt0710 | 7:1f1bdb4e4f33 | 81 | * 3 : フレームリーダー2まで受信 |
alt0710 | 7:1f1bdb4e4f33 | 82 | |
alt0710 | 7:1f1bdb4e4f33 | 83 | * 4 : マシンIDまで受信 |
alt0710 | 7:1f1bdb4e4f33 | 84 | |
alt0710 | 7:1f1bdb4e4f33 | 85 | */ |
alt0710 | 7:1f1bdb4e4f33 | 86 | switch(StatusManager::uart){ |
alt0710 | 7:1f1bdb4e4f33 | 87 | case 0: |
alt0710 | 23:0bb032ef1880 | 88 | sprintf(str,"ID%dB%3.1f\nComplete",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 89 | sprintf(str_uart,"Complete"); |
alt0710 | 7:1f1bdb4e4f33 | 90 | break; |
alt0710 | 7:1f1bdb4e4f33 | 91 | |
alt0710 | 7:1f1bdb4e4f33 | 92 | case 1: |
alt0710 | 7:1f1bdb4e4f33 | 93 | break; |
alt0710 | 7:1f1bdb4e4f33 | 94 | |
alt0710 | 7:1f1bdb4e4f33 | 95 | case 2: |
alt0710 | 23:0bb032ef1880 | 96 | sprintf(str,"ID%dB%3.1f\nHeader1",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 97 | sprintf(str_uart,"Header1"); |
alt0710 | 7:1f1bdb4e4f33 | 98 | break; |
alt0710 | 6:21b3fbe57b88 | 99 | |
alt0710 | 7:1f1bdb4e4f33 | 100 | case 3: |
alt0710 | 23:0bb032ef1880 | 101 | sprintf(str,"ID%dB%3.1f\nHeader2",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 102 | sprintf(str_uart,"Header2"); |
alt0710 | 7:1f1bdb4e4f33 | 103 | break; |
alt0710 | 7:1f1bdb4e4f33 | 104 | |
alt0710 | 7:1f1bdb4e4f33 | 105 | case 4: |
alt0710 | 23:0bb032ef1880 | 106 | sprintf(str,"ID%dB%3.1f\nCheckER1",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 107 | sprintf(str_uart,"CheckERR"); |
alt0710 | 7:1f1bdb4e4f33 | 108 | break; |
alt0710 | 7:1f1bdb4e4f33 | 109 | |
alt0710 | 7:1f1bdb4e4f33 | 110 | case 5: |
alt0710 | 23:0bb032ef1880 | 111 | sprintf(str,"ID%dB%3.1f\nCheckER2",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 112 | sprintf(str_uart,"CheckERR"); |
alt0710 | 7:1f1bdb4e4f33 | 113 | break; |
alt0710 | 7:1f1bdb4e4f33 | 114 | |
alt0710 | 7:1f1bdb4e4f33 | 115 | case -1: |
alt0710 | 23:0bb032ef1880 | 116 | sprintf(str,"ID%dB%3.1f\nTimeOut",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 117 | sprintf(str_uart,"TimeOut"); |
alt0710 | 7:1f1bdb4e4f33 | 118 | break; |
alt0710 | 7:1f1bdb4e4f33 | 119 | |
alt0710 | 7:1f1bdb4e4f33 | 120 | case -2: |
alt0710 | 23:0bb032ef1880 | 121 | sprintf(str,"ID%dB%3.1f\nOERR",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 122 | sprintf(str_uart,"OERR"); |
alt0710 | 7:1f1bdb4e4f33 | 123 | break; |
alt0710 | 7:1f1bdb4e4f33 | 124 | |
alt0710 | 7:1f1bdb4e4f33 | 125 | case -3: |
alt0710 | 23:0bb032ef1880 | 126 | sprintf(str,"ID%dB%3.1f\nFERR",ParameterManager::machine_id,StatusManager::supply_voltage); |
alt0710 | 7:1f1bdb4e4f33 | 127 | sprintf(str_uart,"FERR"); |
alt0710 | 7:1f1bdb4e4f33 | 128 | break; |
alt0710 | 7:1f1bdb4e4f33 | 129 | |
alt0710 | 7:1f1bdb4e4f33 | 130 | default: |
alt0710 | 23:0bb032ef1880 | 131 | sprintf(str,"ID%dB%3.1f\n %d",ParameterManager::machine_id,StatusManager::supply_voltage, StatusManager::uart); |
alt0710 | 7:1f1bdb4e4f33 | 132 | break; |
alt0710 | 7:1f1bdb4e4f33 | 133 | } |
alt0710 | 7:1f1bdb4e4f33 | 134 | |
alt0710 | 7:1f1bdb4e4f33 | 135 | |
alt0710 | 7:1f1bdb4e4f33 | 136 | //sprintf(str,"ID%d EN: \n %s",ParameterManager::machine_id ,str_uart); |
alt0710 | 7:1f1bdb4e4f33 | 137 | } |