58 #include "rnr/rnrconfig.h" 105 "product",
"cpu",
"motors",
"watchdog",
"tof",
"imu",
"cam",
"batt" 119 "Run Laelaps diagnostics.",
122 "The %P command executes Laelaps subsystem diagnostics. " 123 "The Laelaps embedded software interfaces are used to test the subsystems." 125 "DIAG: Diagnostic to run. One of:\n" 126 " all - Run all dignostics.\n" 127 " batt - Run battery dignostics.\n" 128 " cam - Run camera diagnotics.\n" 129 " cpu - Run main CPU diagnotics.\n" 130 " imu - Run Inertia Measurement Unit diagnostics.\n" 131 " motors - Run motors diagnotics.\n" 132 " product - Run Laelaps product diagnotics.\n" 133 " tof - Run time-of-flight sensors diagnostics.\n" 134 " watchdog - Run Arduino watchdog sub-processor diagnostics.\n\n" 135 "The ROS node laelaps_control cannot be running while using this tool.",
157 "Run diagnositcs that causes the Laelaps to move." 171 "For each diagnositc, the user presses any keyboard key to progress to" 172 " the next diagnostic. Only valid for batt, imu, tof diagnostics." 182 bool bUsesI2C =
false;
183 bool bUsesWd =
false;
187 printHdr(
"Diagnostic Prelims");
189 ++statsTotal.testCnt;
191 if( findProc(
"laelaps_control/laelaps_control") > 1 )
193 printTestResult(FatalTag,
194 "The laelaps_control ROS node cannot be running. " 195 "Stop with either:\n" 196 " - 'laelaps_init' GUI\n" 197 " - 'sudo laelaps_service stop' utility\n" 198 " - 'sudo service laelaps_control stop' system init script.");
199 statsTotal.fatal =
true;
203 printTestResult(PassTag,
"The laelaps_control ROS node is not running.");
204 ++statsTotal.passCnt;
207 ++statsTotal.testCnt;
212 if( !statsTotal.fatal )
214 if( xml.
load(RobotDesc, LaeSysCfgPath, LaeEtcCfg) < 0 )
216 printTestResult(FatalTag,
"Loading XML file '%s' failed.", LaeEtcCfg);
217 statsTotal.fatal =
true;
223 printTestResult(PassTag,
"Robot v%s description from '%s' loaded.",
225 ++statsTotal.passCnt;
247 if( !statsTotal.fatal && bUsesI2C )
249 ++statsTotal.testCnt;
252 printTestResult(FailTag,
"Open I2C bus failed.");
253 statsTotal.fatal =
true;
257 printTestResult(PassTag,
"I2C bus opened.");
258 ++statsTotal.passCnt;
262 if( !statsTotal.fatal && bUsesWd )
266 ++statsTotal.testCnt;
269 printTestResult(FailTag,
"WatchDog: Failed to get firmware version.");
274 printTestResult(PassTag,
"Connected to WatchDog sub-processor, fwver=%u.",
276 ++statsTotal.passCnt;
280 ++statsTotal.testCnt;
281 printTestResult(PassTag,
"Preliminaries completed.");
282 ++statsTotal.passCnt;
285 printTotals(statsTotal);
305 Argv0 = basename(argv[0]);
312 fprintf(stderr,
"%s: Error: No diagnostics specified.\n",
Argv0);
313 fprintf(stderr,
"Try '%s --help' for more information.\n",
Argv0);
317 for(
int i = 0; i < argc; ++i)
322 if( strArg ==
"all" )
346 fprintf(stderr,
"%s: Warning: Unknown diganostic %s - ignoring.\n",
347 Argv0, strArg.c_str());
353 fprintf(stderr,
"%s: Error: No valid diagnostics to run.\n",
Argv0);
354 fprintf(stderr,
"Try '%s --help' for more information.\n",
Argv0);
370 LaeWd WatchDog(I2CBus);
380 int main(
int argc,
char* argv[])
387 setTags(LOG_IN_COLOR());
389 statsGrandTotal = prelims();
393 if( statsGrandTotal.fatal )
400 if( strDiag ==
"product" )
402 statsGrandTotal += runProductDiagnostics();
404 else if( strDiag ==
"cpu" )
406 statsGrandTotal += runCpuDiagnostics();
408 else if( strDiag ==
"motors" )
410 statsGrandTotal += runMotorsDiagnostics(
OptsMotion);
412 else if( strDiag ==
"cam" )
414 statsGrandTotal += runCamDiagnostics();
416 else if( strDiag ==
"tof" )
418 statsGrandTotal += runToFDiagnostics(
OptsAnyKey);
420 else if( strDiag ==
"imu" )
422 statsGrandTotal += runImuDiagnostics(
OptsAnyKey);
424 else if( strDiag ==
"watchdog" )
426 statsGrandTotal += runWatchDogDiagnostics();
428 else if( strDiag ==
"batt" )
430 statsGrandTotal += runBatteryDiagnostics(
OptsAnyKey);
434 printGrandTotals(statsGrandTotal);
#define APP_EC_ARGS
command-line options/arguments error exit code
Laelaps robotic mobile platform full description class.
#define APP_EC_OK
success exit code
RoboClaw motor controller class interface.
static char * Argv0
the command
Laelaps PCA9548A I2C multiplexer switch interface.
static OptsPgmInfo_T PgmInfo
Program information.
Laelaps I2C class interface.
static bool_t OptsAnyKey
user presses anykey to stop option
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Laelaps robotic base mobile platform description class interface.
static const PkgInfo_T PkgInfo
Simple diagnostics statistics class.
Laelaps common utilities.
static OptsInfo_T OptsInfo[]
Command line options information.
static bool_t OptsMotion
motion option
int markAsDescribed()
Mark <b><i>Laelaps</i></b> hardware as fully described.
Package version information.
int main(int argc, char *argv[])
Main.
virtual int cmdGetFwVersion(uint_t &uVerNum)
Get the firmware version command.
Laelaps motors, encoder, and controllers hardware abstraction interfaces.
static const char * DiagnosticsAvail[]
Available diagnostics.
static void mainInit(int argc, char *argv[])
Main initialization.
<b><i>Laelaps</i></b> XML configuration class interface.
static vector< string > DiagnosticsToRun
diagnostics to run
virtual int load(LaeDesc &desc, const std::string &strSearchPath, const std::string &strXmlFileName, bool bAllInstances=false)
Load XML file into DOM and set the <b><i>Laelaps</i></b> description.
std::string getProdHwVerString() const
Get this robot's hardware version string.
int i2cTryOpen(LaeI2C &i2cBus, uint_t addr)
Try to open a series of I2C devices to fine the required endpoint.
virtual void sync()
Synchronize watchdog state with subprocessor state.
Top-level package include file.
LaeXmlCfg <b><i>Laelaps</i></b> XML configuration class.