Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laelaps::LaeDesc Class Reference

Laelaps robotic mobile platform full description class. More...

#include <laeDesc.h>

Public Types

typedef std::map< std::string, LaeDescPowertrain * > MapDescPowertrain
 
typedef std::map< std::string, LaeDescRangeSensor * > MapDescRangeSensor
 

Public Member Functions

 LaeDesc ()
 
virtual ~LaeDesc ()
 
int markAsDescribed ()
 Mark Laelaps hardware as fully described. More...
 
void clear ()
 Clear description to the "unitialized" values.
 
bool isDescribed () const
 Test if required base description is adequately described. More...
 
int getProdId () const
 Get this base description's base product id. More...
 
std::string getProdName () const
 Get this base description's name. More...
 
std::string getProdBrief () const
 Get this base description's brief. More...
 
std::string getProdHwVerString () const
 Get this robot's hardware version string. More...
 
uint_t getProdHwVer () const
 Get this robot's packed hardware version number. More...
 
void print (int indent=0)
 Print out description to stdout. More...
 

Static Public Member Functions

static std::string prettyMotorCtlrName (int nCtlrId)
 Create pretty motor controller identifier string. More...
 
static std::string prettyMotorCtlrName (int nCtlrId, byte_t addr)
 Create pretty motor controller identifier string. More...
 
static std::string prettyMotorName (int nMotorId)
 Create pretty motor/powertrain identifier string. More...
 
static std::string prettyMotorName (int nCtlrId, byte_t addr, int nMotorId)
 Create pretty motor/powertrain identifier string. More...
 
static const char * getProdName (int eProdId)
 Get the Laelaps product name string given the product id. More...
 
static const char * getProdBrief (int eProdId)
 Get the Laelaps product one-line brief description string given the product id. More...
 

Public Attributes

bool m_bIsDescribed
  Laelaps is [not] fully described
 
int m_eProdId
 base product id
 
std::string m_strProdFamily
 product family
 
std::string m_strProdModel
 product model
 
std::string m_strProdName
 product name
 
std::string m_strProdBrief
 product brief
 
std::string m_strProdHwVer
 product hardware version string
 
uint_t m_uProdHwVer
 product hardware version number
 
LaeDescOptions m_options
 
LaeDescBasem_pDescBase
 base description
 
LaeDescBatterym_pDescBattery
 internal battery description
 
MapDescPowertrain m_mapDescPowertrain
 powertrain descriptions
 
MapDescRangeSensor m_mapDescRangeSensor
 range sensor descriptions
 
LaeDescImum_pDescImu
 built-in imu description
 

Static Public Attributes

static const char *const KeyRobotBase = "platform"
 robot base key
 
static const char *const KeyBattery = "battery"
 internal battery key
 
static const char *const KeyMotorCtlr []
 motor controller keys More...
 
static const char *const KeyPowertrain []
 powertrain keys More...
 
static const char *const KeyImu = "imu"
 built-in IMU keys
 
static const char *const KeyRangeSensorMax []
 max range sensor keys More...
 
static const char *const KeyRangeSensorStd []
 std range sensor keys More...
 
static const char *const KeyFCam = "fcam"
 front camera keys
 

Protected Member Functions

void setVersion ()
 Set version number from parsed version string.
 

Detailed Description

Laelaps robotic mobile platform full description class.

The description is determined from the XML etc configuration file. From those description components, the compiled description are assigned.

Definition at line 451 of file laeDesc.h.

Member Typedef Documentation

typedef std::map<std::string, LaeDescPowertrain*> laelaps::LaeDesc::MapDescPowertrain

Map of powertrain descriptions type.

Definition at line 455 of file laeDesc.h.

typedef std::map<std::string, LaeDescRangeSensor*> laelaps::LaeDesc::MapDescRangeSensor

Map of range sensor descriptions type.

Definition at line 458 of file laeDesc.h.

Constructor & Destructor Documentation

