/************************************************************/ /* NAME: pMotor */ /* FILE: main.cpp */ /************************************************************/ #include #include "MBUtils.h" #include "ColorParse.h" #include "Motor.h" #include "Motor_Info.h" #include "../pPowerManger/logc/loguru.hpp" using namespace std; int main(int argc, char *argv[]) { loguru::init(argc, argv); string mission_file; string run_command = argv[0]; // 默认以程序文件名(去掉路径)作为进程名,保证与 .moos 中 ProcessConfig 匹配 { size_t slash = run_command.find_last_of('/'); if (slash != string::npos) run_command = run_command.substr(slash + 1); } for (int i = 1; i < argc; i++) { string argi = argv[i]; if ((argi == "-v") || (argi == "--version") || (argi == "-version")) showReleaseInfoAndExit(); else if ((argi == "-e") || (argi == "--example") || (argi == "-example")) showExampleConfigAndExit(); else if ((argi == "-h") || (argi == "--help") || (argi == "-help")) showHelpAndExit(); else if ((argi == "-i") || (argi == "--interface")) showInterfaceAndExit(); else if (strEnds(argi, ".moos") || strEnds(argi, ".moos++")) mission_file = argv[i]; else if (strBegins(argi, "--alias=")) run_command = argi.substr(8); else if (i == 2) run_command = argi; } if (mission_file == "") showHelpAndExit(); LOG_F(INFO, "pMotor launching as %s", run_command.c_str()); motor::Motor Motor; Motor.Run(run_command.c_str(), mission_file.c_str()); return 0; }