58 #include "rnr/rnrconfig.h" 79 static const char *SubSysName =
"ToF";
80 static const char *ProdName =
"VL6180";
82 static const char *SensorKeys[ToFSensorMaxNumOf] =
84 "front",
"left_front",
"left",
"left_rear",
85 "rear",
"right_rear",
"right",
"right_front" 90 uint_t uVerMajor, uVerMinor, uFwVer;
94 printSubHdr(
"Initialize Sensors");
100 printTestResult(PassTag,
"Range Sensor Group interface set.");
105 printTestResult(FatalTag,
106 "Failed to set interface with product hw version 0x%x.",
117 printTestResult(PassTag,
"Range Sensor Group interface %u.%u, fwver=%u.",
118 uVerMajor, uVerMinor, uFwVer);
125 printTestResult(FailTag,
126 "Failed to read range sensor group interface version.");
134 if( rnggrp.
configure(RobotDesc) == LAE_OK )
136 printTestResult(PassTag,
137 "Configured range sensors from robot description.");
142 printTestResult(FailTag,
"Failed to configure range sensors.");
154 string strRadiationType;
167 uint_t uRangeCrossTalk;
169 uint_t uAlsIntPeriod;
175 printSubHdr(
"Read Sensors Properties and Tuning");
180 for(
size_t i = 0; i < ToFSensorMaxNumOf; ++i)
182 sKey = SensorKeys[i];
191 fFoV, fBeamDir, fMin, fMax);
195 printTestResult(PassTag,
"%s %s sensor: Got sensor properties.",
200 else if( rc == -LAE_ECODE_BAD_VAL )
202 printTestResult(PassTag,
"%s %s sensor: NOT INSTALLED.", ProdName, sKey);
207 printTestResult(FailTag,
"%s %s sensor: Failed to get sensor properties.",
219 printTestResult(PassTag,
"%s %s sensor: Read sensor identity.",
226 printTestResult(FailTag,
227 "%s %s sensor: Failed to read sensor identity.",
234 fAlsGain, uAlsIntPeriod);
238 printTestResult(PassTag,
"%s %s sensor: Read sensor tuning parameters.",
245 printTestResult(PassTag,
246 "%s %s sensor: Failed to read sensor tuning parameters.",
252 printf(
"%s %s Sensor Info:\n", SubSysName, ProdName);
253 printf(
" Properties\n");
254 printf(
" Location: %s\n", sKey);
255 printf(
" Installed: %s\n", (bInstalled?
"yes":
"no"));
256 printf(
" Beam Direction: %.1lf degrees\n",
radToDeg(fBeamDir));
257 printf(
" Radiation: %s\n", strRadiationType.c_str());
258 printf(
" FoV: %.1lf degrees\n",
radToDeg(fFoV));
259 printf(
" Min Distance: %.3lf meters\n", fMin);
260 printf(
" MAx Distance: %.3lf meters\n", fMax);
263 printf(
" Identity\n");
264 printf(
" Model: 0x%02x v%u.%u\n",
265 ident.idModel, ident.idModelRevMajor, ident.idModelRevMinor);
266 printf(
" Module: v%u.%u\n",
267 ident.idModuleRevMajor, ident.idModuleRevMinor);
268 printf(
" Date/Time: %u/%u\n", ident.idDate, ident.idTime);
273 printf(
" Range Offset: %u\n", uRangeOffset);
274 printf(
" Range Cross-Talk: %u\n", uRangeCrossTalk);
275 printf(
" ALS Gain: %.2lf\n", fAlsGain);
276 printf(
" ALS Int. Period: %u\n", uAlsIntPeriod);
287 vector<double> distance;
293 showLabel = cnt == 0;
297 rc = rnggrp.
getRange(keys, distance);
305 printTestResult(FailTag,
"%s: Failed to get distance measurements.",
313 for(
size_t i = 0; i < keys.size(); ++i)
315 printf(
"%10s ", keys[i].c_str());
320 printf(
"%6d. ", cnt);
321 for(
size_t i = 0; i < distance.size(); ++i)
325 printf(
"%10s ",
"noobj");
327 else if( distance[i] < 0 )
329 printf(
"%10s ",
"error");
333 printf(
"%10.3lf ", distance[i]);
345 vector<double> ambient;
351 showLabel = cnt == 0;
363 printTestResult(FailTag,
"%s: Failed to get ambient light measurements.",
371 for(
size_t i = 0; i < keys.size(); ++i)
373 printf(
"%10s ", keys[i].c_str());
378 printf(
"%6d. ", cnt);
379 for(
size_t i = 0; i < ambient.size(); ++i)
381 printf(
"%10.2lf ", ambient[i]);
389 DiagStats runToFDiagnostics(
bool bAnyKey)
396 printHdr(
"Time-of-Flight Sensors Diagnostics");
403 statsTest = initSensors(rangegroup);
405 printSubTotals(statsTest);
407 statsTotal += statsTest;
412 if( !statsTotal.fatal )
414 statsTest = getSensorInfo(rangegroup);
416 printSubTotals(statsTest);
418 statsTotal += statsTest;
426 bQuit = statsTotal.fatal;
429 printSubHdr(
"Distance Measurements");
435 statsTest += measureDistance(rangegroup, cnt++);
437 if( !bAnyKey || kbhit() || statsTest.fatal )
440 printSubTotals(statsTest);
449 statsTotal += statsTest;
456 bQuit = statsTotal.fatal;
459 printSubHdr(
"Ambient Light Measurements");
462 printf(
"Warning: The ALS is experimental and is disabled in production.\n");
469 statsTest += measureAmbient(rangegroup, cnt++);
471 if( !bAnyKey || kbhit() || statsTest.fatal )
474 printSubTotals(statsTest);
483 statsTotal += statsTest;
488 printTotals(statsTotal);
uint_t getProdHwVer() const
Get this robot's packed hardware version number.
#define VL6180X_RANGE_MAX
maximum range (m)
virtual int getRange(const std::string &strKey, double &fRange)
Get the shadowed range measurement.
void clearSensedData()
Clear sensed data.
virtual int getInterfaceVersion(uint_t &uVerMajor, uint_t &uVerMinor, uint_t &uFwVer)
Get interface version.
Laelaps I2C class interface.
double radToDeg(double r)
Convert radians to degrees.
virtual int configure(const laelaps::LaeDesc &desc)
Configure sensor group from product description.
Laelaps Time-of-Flight sensors. The ToFs are used as a virtual bumper for close-in obstacle detection...
void zero()
Zero statistics.
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Laelaps robotic base mobile platform description class interface.
Simple diagnostics statistics class.
Laelaps common utilities.
virtual int readSensorIdentity(const std::string &strKey, VL6180xIdentification &ident)
Read sensor's identification.
int setInterface(uint_t uProdHwVer)
Set the interface, given the <b><i>Laelaps</i></b> hardware version.
virtual int getAmbientLight(const std::string &strKey, double &fAmbient)
Get the shadowed ambient light illuminance measurement.
virtual int getSensorProps(const std::string &strKey, std::string &strRadiationType, double &fFoV, double &fBeamDir, double &fMin, double &fMax)
Get range sensor properties.
virtual int readSensorTunes(const std::string &strKey, uint_t &uRangeOffset, uint_t &uRangeCrossTalk, double &fAlsGain, uint_t &uAlsIntPeriod)
Read sensor's current tuning parameters.
Range sensor group class.
Top-level package include file.