LaeDesc::LaeDesc ( )

Default constructor.

Definition at line 655 of file laeDesc.cxx.

References laelaps::LaeProdIdUnknown, m_bIsDescribed, m_eProdId, m_pDescBase, m_pDescBattery, m_pDescImu, and m_uProdHwVer.

655  :
657 {
658  m_bIsDescribed = false;
660  m_uProdHwVer = 0;
661 
662  m_pDescBase = NULL;
663  m_pDescBattery = NULL;
664  m_pDescImu = NULL;
665 }
LaeDescBase * m_pDescBase
base description
Definition: laeDesc.h:523
LaeDescImu * m_pDescImu
built-in imu description
Definition: laeDesc.h:527
static const int LaeProdIdUnknown
unknown/undefined product id
Definition: laelaps.h:143
LaeDescBattery * m_pDescBattery
internal battery description
Definition: laeDesc.h:524
std::string m_strProdFamily
product family
Definition: laeDesc.h:512
uint_t m_uProdHwVer
product hardware version number
Definition: laeDesc.h:517
int m_eProdId
base product id
Definition: laeDesc.h:511
const char *const LaeProdFamily
product family name
Definition: laelaps.h:140
bool m_bIsDescribed
<b><i>Laelaps</i></b> is [not] fully described
Definition: laeDesc.h:510
LaeDesc::~LaeDesc ( )
virtual

Destructor.

Definition at line 667 of file laeDesc.cxx.

References clear().

668 {
669  clear();
670 }
void clear()
Clear description to the "unitialized" values.
Definition: laeDesc.cxx:748

Member Function Documentation

std::string laelaps::LaeDesc::getProdBrief ( ) const
inline

Get this base description's brief.

Returns
Returns string.

Definition at line 588 of file laeDesc.h.

Referenced by laelaps::LaeRobot::getFullProdBrief().

589  {
590  return m_strProdBrief;
591  }
std::string m_strProdBrief
product brief
Definition: laeDesc.h:515
const char * LaeDesc::getProdBrief ( int  eProdId)
static

Get the Laelaps product one-line brief description string given the product id.

Parameters
eProdIdSupported product id. See LaeProdId.
Returns
Returns product description string. An unidentified product id returns "".

Definition at line 808 of file laeDesc.cxx.

References laelaps::LaeProdIdLarge, and laelaps::LaeProdIdStd.

809 {
810  switch( eProdId )
811  {
812  case LaeProdIdStd:
813  return "RoadNarrows Laelaps Standard robotic mobile platform";
814  case LaeProdIdLarge:
815  return "RoadNarrows Laelaps Large robotic mobile platform";
816  default:
817  return "";
818  }
819 }
static const int LaeProdIdStd
standard Laelaps product id
Definition: laelaps.h:144
static const int LaeProdIdLarge
large Laelaps product id
Definition: laelaps.h:145
uint_t laelaps::LaeDesc::getProdHwVer ( ) const
inline

Get this robot's packed hardware version number.

Returns
Number.

Definition at line 608 of file laeDesc.h.

References laelaps::LaeDescBase::print().

Referenced by laelaps::LaeRobot::connSensors(), and laelaps::LaeRobot::getVersion().

609  {
610  return m_uProdHwVer;
611  }
uint_t m_uProdHwVer
product hardware version number
Definition: laeDesc.h:517
std::string laelaps::LaeDesc::getProdHwVerString ( ) const
inline

Get this robot's hardware version string.

Returns
Returns string.

Definition at line 598 of file laeDesc.h.

Referenced by laelaps::LaeRobot::getVersionString().

599  {
600  return m_strProdHwVer;
601  }
std::string m_strProdHwVer
product hardware version string
Definition: laeDesc.h:516
int laelaps::LaeDesc::getProdId ( ) const
inline

Get this base description's base product id.

Returns
Returns product id. See LaeProdId.

Definition at line 568 of file laeDesc.h.

