int main(int argc,char *argv[]) { int i; int motorNo; float vSetF; enum DriveMode drive; char *controlOperand; for(i=0;i<argc;i++){ if( strcmp(argv[i],"-c")==0){ controlOperand=argv[i+1]; }else if( strcmp(argv[i],"-v")==0){ vSetF = atof(argv[i+1]); }else if( strcmp(argv[i],"-n")==0){ motorNo = atoi(argv[i+1]); }else if( strcmp(argv[i],"-h")==0){ printf("-c pos:正転\n neg:逆転\n stop:停止\n stanby:惰走\n"); printf("-n モータ番号(0~1) \n"); printf("-v 電圧(0.48~5.06) \n"); } } if( strcmp(controlOperand,"pos")==0){ if(vSetF!=0){ drive=PositiveDrive; }else{ printf("Voletage dont input!!"); return 1; } }else if(strcmp(controlOperand,"neg")==0){ if(vSetF!=0){ drive=NegativeDrive; }else{ printf("Voletage dont input!!"); return 1; } }else if(strcmp(controlOperand,"stop")==0){ drive=Break; vSetF=1; }else if(strcmp(controlOperand,"stanby")==0){ drive=Stanby; vSetF=1; }else{ printf("Operand Error!!\n"); return 1; } return motorDrive(motorNo, drive,vSetF); }
//メソッド:void 競技走行する() void CompetitionRunning::CompetitionRun(){ float TAIL_ANGLE_DRIVE = 3; MotorDrive motorDrive( m_pDeviceInterface ); SectionDecisionController sectionDecisionController( m_pDeviceInterface ); RunningController runningController( m_pDeviceInterface, m_pUIGet ); while (m_nNowSection < 7) { ev3_lcd_draw_string("running_start", 0, 60); //しっぽをバランス走行用に制御 motorDrive.TailMotorDrive(TAIL_ANGLE_DRIVE); //区間判断コントローラに現区間の番号をもらう m_nNowSection = sectionDecisionController.SectionIdentify(m_nNowSection); if(m_nNowSection == 7) break; //走行コントローラに投げる runningController.RunningExecute(m_nNowSection); if (m_pUIGet->UIGetter().Button == 'B') break; m_pDeviceInterface->m_pCClock->sleep(3); /* 4msec周期起動 */ } ev3_lcd_draw_string("running_end", 0, 60); }
// drive the left motor, input should be between -100 and 100 void DashBot::motorDriveL(float motor_pwm) { motorDrive(motor_pwm, 'L'); }
// drive the right motor, input should be between -100 and 100 void DashBot::motorDriveR(float motor_pwm) { motorDrive(motor_pwm, 'R'); }