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:
Wed May 02 02:47:35 2018 +0000
Revision:
30:8ee22331bfaf
Parent:
24:37a074e767c8
Child:
31:7b003082f31d
ifdef???ver????????????LCD?BoardNo.???????????; ;

Who changed what in which revision?

UserRevisionLine numberNew 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 30:8ee22331bfaf 17 #ifdef ON_INDICATER
alt0710 30:8ee22331bfaf 18 static char batVoltage[1];
alt0710 30:8ee22331bfaf 19 #endif
alt0710 24:37a074e767c8 20
alt0710 6:21b3fbe57b88 21 /* **ローカル関数定義** */
alt0710 6:21b3fbe57b88 22
alt0710 6:21b3fbe57b88 23 /* **ローカル関数** */
alt0710 6:21b3fbe57b88 24
alt0710 6:21b3fbe57b88 25 /* **グルーバル関数** */
alt0710 6:21b3fbe57b88 26
alt0710 6:21b3fbe57b88 27 /* **クラス** */
alt0710 6:21b3fbe57b88 28 class InterfaceManager;
alt0710 7:1f1bdb4e4f33 29 class StatusManager;
alt0710 7:1f1bdb4e4f33 30 class ParameterManager;
alt0710 7:1f1bdb4e4f33 31
alt0710 23:0bb032ef1880 32
alt0710 23:0bb032ef1880 33
alt0710 6:21b3fbe57b88 34 //メンバ変数の初期化は、定義順(Warningになる)
alt0710 6:21b3fbe57b88 35 NormalRoutine::NormalRoutine()
alt0710 23:0bb032ef1880 36 {
alt0710 23:0bb032ef1880 37 failsafe.init();
alt0710 6:21b3fbe57b88 38 }
alt0710 6:21b3fbe57b88 39
alt0710 6:21b3fbe57b88 40 void NormalRoutine::run(void)
alt0710 6:21b3fbe57b88 41 {
alt0710 7:1f1bdb4e4f33 42 packet.splitPacket();
alt0710 7:1f1bdb4e4f33 43
alt0710 7:1f1bdb4e4f33 44 //Kick
alt0710 7:1f1bdb4e4f33 45 kicker.setCharge(ParameterManager::machine_data.charge_flag);
alt0710 7:1f1bdb4e4f33 46 kicker.setKick(ParameterManager::machine_data.kick_flag,ParameterManager::machine_data.kick_type,ParameterManager::machine_data.kickers_power);
alt0710 10:9cd22f673968 47 kicker.forceFireKick();
alt0710 7:1f1bdb4e4f33 48
alt0710 7:1f1bdb4e4f33 49 //Wheel
alt0710 15:2bf8eafacef8 50 wheel.setVelocity(ParameterManager::machine_data.v_mm_per_sec,ParameterManager::machine_data.angle_degree,ParameterManager::machine_data.vw_mrad_per_sec);
alt0710 15:2bf8eafacef8 51 //wheel.setVelocity(5000,0,0);
alt0710 14:f6cc949a8046 52
alt0710 11:7f5259ad738c 53 //Drible
alt0710 14:f6cc949a8046 54 dribble.setdribble(ParameterManager::machine_data.dribble_flag, ParameterManager::machine_data.dribbler_power);
alt0710 18:8db19ccf7e02 55 //dribble.setdribble(1, 3);
alt0710 7:1f1bdb4e4f33 56
alt0710 23:0bb032ef1880 57 StatusManager::supply_voltage = InterfaceManager::batVoltage.read();
alt0710 24:37a074e767c8 58 StatusManager::supply_voltage *= (float)3.3 * (float)5.977;
alt0710 23:0bb032ef1880 59
alt0710 23:0bb032ef1880 60
alt0710 23:0bb032ef1880 61
alt0710 24:37a074e767c8 62 //sprintf(str,"T%dOv:%d\nC:%3.2f",StatusManager::DriveTime,StatusManager::dribbleMot_OvrCur,StatusManager::dribbleMotor_current);
alt0710 7:1f1bdb4e4f33 63 createLcdData();
alt0710 24:37a074e767c8 64 InterfaceManager::i2c.setLCDMsg(str,sizeof(str));
alt0710 30:8ee22331bfaf 65
alt0710 30:8ee22331bfaf 66 #ifdef ON_INDICATER
alt0710 30:8ee22331bfaf 67 batVoltage[0] = (char)(StatusManager::supply_voltage * 10);
alt0710 30:8ee22331bfaf 68 InterfaceManager::i2c.setIndicateMsg( batVoltage , sizeof(batVoltage));
alt0710 30:8ee22331bfaf 69 #endif
alt0710 30:8ee22331bfaf 70
alt0710 6:21b3fbe57b88 71 }
alt0710 6:21b3fbe57b88 72
alt0710 7:1f1bdb4e4f33 73 void NormalRoutine::createLcdData(void)
alt0710 7:1f1bdb4e4f33 74 {
alt0710 7:1f1bdb4e4f33 75
alt0710 7:1f1bdb4e4f33 76 /*
alt0710 7:1f1bdb4e4f33 77
alt0710 7:1f1bdb4e4f33 78 * 0 : 正常終了
alt0710 7:1f1bdb4e4f33 79
alt0710 7:1f1bdb4e4f33 80 * -1 : タイムアウト
alt0710 7:1f1bdb4e4f33 81
alt0710 7:1f1bdb4e4f33 82 * -2 : オーバーランエラー
alt0710 7:1f1bdb4e4f33 83
alt0710 7:1f1bdb4e4f33 84 * -3 : フレーミングエラー
alt0710 7:1f1bdb4e4f33 85
alt0710 7:1f1bdb4e4f33 86 * 1 : 受信中
alt0710 7:1f1bdb4e4f33 87
alt0710 7:1f1bdb4e4f33 88 * 2 : フレームリーダー1まで受信
alt0710 7:1f1bdb4e4f33 89
alt0710 7:1f1bdb4e4f33 90 * 3 : フレームリーダー2まで受信
alt0710 7:1f1bdb4e4f33 91
alt0710 7:1f1bdb4e4f33 92 * 4 : マシンIDまで受信
alt0710 7:1f1bdb4e4f33 93
alt0710 7:1f1bdb4e4f33 94 */
alt0710 7:1f1bdb4e4f33 95 switch(StatusManager::uart){
alt0710 7:1f1bdb4e4f33 96 case 0:
alt0710 23:0bb032ef1880 97 sprintf(str,"ID%dB%3.1f\nComplete",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 98 sprintf(str_uart,"Complete");
alt0710 7:1f1bdb4e4f33 99 break;
alt0710 7:1f1bdb4e4f33 100
alt0710 7:1f1bdb4e4f33 101 case 1:
alt0710 7:1f1bdb4e4f33 102 break;
alt0710 7:1f1bdb4e4f33 103
alt0710 7:1f1bdb4e4f33 104 case 2:
alt0710 23:0bb032ef1880 105 sprintf(str,"ID%dB%3.1f\nHeader1",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 106 sprintf(str_uart,"Header1");
alt0710 7:1f1bdb4e4f33 107 break;
alt0710 6:21b3fbe57b88 108
alt0710 7:1f1bdb4e4f33 109 case 3:
alt0710 23:0bb032ef1880 110 sprintf(str,"ID%dB%3.1f\nHeader2",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 111 sprintf(str_uart,"Header2");
alt0710 7:1f1bdb4e4f33 112 break;
alt0710 7:1f1bdb4e4f33 113
alt0710 7:1f1bdb4e4f33 114 case 4:
alt0710 23:0bb032ef1880 115 sprintf(str,"ID%dB%3.1f\nCheckER1",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 116 sprintf(str_uart,"CheckERR");
alt0710 7:1f1bdb4e4f33 117 break;
alt0710 7:1f1bdb4e4f33 118
alt0710 7:1f1bdb4e4f33 119 case 5:
alt0710 23:0bb032ef1880 120 sprintf(str,"ID%dB%3.1f\nCheckER2",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 121 sprintf(str_uart,"CheckERR");
alt0710 7:1f1bdb4e4f33 122 break;
alt0710 7:1f1bdb4e4f33 123
alt0710 7:1f1bdb4e4f33 124 case -1:
alt0710 30:8ee22331bfaf 125 //sprintf(str,"ID%dB%3.1f\nTimeOut",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 30:8ee22331bfaf 126 //sprintf(str,"ID%dB%d\nTimeOut",ParameterManager::machine_id,StatusManager::indicate_i2c_enable);
alt0710 30:8ee22331bfaf 127 sprintf(str,"ID%d:TO\nB%3.1fBN%d",ParameterManager::machine_id,StatusManager::supply_voltage,StatusManager::MainBoard);
alt0710 7:1f1bdb4e4f33 128 sprintf(str_uart,"TimeOut");
alt0710 7:1f1bdb4e4f33 129 break;
alt0710 7:1f1bdb4e4f33 130
alt0710 7:1f1bdb4e4f33 131 case -2:
alt0710 23:0bb032ef1880 132 sprintf(str,"ID%dB%3.1f\nOERR",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 133 sprintf(str_uart,"OERR");
alt0710 7:1f1bdb4e4f33 134 break;
alt0710 7:1f1bdb4e4f33 135
alt0710 7:1f1bdb4e4f33 136 case -3:
alt0710 23:0bb032ef1880 137 sprintf(str,"ID%dB%3.1f\nFERR",ParameterManager::machine_id,StatusManager::supply_voltage);
alt0710 7:1f1bdb4e4f33 138 sprintf(str_uart,"FERR");
alt0710 7:1f1bdb4e4f33 139 break;
alt0710 7:1f1bdb4e4f33 140
alt0710 7:1f1bdb4e4f33 141 default:
alt0710 23:0bb032ef1880 142 sprintf(str,"ID%dB%3.1f\n %d",ParameterManager::machine_id,StatusManager::supply_voltage, StatusManager::uart);
alt0710 7:1f1bdb4e4f33 143 break;
alt0710 7:1f1bdb4e4f33 144 }
alt0710 7:1f1bdb4e4f33 145
alt0710 7:1f1bdb4e4f33 146
alt0710 7:1f1bdb4e4f33 147 //sprintf(str,"ID%d EN: \n %s",ParameterManager::machine_id ,str_uart);
alt0710 7:1f1bdb4e4f33 148 }