Referenced by laelaps::LaeRobot::getProdId().

569  {
570  return m_eProdId;
571  }
int m_eProdId
base product id
Definition: laeDesc.h:511
std::string laelaps::LaeDesc::getProdName ( ) const
inline

Get this base description's name.

Returns
Returns string.

Definition at line 578 of file laeDesc.h.

Referenced by laelaps::LaeRobot::getProdName().

579  {
580  return m_strProdName;
581  }
std::string m_strProdName
product name
Definition: laeDesc.h:514
const char * LaeDesc::getProdName ( int  eProdId)
static

Get the Laelaps product name string given the product id.

Parameters
eProdIdSupported product id. See LaeProdId.
Returns
Returns product name string. An unidentified product id returns "".

Definition at line 795 of file laeDesc.cxx.

References laelaps::LaeProdIdLarge, and laelaps::LaeProdIdStd.

796 {
797  switch( eProdId )
798  {
799  case LaeProdIdStd:
800  return "Laelaps-Standard";
801  case LaeProdIdLarge:
802  return "Laelaps-Large";
803  default:
804  return "";
805  }
806 }
static const int LaeProdIdStd
standard Laelaps product id
Definition: laelaps.h:144
static const int LaeProdIdLarge
large Laelaps product id
Definition: laelaps.h:145
bool laelaps::LaeDesc::isDescribed ( ) const
inline

Test if required base description is adequately described.

Returns
Returns true or false.

Definition at line 558 of file laeDesc.h.

Referenced by laelaps::LaeRobot::connect(), and laelaps::LaeRobot::isDescribed().

559  {
560  return m_bIsDescribed;
561  }
bool m_bIsDescribed
<b><i>Laelaps</i></b> is [not] fully described
Definition: laeDesc.h:510
int LaeDesc::markAsDescribed ( )

Mark Laelaps hardware as fully described.

The calling application context determines this state.

Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 672 of file laeDesc.cxx.

References KeyPowertrain, KeyRangeSensorMax, KeyRangeSensorStd, laelaps::LAE_ECODE_BAD_OP, laelaps::LAE_OK, LAE_VERSION, laelaps::LaeMotorsNumOf, laelaps::LaeProdIdLarge, laelaps::LaeProdIdStd, laelaps::LaeProdIdUnknown, m_bIsDescribed, laelaps::LaeDbProduct::m_eProdId, m_eProdId, m_mapDescPowertrain, m_mapDescRangeSensor, m_pDescBase, m_pDescBattery, m_pDescImu, laelaps::LaeDb::m_product, laelaps::LaeDescOptions::m_strPkgToF, m_strProdHwVer, laelaps::LaeDbProduct::m_uProdHwVer, m_uProdHwVer, laelaps::LaeDescOptions::PkgOptDeluxe, laelaps::RtDb, setVersion(), laelaps::ToFSensorMaxNumOf, and laelaps::ToFSensorStdNumOf.

Referenced by main(), and mainInit().

