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:
Sat Apr 28 19:47:31 2018 +0000
Revision:
24:37a074e767c8
Parent:
23:0bb032ef1880
Child:
30:8ee22331bfaf
ID??????????????????Ticker??????????????????????????????????????main??????????main?????????????;

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