Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeDesc.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // Library: liblaelaps
6 //
7 // File: laeDesc.cxx
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2016-02-15 15:44:49 -0700 (Mon, 15 Feb 2016) $
12  * $Rev: 4320 $
13  *
14  * \brief Laelaps robotic base mobile platform description class implementation.
15  *
16  * The base description does not include any payload descriptions.
17  * Any applicable tuning parameters override the description.
18  *
19  * \author Robin Knight (robin.knight@roadnarrows.com)
20  *
21  * \par Copyright
22  * \h_copy 2015-2017. RoadNarrows LLC.\n
23  * http://www.roadnarrows.com\n
24  * All Rights Reserved
25  */
26 /*
27  * @EulaBegin@
28  *
29  * Unless otherwise stated explicitly, all materials contained are copyrighted
30  * and may not be used without RoadNarrows LLC's written consent,
31  * except as provided in these terms and conditions or in the copyright
32  * notice (documents and software) or other proprietary notice provided with
33  * the relevant materials.
34  *
35  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
36  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
37  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
38  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
39  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
40  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
43  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
44  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
45  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
46  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
47  *
48  * @EulaEnd@
49  */
50 ////////////////////////////////////////////////////////////////////////////////
51 
52 #include <stdio.h>
53 #include <math.h>
54 
55 #include <string>
56 #include <sstream>
57 #include <iomanip>
58 #include <locale>
59 #include <vector>
60 #include <map>
61 
62 #include "rnr/rnrconfig.h"
63 #include "rnr/log.h"
64 
65 #include "Laelaps/laelaps.h"
66 #include "Laelaps/laeUtils.h"
67 #include "Laelaps/laeTune.h"
68 #include "Laelaps/laeDesc.h"
69 #include "Laelaps/laeDb.h"
70 
71 using namespace std;
72 using namespace laelaps;
73 
74 // -----------------------------------------------------------------------------
75 // Fixed Data
76 // -----------------------------------------------------------------------------
77 
78 //
79 // Dimensions.
80 //
81 
82 /*!
83  * \brief Laelaps body dimensions (W x H x L).
84  */
85 static const Dim LaeDimBody(0.250, 0.080, 0.350);
86 
87 /*!
88  * \brief Front bumper dimensions (W x H x L).
89  */
90 static const Dim LaeDimFrontBumper(0.025, 0.038, 0.190);
91 
92 /*!
93  * \brief Center of wheel shaft offset from body (dW x dH x dL).
94  */
95 static const Dim LaeDimWheelShaftOffset(0.005, -0.015, -0.015);
96 
97 
98 // -----------------------------------------------------------------------------
99 // Class LaeDescBase
100 // -----------------------------------------------------------------------------
101 
102 LaeDescBase::LaeDescBase() :
103  m_strKey(LaeDesc::KeyRobotBase),
104  m_dimBody(LaeDimBody)
105 {
107 
110 }
111 
113 {
114 }
115 
117 {
118  m_strKey = rhs.m_strKey;
119  m_dimRobot = rhs.m_dimRobot;
120  m_dimBody = rhs.m_dimBody;
125 
126  return *this;
127 }
128 
130 {
131  m_strKey.clear();
132  m_dimRobot.clear();
133  m_dimBody.clear();
134  m_fWheelbase = 0.0;
135  m_fWheeltrack = 0.0;
136  m_nNumMotorCtlrs = 0;
137  m_nNumMotors = 0;
138 }
139 
140 void LaeDescBase::calcDimensions(double fTireRadius, double fTireWidth)
141 {
142  //
143  // Robot outer dimensions.
144  //
147  2.0 * fTireWidth;
148 
151  fTireRadius;
152 
155 
156  //
157  // Wheelbase is measured from the centers of rotation of the front and rear
158  // axes.
159  //
162 
163  //
164  // Wheeltrack is measured from the centers of width between the left and right
165  // tires.
166  //
169  fTireWidth;
170 }
171 
172 void LaeDescBase::print(int indent)
173 {
174  printf("%*sPlatform Description =\n", indent, "");
175  printf("%*s{\n", indent, "");
176 
177  printf("%*sKey = %s\n", indent+2, "", m_strKey.c_str());
178 
179  printf("%*sOuter Dimensions =\n", indent+2, "");
180  printf("%*s{\n", indent+2, "");
181  printf("%*sWidth = %.3lf\n", indent+4, "", m_dimRobot.m_width);
182  printf("%*sHeight = %.3lf\n", indent+4, "", m_dimRobot.m_height);
183  printf("%*sLength = %.3lf\n", indent+4, "", m_dimRobot.m_length);
184  printf("%*s}\n", indent+2, "");
185 
186  printf("%*sBody Dimensions =\n", indent+2, "");
187  printf("%*s{\n", indent+2, "");
188  printf("%*sWidth = %.3lf\n", indent+4, "", m_dimBody.m_width);
189  printf("%*sHeight = %.3lf\n", indent+4, "", m_dimBody.m_height);
190  printf("%*sLength = %.3lf\n", indent+4, "", m_dimBody.m_length);
191  printf("%*s}\n", indent+2, "");
192 
193  printf("%*sWheelbase = %.3lf\n", indent+2, "", m_fWheelbase);
194  printf("%*sWheeltrack = %.3lf\n", indent+2, "", m_fWheeltrack);
195  printf("%*sNumber of Motors Ctlrs = %d\n", indent+2, "", m_nNumMotorCtlrs);
196  printf("%*sNumber of Motors = %d\n", indent+2, "", m_nNumMotors);
197 
198  printf("%*s}\n", indent, "");
199 }
200 
201 
202 // -----------------------------------------------------------------------------
203 // Class LaeDescPowertrain
204 // -----------------------------------------------------------------------------
205 
207 {
208  clear();
209 }
210 
211 LaeDescPowertrain::LaeDescPowertrain(const string &strKey)
212 {
213  m_eJointType = LaeJointTypeContinuous;
214  m_eEncType = LaeEncTypeQuadrature;
215  m_fGearRatio = LaeMotorGearRatio;
216  m_nDir = LaeMotorDirNormal;
217 
218  if( strKey == LaeKeyLeftFront )
219  {
220  m_nMotorId = LaeMotorIdLF;
221  m_nMotorCtlrId = LaeMotorCtlrIdFront;
222  m_nMotorIndex = LaeMotorLeft;
223  }
224  else if( strKey == LaeKeyRightFront )
225  {
226  m_nMotorId = LaeMotorIdRF;
227  m_nMotorCtlrId = LaeMotorCtlrIdFront;
228  m_nMotorIndex = LaeMotorRight;
229  }
230  else if( strKey == LaeKeyLeftRear )
231  {
232  m_nMotorId = LaeMotorIdLR;
233  m_nMotorCtlrId = LaeMotorCtlrIdRear;
234  m_nMotorIndex = LaeMotorLeft;
235  }
236  else if( strKey == LaeKeyRightRear )
237  {
238  m_nMotorId = LaeMotorIdRR;
239  m_nMotorCtlrId = LaeMotorCtlrIdRear;
240  m_nMotorIndex = LaeMotorRight;
241  }
242  else
243  {
244  LOGWARN("Powertrain %s: Unknown.", strKey.c_str());
245  clear();
246  }
247 
248  m_strKey = strKey;
249 }
250 
252 {
253 }
254 
256 {
257  m_strKey = rhs.m_strKey;
258  m_nMotorId = rhs.m_nMotorId;
259  m_nMotorCtlrId = rhs.m_nMotorCtlrId;
260  m_nMotorIndex = rhs.m_nMotorIndex;
261  m_eJointType = rhs.m_eJointType;
262  m_eEncType = rhs.m_eEncType;
263  m_fGearRatio = rhs.m_fGearRatio;
264  m_nDir = rhs.m_nDir;
265 
266  return *this;
267 }
268 
270 {
271  m_strKey.clear();
272  m_nMotorId = LaeMotorIdNone;
273  m_nMotorCtlrId = LaeMotorCtlrIdNone;
274  m_nMotorIndex = LaeMotorLeft;
275  m_eJointType = LaeJointTypeContinuous;
276  m_eEncType = LaeEncTypeUnknown;
277  m_fGearRatio = 1.0;
278  m_nDir = LaeMotorDirNormal;
279 }
280 
281 void LaeDescPowertrain::print(int indent)
282 {
283  printf("%*sPowertrain[%s] Description =\n", indent, "", m_strKey.c_str());
284  printf("%*s{\n", indent, "");
285  printf("%*sKey = %s\n", indent+2, "", m_strKey.c_str());
286  printf("%*sMotor Id = %d\n", indent+2, "", m_nMotorId);
287  printf("%*sMotor Ctlr Id = %d\n", indent+2, "", m_nMotorCtlrId);
288  printf("%*sMotor Index = %d\n", indent+2, "", m_nMotorIndex);
289  printf("%*sJoint Type = %d\n", indent+2, "", m_eJointType);
290  printf("%*sEncoder Type = 0x%02x\n", indent+2, "", m_eEncType);
291  printf("%*sDirection = %d\n", indent+2, "", m_nDir);
292  printf("%*s}\n", indent, "");
293 }
294 
295 
296 // -----------------------------------------------------------------------------
297 // Class LaeDescBattery
298 // -----------------------------------------------------------------------------
299 
301  m_strKey(LaeDesc::KeyBattery),
302  m_strType(LaeTuneBattType),
303  m_strChemistry(LaeTuneBattChem)
304 {
310 }
311 
313 {
314 }
315 
317 {
318  m_strKey = rhs.m_strKey;
319  m_strType = rhs.m_strType;
321  m_nNumCells = rhs.m_nNumCells;
322  m_fCapacity = rhs.m_fCapacity;
323  m_fMaxV = rhs.m_fMaxV;
324  m_fMinV = rhs.m_fMinV;
325  m_fNomV = rhs.m_fNomV;
326 
327  return *this;
328 }
329 
331 {
332  m_strKey.clear();
333  m_strType.clear();
334  m_strChemistry.clear();
335  m_nNumCells = 0;
336  m_fCapacity = 0.0;
337  m_fMaxV = 0.0;
338  m_fMinV = 0.0;
339  m_fNomV = 0.0;
340 }
341 
342 void LaeDescBattery::print(int indent)
343 {
344  printf("%*sBattery Description =\n", indent, "");
345  printf("%*s{\n", indent, "");
346  printf("%*sKey = %s\n", indent+2, "", m_strKey.c_str());
347  printf("%*sType = %s\n", indent+2, "", m_strType.c_str());
348  printf("%*sChemistry = %s\n", indent+2, "", m_strChemistry.c_str());
349  printf("%*sCapacity Ah = %.2lf\n", indent+2, "", m_fCapacity);
350  printf("%*sCells = %d\n", indent+2, "", m_nNumCells);
351  printf("%*sMax V = %.2lf\n", indent+2, "", m_fMaxV);
352  printf("%*sNominal V = %.2lf\n", indent+2, "", m_fNomV);
353  printf("%*sMin V = %.2lf\n", indent+2, "", m_fMinV);
354  printf("%*s}\n", indent, "");
355 }
356 
357 
358 // -----------------------------------------------------------------------------
359 // Class LaeDescRangeSensor
360 // -----------------------------------------------------------------------------
361 
363 {
364  clear();
365 }
366 
367 LaeDescRangeSensor::LaeDescRangeSensor(const string &strKey)
368 {
369  if( strKey == "front" )
370  {
371  m_nChan = ToFSensor0Chan;
372  m_fDir = ToFSensor0Dir;
373  m_fDeadzone = ToFSensor0Deadzone;
374  }
375  else if( strKey == "left_front" )
376  {
377  m_nChan = ToFSensor1Chan;
378  m_fDir = ToFSensor1Dir;
379  m_fDeadzone = ToFSensor1Deadzone;
380  }
381  else if( strKey == "left" )
382  {
383  m_nChan = ToFSensor2Chan;
384  m_fDir = ToFSensor2Dir;
385  m_fDeadzone = ToFSensor2Deadzone;
386  }
387  else if( strKey == "left_rear" )
388  {
389  m_nChan = ToFSensor3Chan;
390  m_fDir = ToFSensor3Dir;
391  m_fDeadzone = ToFSensor3Deadzone;
392  }
393  else if( strKey == "rear" )
394  {
395  m_nChan = ToFSensor4Chan;
396  m_fDir = ToFSensor4Dir;
397  m_fDeadzone = ToFSensor4Deadzone;
398  }
399  else if( strKey == "right_rear" )
400  {
401  m_nChan = ToFSensor5Chan;
402  m_fDir = ToFSensor5Dir;
403  m_fDeadzone = ToFSensor5Deadzone;
404  }
405  else if( strKey == "right" )
406  {
407  m_nChan = ToFSensor6Chan;
408  m_fDir = ToFSensor6Dir;
409  m_fDeadzone = ToFSensor6Deadzone;
410  }
411  else if( strKey == "right_front" )
412  {
413  m_nChan = ToFSensor7Chan;
414  m_fDir = ToFSensor7Dir;
415  m_fDeadzone = ToFSensor7Deadzone;
416  }
417  else
418  {
419  LOGWARN("Range Sensor %s: Unknown.", strKey.c_str());
420  clear();
421  }
422 
423  makeDesc();
424 
425  m_strKey = strKey;
426 }
427 
429 {
430 }
431 
433 {
434  m_strKey = rhs.m_strKey;
435  m_nChan = rhs.m_nChan;
436  m_fDir = rhs.m_fDir;
437  m_fDeadzone = rhs.m_fDeadzone;
438 
439  return *this;
440 }
441 
443 {
444  m_strKey.clear();
445  m_nChan = -1;
446  m_fDir = 0.0;
447  m_fDeadzone = 0.0;
448 }
449 
451 {
452  printf("%*sRange Sensor[%s] Description =\n", indent, "", m_strKey.c_str());
453  printf("%*s{\n", indent, "");
454  printf("%*sKey = %s\n", indent+2, "", m_strKey.c_str());
455  printf("%*sChannel Number = %d\n", indent+2, "", m_nChan);
456  printf("%*sDirection = %.1lf\n", indent+2, "", radToDeg(m_fDir));
457  printf("%*sDeadZone = %.3lf\n", indent+2, "", m_fDeadzone);
458  printf("%*s}\n", indent, "");
459 }
460 
462 {
463  stringstream ss;
464 
465  if( m_nChan == -1 )
466  {
467  m_strDesc = "Unknown sensor";
468  return;
469  }
470 
471  ss << "Range sensor at "
472  << m_strKey << " "
473  << radToDeg(m_fDir) << " degrees";
474 
475  m_strDesc = ss.str();
476 }
477 
478 
479 // -----------------------------------------------------------------------------
480 // Class LaeDescImu
481 // -----------------------------------------------------------------------------
482 
484  m_strKey(LaeDesc::KeyImu),
485  m_strHw("Naze32"),
486  m_strFw("CleanFlight")
487 {
488 }
489 
491 {
492 }
493 
495 {
496  m_strKey = rhs.m_strKey;
497  m_strHw = rhs.m_strHw;
498  m_strFw = rhs.m_strFw;
499 
500  return *this;
501 }
502 
504 {
505  m_strKey.clear();
506  m_strHw.clear();
507  m_strFw.clear();
508 }
509 
510 void LaeDescImu::print(int indent)
511 {
512  printf("%*sIMU Description =\n", indent, "");
513  printf("%*s{\n", indent, "");
514  printf("%*sKey = %s\n", indent+2, "", m_strKey.c_str());
515  printf("%*sHardware = %s\n", indent+2, "", m_strHw.c_str());
516  printf("%*sFirmware = %s\n", indent+2, "", m_strFw.c_str());
517  printf("%*s}\n", indent, "");
518 }
519 
520 
521 // -----------------------------------------------------------------------------
522 // Class LaeDescOptions
523 // -----------------------------------------------------------------------------
524 
525 const char* const LaeDescOptions::PkgOptStd = "standard";
526 const char* const LaeDescOptions::PkgOptDeluxe = "deluxe";
527 
529  m_strPkgToF(LaeDescOptions::PkgOptStd),
530  m_strPkgFCam(LaeDescOptions::PkgOptStd)
531 {
532 }
533 
535 {
536 }
537 
539 {
540  m_strPkgToF = rhs.m_strPkgToF;
542 
543  return *this;
544 }
545 
547 {
548  m_strPkgToF.clear();
549  m_strPkgFCam.clear();
550 }
551 
552 void LaeDescOptions::print(int indent)
553 {
554  printf("%*sPackage Options =\n", indent, "");
555  printf("%*s{\n", indent, "");
556  printf("%*sTime-of-Flight Package = %s\n", indent+2, "", m_strPkgToF.c_str());
557  printf("%*sFront Camera Package = %s\n", indent+2, "",m_strPkgFCam.c_str());
558  printf("%*s}\n", indent, "");
559 }
560 
561 
562 // -----------------------------------------------------------------------------
563 // Class LaeDesc
564 // -----------------------------------------------------------------------------
565 
566 const char* const LaeDesc::KeyRobotBase = "platform";
567 
568 const char* const LaeDesc::KeyBattery = "battery";
569 
570 const char* const LaeDesc::KeyMotorCtlr[] =
571 {
573 };
574 
575 const char* const LaeDesc::KeyPowertrain[] =
576 {
579 };
580 
581 const char* const LaeDesc::KeyImu = "imu";
582 
583 const char* const LaeDesc::KeyRangeSensorMax[] =
584 {
585  "front", "left_front", "left", "left_rear",
586  "rear", "right_rear", "right", "right_front"
587 };
588 
589 const char* const LaeDesc::KeyRangeSensorStd[] =
590 {
591  "front", "left_front", "right_front"
592 };
593 
594 const char* const LaeDesc::KeyFCam = "fcam";
595 
596 std::string LaeDesc::prettyMotorCtlrName(int nCtlrId)
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 }
609 
610 std::string LaeDesc::prettyMotorCtlrName(int nCtlrId, byte_t addr)
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 }
625 
626 std::string LaeDesc::prettyMotorName(int nMotorId)
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 }
644 
645 std::string LaeDesc::prettyMotorName(int nCtlrId, byte_t addr, int nMotorId)
646 {
647  std::stringstream ss;
648 
649  ss << LaeDesc::prettyMotorCtlrName(nCtlrId, addr) << ": "
650  << LaeDesc::prettyMotorName(nMotorId);
651 
652  return ss.str();
653 }
654 
656  m_strProdFamily(LaeProdFamily)
657 {
658  m_bIsDescribed = false;
660  m_uProdHwVer = 0;
661 
662  m_pDescBase = NULL;
663  m_pDescBattery = NULL;
664  m_pDescImu = NULL;
665 }
666 
668 {
669  clear();
670 }
671 
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 }
747 
749 {
750  m_bIsDescribed = false;
752  m_strProdModel.clear();
753  m_strProdName.clear();
754  m_strProdBrief.clear();
755  m_strProdHwVer.clear();
756  m_uProdHwVer = 0;
757 
758  m_options.clear();
759 
760  if( m_pDescBase != NULL )
761  {
762  delete m_pDescBase;
763  m_pDescBase = NULL;
764  }
765 
766  if( m_pDescBattery != NULL )
767  {
768  delete m_pDescBattery;
769  m_pDescBattery = NULL;
770  }
771 
772  for(MapDescPowertrain::iterator iter = m_mapDescPowertrain.begin();
773  iter != m_mapDescPowertrain.end();
774  ++iter)
775  {
776  delete iter->second;
777  }
778  m_mapDescPowertrain.clear();
779 
780  for(MapDescRangeSensor::iterator iter = m_mapDescRangeSensor.begin();
781  iter != m_mapDescRangeSensor.end();
782  ++iter)
783  {
784  delete iter->second;
785  }
786  m_mapDescRangeSensor.clear();
787 
788  if( m_pDescImu != NULL )
789  {
790  delete m_pDescImu;
791  m_pDescImu = NULL;
792  }
793 }
794 
795 const char *LaeDesc::getProdName(int eProdId)
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 }
807 
808 const char *LaeDesc::getProdBrief(int eProdId)
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 }
820 
821 void LaeDesc::print(int indent)
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 }
865 
867 {
869 }
static const int LaeMotorIdRR
right rear
Definition: laeMotor.h:106
const double ToFSensor6Deadzone
sensor 6 8mm deadzone
Definition: laeSysDev.h:280
LaeDescBattery operator=(const LaeDescBattery &rhs)
Assignment operator.
Definition: laeDesc.cxx:316
const char *const LaeTuneBattType
Fixed battery type.
Definition: laeTune.h:218
double m_fWheelbase
wheelbase(m)
Definition: laeDesc.h:119
const double ToFSensor6Dir
sensor 6 direction
Definition: laeSysDev.h:268
int m_eProdId
base product id
Definition: laeDb.h:79
const double ToFSensor4Deadzone
sensor 4 8mm deadzone
Definition: laeSysDev.h:278
LaeDescPowertrain operator=(const LaeDescPowertrain &rhs)
Assignment operator.
Definition: laeDesc.cxx:255
virtual ~LaeDescOptions()
Destructor.
Definition: laeDesc.cxx:534
static const int LaeMotorCtlrIdRear
rear motor controller
Definition: laeMotor.h:114
LaeDescRangeSensor operator=(const LaeDescRangeSensor &rhs)
Assignment operator.
Definition: laeDesc.cxx:432
LaeDescOptions operator=(const LaeDescOptions &rhs)
Assignment operator.
Definition: laeDesc.cxx:538
LaeDescBase * m_pDescBase
base description
Definition: laeDesc.h:523
Laelaps robotic mobile platform full description class.
Definition: laeDesc.h:451
LaeDbProduct m_product
product data
Definition: laeDb.h:227
void clear()
Clear description.
Definition: laeDesc.cxx:442
double m_fDir
sensor direction (radians)
Definition: laeDesc.h:293
static std::string prettyMotorName(int nMotorId)
Create pretty motor/powertrain identifier string.
Definition: laeDesc.cxx:626
const double ToFSensor7Dir
sensor 7 direction
Definition: laeSysDev.h:269
static const int LaeMotorDirNormal
normal
Definition: laeMotor.h:136
uint_t strToVersion(const std::string &str)
Convert version dotted string to integer equivalent.
int m_nNumMotors
number of motors
Definition: laeDesc.h:122
LaeDescImu * m_pDescImu
built-in imu description
Definition: laeDesc.h:527
Battery description.
Definition: laeDesc.h:235
double m_fDeadzone
deadzone (meters)
Definition: laeDesc.h:294
static const int LaeProdIdStd
standard Laelaps product id
Definition: laelaps.h:144
std::string m_strProdBrief
product brief
Definition: laeDesc.h:515
static const int LaeProdIdLarge
large Laelaps product id
Definition: laelaps.h:145
uint_t m_uProdHwVer
product hardware version number
Definition: laeDb.h:80
std::string m_strChemistry
battery chemistry
Definition: laeDesc.h:240
double m_fCapacity
battery capacity(Ah)
Definition: laeDesc.h:242
std::string m_strKey
range sensor key
Definition: laeDesc.h:291
const double ToFSensor0Deadzone
sensor 0 8mm deadzone
Definition: laeSysDev.h:274
LaeDescBase operator=(const LaeDescBase &rhs)
Assignment operator.
Definition: laeDesc.cxx:116
void clear()
Clear description.
Definition: laeDesc.cxx:129
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:450
const int ToFSensorStdNumOf
max num of ToF sensors for std option
Definition: laeSysDev.h:245
const int ToFSensor7Chan
sensor 7 channel (bit) number
Definition: laeSysDev.h:257
static const int LaeMotorsNumOf
number of motors
Definition: laeMotor.h:107
const double ToFSensor4Dir
sensor 4 direction
Definition: laeSysDev.h:266
const double LaeTuneTireRadiusDft
Default tire radius (meters).
Definition: laeTune.h:319
static const int LaeMotorIdNone
no motor id
Definition: laeMotor.h:102
double m_length
object length (meters)
Definition: laeUtils.h:529
Object width x height x length dimensions class.
Definition: laeUtils.h:524
static const char *const LaeKeyLeftRear
left rear
Definition: laeMotor.h:96
static const char *const LaeKeyRightFront
right front
Definition: laeMotor.h:95
const double LaeTuneBattNominalV
Fixed nominal operating voltage.
Definition: laeTune.h:262
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:281
double m_fMinV
battery minimum low at cutoff (V)
Definition: laeDesc.h:244
void clear()
Clear description.
Definition: laeDesc.cxx:546
static const char *const LaeKeyRear
rear
Definition: laeMotor.h:93
std::string m_strKey
base name
Definition: laeDesc.h:116
const double LaeTuneBattMinVDft
Definition: laeTune.h:270
static const char *const PkgOptDeluxe
deluxe package option
Definition: laeDesc.h:402
void clear()
Clear description to the "unitialized" values.
Definition: laeDesc.cxx:748
static const char *const LaeKeyFront
front
Definition: laeMotor.h:92
LaeEncType m_eEncType
encoder type
Definition: laeDesc.h:185
const double ToFSensor5Deadzone
sensor 5 14.5mm deadzone
Definition: laeSysDev.h:279
const double ToFSensor1Deadzone
sensor 1 14.5mm deadzone
Definition: laeSysDev.h:275
std::string m_strHw
hardware
Definition: laeDesc.h:354
const int ToFSensorMaxNumOf
maximum number of ToF sensors
Definition: laeSysDev.h:244
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
const double ToFSensor0Dir
sensor 0 direction
Definition: laeSysDev.h:262
void setVersion()
Set version number from parsed version string.
Definition: laeDesc.cxx:866
std::string getProdBrief() const
Get this base description&#39;s brief.
Definition: laeDesc.h:588
static const int LaeMotorLeft
left motors
Definition: laeMotor.h:128
std::string m_strPkgToF
range time-of-flight package
Definition: laeDesc.h:404
std::string m_strFw
firmware
Definition: laeDesc.h:355
LaeDescImu()
Default constructor.
Definition: laeDesc.cxx:483
const int ToFSensor1Chan
sensor 1 channel (bit) number
Definition: laeSysDev.h:251
const int ToFSensor2Chan
sensor 2 channel (bit) number
Definition: laeSysDev.h:252
double radToDeg(double r)
Convert radians to degrees.
Definition: laeUtils.h:136
LaeDescOptions()
Default constructor.
Definition: laeDesc.cxx:528
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:342
static const int LaeProdIdUnknown
unknown/undefined product id
Definition: laelaps.h:143
const double ToFSensor2Deadzone
sensor 2 8mm deadzone
Definition: laeSysDev.h:276
LaeJointType m_eJointType
powertrain joint type
Definition: laeDesc.h:184
static const int LaeMotorIdRF
right front
Definition: laeMotor.h:104
Robotic built-in IMU description.
Definition: laeDesc.h:350
LaeDescPowertrain()
Default constructor.
Definition: laeDesc.cxx:206
static const int LaeMotorIdLR
left rear
Definition: laeMotor.h:105
int m_nNumMotorCtlrs
number of motor controllers
Definition: laeDesc.h:121
int m_nDir
normalize cw/ccw direction.
Definition: laeDesc.h:187
std::string m_strProdModel
product model
Definition: laeDesc.h:513
virtual ~LaeDescImu()
Destructor.
Definition: laeDesc.cxx:490
static const char *const LaeKeyRightRear
right rear
Definition: laeMotor.h:97
Robotic powertrain description.
Definition: laeDesc.h:177
const int ToFSensor6Chan
sensor 6 channel (bit) number
Definition: laeSysDev.h:256
virtual ~LaeDescPowertrain()
Destructor.
Definition: laeDesc.cxx:251
double m_fMaxV
battery maximum high charge (V)
Definition: laeDesc.h:243
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:552
MapDescPowertrain m_mapDescPowertrain
powertrain descriptions
Definition: laeDesc.h:525
LaeDescBattery()
Default constructor.
Definition: laeDesc.cxx:300
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
Laelaps robotic base mobile platform description class interface.
const int ToFSensor0Chan
sensor 0 channel (bit) number
Definition: laeSysDev.h:250
const double ToFSensor3Deadzone
sensor 3 14.5mm deadzone
Definition: laeSysDev.h:277
const int ToFSensor5Chan
sensor 5 channel (bit) number
Definition: laeSysDev.h:255
LaeDescBattery * m_pDescBattery
internal battery description
Definition: laeDesc.h:524
static const Dim LaeDimFrontBumper(0.025, 0.038, 0.190)
Front bumper dimensions (W x H x L).
std::string m_strProdHwVer
product hardware version string
Definition: laeDesc.h:516
void clear()
Clear description.
Definition: laeDesc.cxx:330
virtual ~LaeDescBattery()
Destructor.
Definition: laeDesc.cxx:312
Laelaps common utilities.
std::string m_strProdFamily
product family
Definition: laeDesc.h:512
uint_t m_uProdHwVer
product hardware version number
Definition: laeDesc.h:517
continuous rotation
Definition: laeDesc.h:79
void clear()
Clear description.
Definition: laeDesc.cxx:503
const double LaeTuneTireWidthDft
Default tire width (meters).
Definition: laeTune.h:327
double m_height
object height (meters)
Definition: laeUtils.h:528
int markAsDescribed()
Mark <b><i>Laelaps</i></b> hardware as fully described.
Definition: laeDesc.cxx:672
int m_nMotorId
unique robot motor id
Definition: laeDesc.h:181
int m_eProdId
base product id
Definition: laeDesc.h:511
Laelaps tuning.
Dim m_dimBody
body dimensions(m)
Definition: laeDesc.h:118
static const Dim LaeDimBody(0.250, 0.080, 0.350)
Laelaps body dimensions (W x H x L).
std::string m_strPkgFCam
front camera package
Definition: laeDesc.h:405
static const char *const KeyFCam
front camera keys
Definition: laeDesc.h:467
static const int LaeMotorIdLF
left front
Definition: laeMotor.h:103
static const int LAE_ECODE_BAD_OP
invalid operation error
Definition: laelaps.h:80
static const Dim LaeDimWheelShaftOffset(0.005,-0.015,-0.015)
Center of wheel shaft offset from body (dW x dH x dL).
const double ToFSensor2Dir
sensor 2 direction
Definition: laeSysDev.h:264
int m_nNumCells
number of cells
Definition: laeDesc.h:241
Package options class.
Definition: laeDesc.h:398
const int LaeTuneBattCells
Fixed battery cell count.
Definition: laeTune.h:244
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:510
std::string m_strType
battery type
Definition: laeDesc.h:239
double m_fGearRatio
motor gear ratio
Definition: laeDesc.h:186
virtual ~LaeDescBase()
Destructor.
Definition: laeDesc.cxx:112
static const int LaeMotorCtlrIdNone
no motor controller id
Definition: laeMotor.h:112
const char *const LaeProdFamily
product family name
Definition: laelaps.h:140
Robotic base platform description.
Definition: laeDesc.h:113
int m_nMotorCtlrId
unique motor controller id
Definition: laeDesc.h:182
virtual void makeDesc()
Make sensor description string from description.
Definition: laeDesc.cxx:461
static const double LaeMotorGearRatio
gear ratio
Definition: laeMotor.h:165
static const char *const KeyBattery
internal battery key
Definition: laeDesc.h:461
std::string m_strKey
base key
Definition: laeDesc.h:353
Dim m_dimRobot
robot full dimensions(m)
Definition: laeDesc.h:117
const double LaeTuneBattMaxVDft
Definition: laeTune.h:257
const double ToFSensor7Deadzone
sensor 7 14.5mm deadzone
Definition: laeSysDev.h:281
std::string m_strKey
powertrain key
Definition: laeDesc.h:180
static const int LaeNumMotorCtlrs
number of motor controllers
Definition: laeMotor.h:115
static const char *const KeyImu
built-in IMU keys
Definition: laeDesc.h:464
static const char *const KeyPowertrain[]
powertrain keys
Definition: laeDesc.h:463
virtual ~LaeDesc()
Definition: laeDesc.cxx:667
virtual ~LaeDescRangeSensor()
Destructor.
Definition: laeDesc.cxx:428
static const char *const KeyMotorCtlr[]
motor controller keys
Definition: laeDesc.h:462
const double ToFSensor1Dir
sensor 1 direction
Definition: laeSysDev.h:263
#define LAE_VERSION(major, minor, revision)
Convert version triplet to integer equivalent.
Definition: laelaps.h:158
static const char *const PkgOptStd
standard package option
Definition: laeDesc.h:401
static const char *const KeyRangeSensorStd[]
std range sensor keys
Definition: laeDesc.h:466
static std::string prettyMotorCtlrName(int nCtlrId)
Create pretty motor controller identifier string.
Definition: laeDesc.cxx:596
const double ToFSensor5Dir
sensor 5 direction
Definition: laeSysDev.h:267
unknown/undefined encoder type
Definition: laeDesc.h:92
int m_nChan
channel number
Definition: laeDesc.h:292
static const int LaeMotorCtlrIdFront
front motor controller
Definition: laeMotor.h:113
bool m_bIsDescribed
<b><i>Laelaps</i></b> is [not] fully described
Definition: laeDesc.h:510
static const int LaeMotorRight
right motors
Definition: laeMotor.h:129
double m_fWheeltrack
wheeltrack(m)
Definition: laeDesc.h:120
const char *const LaeTuneBattChem
Fixed battery chemistry.
Definition: laeTune.h:228
Range sensor description.
Definition: laeDesc.h:288
static const char *const KeyRangeSensorMax[]
max range sensor keys
Definition: laeDesc.h:465
void clear()
Clear description.
Definition: laeDesc.cxx:269
int m_nMotorIndex
motor controller unique motor index
Definition: laeDesc.h:183
std::string getProdName() const
Get this base description&#39;s name.
Definition: laeDesc.h:578
LaeDescImu operator=(const LaeDescImu &rhs)
Assignment operator.
Definition: laeDesc.cxx:494
const int ToFSensor3Chan
sensor 3 channel (bit) number
Definition: laeSysDev.h:253
void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:821
std::string m_strKey
battery key
Definition: laeDesc.h:238
const double LaeTuneBattCapAh
Fixed battery capacity (Amp-hours).
Definition: laeTune.h:236
static const char *const KeyRobotBase
robot base key
Definition: laeDesc.h:460
Laelaps real-time "database".
double m_fNomV
battery nominal voltage (V)
Definition: laeDesc.h:245
quadrature encoder
Definition: laeDesc.h:98
const int ToFSensor4Chan
sensor 4 channel (bit) number
Definition: laeSysDev.h:254
double m_width
object width (meters)
Definition: laeUtils.h:527
LaeDescRangeSensor()
Default constructor.
Definition: laeDesc.cxx:362
static const char *const LaeKeyLeftFront
left front
Definition: laeMotor.h:94
virtual void print(int indent=0)
Print out description to stdout.
Definition: laeDesc.cxx:172
void calcDimensions(double fTireRadius, double fTireWidth)
Calculate robot dimensions.
Definition: laeDesc.cxx:140
Top-level package include file.
std::string m_strProdName
product name
Definition: laeDesc.h:514
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
MapDescRangeSensor m_mapDescRangeSensor
range sensor descriptions
Definition: laeDesc.h:526
const double ToFSensor3Dir
sensor 3 direction
Definition: laeSysDev.h:265