673 {
674  const char *sKey;
675  int i;
676  int rc;
677 
678  setVersion();
679 
680  switch( m_eProdId )
681  {
682  case LaeProdIdStd:
683  case LaeProdIdLarge:
684  if( m_uProdHwVer < LAE_VERSION(2, 5, 0) )
685  {
686  m_pDescBase = new LaeDescBase();
688 
689  for(i = 0; i < LaeMotorsNumOf; ++i)
690  {
691  sKey = KeyPowertrain[i];
692  m_mapDescPowertrain[sKey] = new LaeDescPowertrain(sKey);
693  }
694 
695  // deluxe time-of-flight sensor package
696  if( m_options.m_strPkgToF == LaeDescOptions::PkgOptDeluxe )
697  {
698  for(i = 0; i < ToFSensorMaxNumOf; ++i)
699  {
700  sKey = KeyRangeSensorMax[i];
701  m_mapDescRangeSensor[sKey] = new LaeDescRangeSensor(sKey);
702  }
703  }
704  // standard time-of-flight sensor package
705  else
706  {
707  for(i = 0; i < ToFSensorStdNumOf; ++i)
708  {
709  sKey = KeyRangeSensorStd[i];
710  m_mapDescRangeSensor[sKey] = new LaeDescRangeSensor(sKey);
711  }
712  }
713 
714  // imu built-in package
715  m_pDescImu = new LaeDescImu();
716 
719 
720  rc = LAE_OK;
721  }
722  else
723  {
724  LOGERROR("Version %s: Laelaps robot version unsupported.",
725  m_strProdHwVer.c_str());
726  rc = -LAE_ECODE_BAD_OP;
727  }
728  break;
729 
730  case LaeProdIdUnknown:
731  LOGERROR("Laelaps robot description is undefined.");
732  rc = -LAE_ECODE_BAD_OP;
733  break;
734  default:
735  LOGERROR("ProdId %d: Unknown Laelaps robot product id.", m_eProdId);
736  rc = -LAE_ECODE_BAD_OP;
737  break;
738  }
739 
740  if( rc == LAE_OK )
741  {
742  m_bIsDescribed = true;
743  }
744 
745  return rc;
746 }
int m_eProdId
base product id
Definition: laeDb.h:79
LaeDescBase * m_pDescBase
base description
Definition: laeDesc.h:523
LaeDbProduct m_product
product data
Definition: laeDb.h:227
LaeDescImu * m_pDescImu
built-in imu description
Definition: laeDesc.h:527
Battery description.
Definition: laeDesc.h:235
static const int LaeProdIdStd
standard Laelaps product id
Definition: laelaps.h:144
static const int LaeProdIdLarge
large Laelaps product id
Definition: laelaps.h:145
uint_t m_uProdHwVer
product hardware version number
Definition: laeDb.h:80
const int ToFSensorStdNumOf
max num of ToF sensors for std option
Definition: laeSysDev.h:245
static const int LaeMotorsNumOf
number of motors
Definition: laeMotor.h:107
static const char *const PkgOptDeluxe
deluxe package option
Definition: laeDesc.h:402
const int ToFSensorMaxNumOf
maximum number of ToF sensors
Definition: laeSysDev.h:244
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
void setVersion()
Set version number from parsed version string.
Definition: laeDesc.cxx:866
std::string m_strPkgToF
range time-of-flight package
Definition: laeDesc.h:404
static const int LaeProdIdUnknown
unknown/undefined product id
Definition: laelaps.h:143
Robotic built-in IMU description.
Definition: laeDesc.h:350
Robotic powertrain description.
Definition: laeDesc.h:177
MapDescPowertrain m_mapDescPowertrain
powertrain descriptions
Definition: laeDesc.h:525
LaeDescBattery * m_pDescBattery
internal battery description
Definition: laeDesc.h:524
std::string m_strProdHwVer
product hardware version string
Definition: laeDesc.h:516
uint_t m_uProdHwVer
product hardware version number
Definition: laeDesc.h:517
int m_eProdId
base product id
Definition: laeDesc.h:511
static const int LAE_ECODE_BAD_OP
invalid operation error
Definition: laelaps.h:80
Robotic base platform description.
Definition: laeDesc.h:113
static const char *const KeyPowertrain[]
powertrain keys
Definition: laeDesc.h:463
#define LAE_VERSION(major, minor, revision)
Convert version triplet to integer equivalent.
Definition: laelaps.h:158
static const char *const KeyRangeSensorStd[]
std range sensor keys
Definition: laeDesc.h:466
bool m_bIsDescribed
<b><i>Laelaps</i></b> is [not] fully described
Definition: laeDesc.h:510
Range sensor description.
Definition: laeDesc.h:288
static const char *const KeyRangeSensorMax[]
max range sensor keys
Definition: laeDesc.h:465
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
MapDescRangeSensor m_mapDescRangeSensor
range sensor descriptions
Definition: laeDesc.h:526
std::string LaeDesc::prettyMotorCtlrName ( int  nCtlrId)
static

