Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laelaps_tof

Macros

#define APP_EC_OK   0
 success exit code
 
#define APP_EC_ARGS   2
 command-line options/arguments error exit code
 
#define APP_EC_EXEC   4
 execution exit code
 

Enumerations

enum  MeasType {
  MeasTypeDistance,
  MeasTypeAmbient,
  MeasTypeBoth
}
 

Functions

static int OptsCvtArgMeas (const char *argv0, const char *sOptName, char *optarg, void *pOptVal)
 
static int tofNameToInt (const string &str, int &val)
 
static int strToInt (const string &str, int &val)
 
int getch ()
 
int kbhit ()
 
static int connectSensor (int n)
 
static int readSensorInfo ()
 
static int calibrateSensorCrossTalk ()
 
static int calibrateSensorOffset ()
 
static void readSensorCalibTuneRegs ()
 
static void printHdr (int what)
 
static void printMeasurement (int seqnum, int what, double fMeters, double fFlux)
 
static int measure ()
 
static void mainInit (int argc, char *argv[])
 Main initialization. More...
 
int main (int argc, char *argv[])
 Main. More...
 

Variables

static char * Argv0
 the command
 
static bool_t OptsNoAuto = false
 don't auto-run
 
static int OptsTimePeriod = 500
 sense time period (msec)
 
static char * OptsMeasure = (char *)"range"
 measure range
 
static bool_t OptsCalibOffset = false
 do [not] calibrate range offset
 
static bool_t OptsCalibXTalk = false
 do [not] calibrate range crosstalk
 
static const char * ToFName []
 
static const double ToFDir []
 
static int SensorId
 
static int Measure
 
static LaeI2C I2CBus
 
static LaeI2CMux I2CMux (I2CBus)
 
static LaeVL6180MuxToFSensor
 
static const char * Sep
 
static OptsPgmInfo_T PgmInfo
 Program information. More...
 
static OptsInfo_T OptsInfo []
 Command line options information.
 

Detailed Description

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Returns
Returns 0 on succes, non-zero on failure.

Definition at line 689 of file laelaps_tof.cxx.

References APP_EC_EXEC, APP_EC_OK, laelaps::LaeI2C::close(), mainInit(), OptsCalibOffset, and OptsCalibXTalk.

690 {
691  int rc; // return code
692 
693  mainInit(argc, argv);
694 
695  if( connectSensor(SensorId) < 0 )
696  {
697  return APP_EC_EXEC;
698  }
699 
700  readSensorInfo();
701 
702  if( OptsCalibOffset )
703  {
704  calibrateSensorOffset();
705  }
706 
707  if( OptsCalibXTalk )
708  {
709  calibrateSensorCrossTalk();
710  }
711 
712  readSensorCalibTuneRegs();
713 
714  rc = measure();
715 
716  I2CBus.close();
717 
718  return rc == LAE_OK? APP_EC_OK: APP_EC_EXEC;
719 }
static void mainInit(int argc, char *argv[])
Main initialization.
#define APP_EC_OK
success exit code
Definition: laelaps_tof.cxx:84
#define APP_EC_EXEC
execution exit code
Definition: laelaps_tof.cxx:86
static bool_t OptsCalibXTalk
do [not] calibrate range crosstalk
Definition: laelaps_tof.cxx:93
virtual int close()
Close I2C bus device.
Definition: laeI2C.cxx:144
static bool_t OptsCalibOffset
do [not] calibrate range offset
Definition: laelaps_tof.cxx:92
static void mainInit ( int  argc,
char *  argv[] 
)
static

Main initialization.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exits:
Program terminates on conversion error.

Definition at line 650 of file laelaps_tof.cxx.

References APP_EC_ARGS, Argv0, OptsInfo, PgmInfo, and PkgInfo.

Referenced by main().

651 {
652  // name of this process
653  Argv0 = basename(argv[0]);
654 
655  // parse input options
656  argv = OptsGet(Argv0, &PkgInfo, &PgmInfo, OptsInfo, true, &argc, argv);
657 
658  if( argc == 0 )
659  {
660  fprintf(stderr, "%s: No sensor number <N> specified.\n", Argv0);
661  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
662  exit(APP_EC_ARGS);
663  }
664  else if( strToInt(argv[0], SensorId) < 0 )
665  {
666  if( tofNameToInt(argv[0], SensorId) < 0 )
667  {
668  fprintf(stderr, "%s: '%s': Bad sensor Id/Name.\n", Argv0, argv[0]);
669  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
670  exit(APP_EC_ARGS);
671  }
672  }
673  else if( (SensorId < ToFSensor0Chan) || (SensorId > ToFSensor7Chan) )
674  {
675  fprintf(stderr, "%s: %d: Sensor number out of range.\n", Argv0, SensorId);
676  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
677  exit(APP_EC_ARGS);
678  }
679 }
static char * Argv0
the command
Definition: laelaps_tof.cxx:88
static const PkgInfo_T PkgInfo
Definition: version.h:45
#define APP_EC_ARGS
command-line options/arguments error exit code
Definition: laelaps_tof.cxx:85
static OptsPgmInfo_T PgmInfo
Program information.
static OptsInfo_T OptsInfo[]
Command line options information.

Variable Documentation

OptsPgmInfo_T PgmInfo
static
Initial value:
=
{
"{<Id> | <Name>}",
"Test and calibrate Laelaps Time-of-Flight sensors.",
"The %P command tests and calibrates the Laelaps Time-of-Flight sensors. "
"The standard Laelaps comes with 3 forward facing ToFs, with an additional "
"5 sensors available as an upgrade option. Sensors are identified by "
"the number Id number of symbolic Name.\n"
" Id Name Direction Package\n"
" -- ----------- --------- -------\n"
" 0 front 0 degrees std\n"
" 1 left_front 15 degrees std\n"
" 2 left 90 degrees opt\n"
" 3 left_rear 165 degrees opt\n"
" 4 rear 180 degrees opt\n"
" 5 right_rear 195 degrees opt\n"
" 6 right 270 degrees opt\n"
" 7 right_front 345 degrees std\n\n"
"The ROS node laelaps_control cannot be running while using this tool.",
NULL
}

Program information.

Definition at line 132 of file laelaps_tof.cxx.

Referenced by mainInit().

const char* Sep
static
Initial value:
=
"----------------------------------------------------------------------------"

Definition at line 120 of file laelaps_tof.cxx.

const double ToFDir[]
static
Initial value:
=
{
degToRad(0.0), degToRad(15.0), degToRad(90.0), degToRad(165.0),
degToRad(180.0), degToRad(195.0), degToRad(270.0), degToRad(345.0)
}
double degToRad(double d)
Convert degrees to radians.
Definition: laeUtils.h:124

Definition at line 101 of file laelaps_tof.cxx.

const char* ToFName[]
static
Initial value:
=
{
"front", "left_front", "left", "left_rear",
"rear", "right_rear", "right", "right_front"
}

Definition at line 95 of file laelaps_tof.cxx.