Create pretty motor controller identifier string.

Parameters
nCtlrIdUnique motor controller id.
Returns
String

Definition at line 596 of file laeDesc.cxx.

References KeyMotorCtlr.

Referenced by prettyMotorName().

597 {
598  std::locale loc;
599  std::stringstream ss;
600  std::string str;
601 
602  ss << LaeDesc::KeyMotorCtlr[nCtlrId] << " motor controller";
603  str = ss.str();
604 
605  str[0] = std::toupper(str[0], loc);
606 
607  return str;
608 }
static const char *const KeyMotorCtlr[]
motor controller keys
Definition: laeDesc.h:462
std::string LaeDesc::prettyMotorCtlrName ( int  nCtlrId,
byte_t  addr 
)
static

Create pretty motor controller identifier string.

Parameters
nCtlrIdUnique motor controller id.
addrMotor controller packet address.
Returns
String

Definition at line 610 of file laeDesc.cxx.

References KeyMotorCtlr.

611 {
612  std::locale loc;
613  std::stringstream ss;
614  std::string str;
615 
616  ss << LaeDesc::KeyMotorCtlr[nCtlrId] << " motor controller (0x"
617  << std::hex << std::setfill('0') << std::setw(2) << (unsigned)addr
618  << ")";
619  str = ss.str();
620 
621  str[0] = std::toupper(str[0], loc);
622 
623  return str;
624 }
static const char *const KeyMotorCtlr[]
motor controller keys
Definition: laeDesc.h:462
std::string LaeDesc::prettyMotorName ( int  nMotorId)
static

Create pretty motor/powertrain identifier string.

Parameters
nMotorIdUnique motor id.
Returns
String

Definition at line 626 of file laeDesc.cxx.

References KeyPowertrain.

Referenced by prettyMotorName().

627 {
628  std::locale loc;
629  std::stringstream ss;
630  std::string str;
631  size_t n;
632 
633  ss << LaeDesc::KeyPowertrain[nMotorId] << " motor (id=" << nMotorId << ")";
634  str = ss.str();
635 
636  str[0] = std::toupper(str[0], loc);
637  if( (n = str.find_first_of('_')) != str.npos )
638  {
639  str.replace(n, 1, " ");
640  }
641 
642  return str;
643 }
static const char *const KeyPowertrain[]
powertrain keys
Definition: laeDesc.h:463
std::string LaeDesc::prettyMotorName ( int  nCtlrId,
byte_t  addr,
int  nMotorId 
)
static

Create pretty motor/powertrain identifier string.

Parameters
nCtlrIdUnique motor controller id.
addrMotor controller packet address.
nMotorIdUnique motor id.
Returns
String

Definition at line 645 of file laeDesc.cxx.

References prettyMotorCtlrName(), and prettyMotorName().

646 {
647  std::stringstream ss;
648 
649  ss << LaeDesc::prettyMotorCtlrName(nCtlrId, addr) << ": "
650  << LaeDesc::prettyMotorName(nMotorId);
651 
652  return ss.str();
653 }
static std::string prettyMotorName(int nMotorId)
Create pretty motor/powertrain identifier string.
Definition: laeDesc.cxx:626
static std::string prettyMotorCtlrName(int nCtlrId)
Create pretty motor controller identifier string.
Definition: laeDesc.cxx:596
void LaeDesc::print ( int  indent = 0)

Print out description to stdout.

Parameters
indentLeft indentation.

Definition at line 821 of file laeDesc.cxx.

References m_eProdId, m_mapDescPowertrain, m_mapDescRangeSensor, m_pDescBase, m_pDescBattery, m_pDescImu, m_strProdBrief, m_strProdFamily, m_strProdHwVer, m_strProdModel, m_strProdName, m_uProdHwVer, laelaps::LaeDescBase::print(), laelaps::LaeDescBattery::print(), and laelaps::LaeDescImu::print().

Referenced by mainInit().

822 {
823  printf("%*sRobot Description =\n", indent, "");
824  printf("%*s{\n", indent, "");
825 
826  printf("%*sProduct Id = %d\n", indent+2, "", m_eProdId);
827  printf("%*sProduct Family = %s\n", indent+2, "", m_strProdFamily.c_str());
828  printf("%*sProduct Model = %s\n", indent+2, "", m_strProdModel.c_str());
829  printf("%*sProduct Full Name = %s\n", indent+2, "", m_strProdName.c_str());
830  printf("%*sProduct Brief = %s\n", indent+2, "", m_strProdBrief.c_str());
831  printf("%*sHardware Version = %s\n", indent+2, "", m_strProdHwVer.c_str());
832  printf("%*sHardware Version = 0x%08x\n", indent+2, "", m_uProdHwVer);
833 
834  if( m_pDescBase != NULL )
835  {
836  m_pDescBase->print(indent+2);
837  }
838 
839  if( m_pDescBattery != NULL )
840  {
841  m_pDescBattery->print(indent+2);
842  }
843 
844  for(MapDescPowertrain::iterator iter = m_mapDescPowertrain.begin();
845  iter != m_mapDescPowertrain.end();
846  ++iter)
847  {
848  iter->second->print(indent+2);
849  }
850 
851  for(MapDescRangeSensor::iterator iter = m_mapDescRangeSensor.begin();
852  iter != m_mapDescRangeSensor.end();
853  ++iter)
854  {
855  iter->second->print(indent+2);
856  }
857 
858  if( m_pDescImu != NULL )
859  {
860  m_pDescImu->print(indent+2);
861  }
862 
863  printf("%*s}\n", indent, "");
864 }
LaeDescBase * m_pDescBase
base description
Definition: laeDesc.h:523
LaeDescImu * m_pDescImu
built-in imu description
Definition: laeDesc.h:527
std::string m_strProdBrief
product brief
Definition: laeDesc.h:515
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:342
std::string m_strProdModel
product model
Definition: laeDesc.h:513
MapDescPowertrain m_mapDescPowertrain
powertrain descriptions
Definition: laeDesc.h:525
LaeDescBattery * m_pDescBattery
internal battery description
Definition: laeDesc.h:524
std::string m_strProdHwVer
product hardware version string
Definition: laeDesc.h:516
std::string m_strProdFamily
product family
Definition: laeDesc.h:512
uint_t m_uProdHwVer
product hardware version number
Definition: laeDesc.h:517
int m_eProdId
base product id
Definition: laeDesc.h:511
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:510
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:172
std::string m_strProdName
product name
Definition: laeDesc.h:514
MapDescRangeSensor m_mapDescRangeSensor
range sensor descriptions
Definition: laeDesc.h:526

Member Data Documentation

const char *const LaeDesc::KeyMotorCtlr
static
Initial value:

motor controller keys

Definition at line 462 of file laeDesc.h.

Referenced by laelaps::LaeTunes::LaeTunes(), prettyMotorCtlrName(), and laelaps::LaeDescOptions::print().

const char *const LaeDesc::KeyPowertrain
static
Initial value:

powertrain keys

Definition at line 463 of file laeDesc.h.

Referenced by markAsDescribed(), prettyMotorName(), and laelaps::LaeDescOptions::print().

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

max range sensor keys

Definition at line 465 of file laeDesc.h.

Referenced by laelaps::LaeTunes::LaeTunes(), markAsDescribed(), and laelaps::LaeDescOptions::print().

const char *const LaeDesc::KeyRangeSensorStd
static
Initial value:
=
{
"front", "left_front", "right_front"
}

std range sensor keys

Definition at line 466 of file laeDesc.h.

Referenced by markAsDescribed(), and laelaps::LaeDescOptions::print().


The documentation for this class was generated from the following files: