Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeRobot.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // Library: liblaelaps
6 //
7 // File: laeRobot.cxx
8 //
9 /*! \file
10  *
11  * \brief Laelaps Robot Class implementation.
12  *
13  * \author Robin Knight (robin.knight@roadnarrows.com)
14  *
15  * \par Copyright
16  * \h_copy 2015-2017. RoadNarrows LLC.\n
17  * http://www.roadnarrows.com\n
18  * All Rights Reserved
19  */
20 /*
21  * @EulaBegin@
22  *
23  * Unless otherwise stated explicitly, all materials contained are copyrighted
24  * and may not be used without RoadNarrows LLC's written consent,
25  * except as provided in these terms and conditions or in the copyright
26  * notice (documents and software) or other proprietary notice provided with
27  * the relevant materials.
28  *
29  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
30  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
31  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
32  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
33  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
34  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
37  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
38  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
39  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
40  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
41  *
42  * @EulaEnd@
43  */
44 ////////////////////////////////////////////////////////////////////////////////
45 
46 #include <stdio.h>
47 #include <unistd.h>
48 #include <pthread.h>
49 #include <math.h>
50 
51 #include <string>
52 #include <utility>
53 #include <vector>
54 #include <map>
55 
56 #include "rnr/rnrconfig.h"
57 #include "rnr/units.h"
58 #include "rnr/i2c.h"
59 #include "rnr/log.h"
60 
61 // common
62 #include "Laelaps/laelaps.h"
63 #include "Laelaps/laeUtils.h"
64 
65 // hardware
66 #include "Laelaps/laeSysDev.h"
67 #include "Laelaps/RoboClaw.h"
68 #include "Laelaps/laeMotor.h"
69 #include "Laelaps/laeI2C.h"
70 #include "Laelaps/laeI2CMux.h"
71 #include "Laelaps/laeWatchDog.h"
72 #include "Laelaps/laeWd.h"
73 #include "Laelaps/laeVL6180.h"
74 #include "Laelaps/laeImu.h"
75 #include "Laelaps/laeCams.h"
76 
77 // descriptions, tuning, and database
78 #include "Laelaps/laeTune.h"
79 #include "Laelaps/laeDesc.h"
80 #include "Laelaps/laeXmlTune.h"
81 #include "Laelaps/laeDb.h"
82 
83 // control and application interface
84 #include "Laelaps/laeTraj.h"
85 #include "Laelaps/laePowertrain.h"
86 #include "Laelaps/laePlatform.h"
87 #include "Laelaps/laeKin.h"
88 #include "Laelaps/laeAlarms.h"
89 #include "Laelaps/laeReports.h"
90 #include "Laelaps/laeThreadAsync.h"
91 #include "Laelaps/laeThreadImu.h"
92 #include "Laelaps/laeThreadKin.h"
93 #include "Laelaps/laeThreadRange.h"
94 #include "Laelaps/laeThreadWd.h"
95 
96 // the robot
97 #include "Laelaps/laeRobot.h"
98 
99 using namespace std;
100 using namespace laelaps;
101 using namespace motor::roboclaw;
102 using namespace sensor::vl6180;
103 using namespace sensor::imu;
104 
105 /*!
106  * \brief Test for no execute flag.
107  *
108  * Only works in LaeRobot methods.
109  *
110  * \return On true, return with LAE_OK.
111  */
112 #define LAE_TRY_NO_EXEC() \
113  do \
114  { \
115  if( m_bNoExec ) \
116  { \
117  return LAE_OK; \
118  } \
119  } while(0)
120 
121 /*!
122  * \brief Test for connection.
123  *
124  * Only works in LaeRobot methods.
125  *
126  * \return On failure, forces return from calling function with the appropriate
127  * error code.
128  */
129 #define LAE_TRY_CONN() \
130  do \
131  { \
132  if( !isConnected() ) \
133  { \
134  LOGERROR("Robot is not connected."); \
135  return -LAE_ECODE_NO_EXEC; \
136  } \
137  } while(0)
138 
139 /*!
140  * \brief Test for not estop.
141  *
142  * Only works in LaeRobot methods.
143  *
144  * \return On failure, forces return from calling function with the appropriate
145  * error code.
146  */
147 #define LAE_TRY_NOT_ESTOP() \
148  do \
149  { \
150  if( m_bIsEStopped ) \
151  { \
152  LOGERROR("Robot is emergency stopped."); \
153  return -LAE_ECODE_NO_EXEC; \
154  } \
155  } while(0)
156 
157 
158 // -----------------------------------------------------------------------------
159 // Class LaeRobot
160 // -----------------------------------------------------------------------------
161 
162 const double LaeRobot::GovernorDft = 1.0;
163 
164 LaeRobot::LaeRobot(bool bNoExec) :
165  m_i2cBus(), m_watchdog(m_i2cBus), m_range(m_i2cBus),
166  m_threadImu(m_imu),
167  m_threadKin(m_kin),
168  m_threadRange(m_range),
169  m_threadWatchDog(m_watchdog)
170 {
171  int nCtlr;
172 
173  // state
174  m_bNoExec = bNoExec;
175  m_bIsConnected = false;
177  m_bIsEStopped = false;
178  m_bAlarmState = false;
179 
181 
182  syncDb();
183 
184  // asynchronous job
185  m_pAsyncJob = NULL;
186 }
187 
189 {
190  disconnect();
191 }
192 
194 {
195  int rc; // return code
196 
197  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
198  // Pre-connect requirements.
199  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
200 
201  //
202  // Been here, did this.
203  //
204  if( m_bIsConnected )
205  {
206  LOGWARN("Laelaps already connected to hardware.");
207  return LAE_OK;
208  }
209 
210  //
211  // Need a robot description before preceeding. The controlling application,
212  // typically a ROS node, provides the description. The desription is normally
213  // the parsed data found in /etc/laelaps/laelaps.conf XML file.
214  //
215  if( !m_descLaelaps.isDescribed() )
216  {
217  LOGERROR("Undefined Laelaps description - "
218  "don't know how to initialized properly.");
219  return -LAE_ECODE_BAD_OP;
220  }
221 
222  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
223  // Initialize robot status.
224  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
225  m_bIsConnected = false;
227  m_bIsEStopped = false;
228  m_bAlarmState = false;
229 
230  syncDb();
231 
232  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
233  // Parse and set tuning parameters.
234  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
235 
236  //
237  // Override any default tuning parameters from the optional, user-specified
238  // tuning XML file.
239  //
240  LaeXmlTune xml;
241 
242  // parse tune XML file and set tuning parameter overrides
244 
245  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
246  // Establish hardware connections.
247  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
248 
249  //
250  // Laelaps peripherals I2C bus.
251  //
252  if( (rc = i2cTryOpen(m_i2cBus, LaeI2CAddrWd)) < 0 )
253  {
254  LOGSYSERROR("Failed to opend I2C bus.");
255  }
256 
257  //
258  // Connect to all standard built-in sensors.
259  //
260  if( rc == LAE_OK )
261  {
262  rc = connSensors();
263  }
264 
265  //
266  // Connect to the external watchdog arduino subprocessor.
267  // Note: The watchdog connection must preceed connection to the motor
268  // controllers.
269  //
270  if( rc == LAE_OK )
271  {
272  rc = connWatchDog();
273  }
274 
275  //
276  // Connect to motor controllers.
277  //
278  if( rc == LAE_OK )
279  {
281  }
282 
283  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
284  // Initialize and Configure
285  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
286 
287  //
288  // Configure hardware for operation.
289  //
290  if( rc == LAE_OK )
291  {
292  rc = configForOperation();
293  }
294 
295  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
296  // Start real-time, persistent threads.
297  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
298 
299  if( rc == LAE_OK )
300  {
301  rc = startCoreThreads();
302  }
303 
304  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
305  // Finale
306  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
307 
308  // failure
309  if( rc != LAE_OK )
310  {
311  LOGERROR("Failed to connect and/or initialize hardware.");
312  disconnect();
313  }
314 
315  // success
316  else
317  {
318  m_bIsConnected = true;
320  m_bIsEStopped = false;
321  m_bAlarmState = false;
322 
323  syncDb();
324 
325  freeze(); // place robot in a safe state
326 
327  LOGDIAG1("Connected to Laelaps.");
328  }
329 
330  return rc;
331 }
332 
334 {
335  int nCtlr;
336 
337  if( !isConnected() )
338  {
339  return LAE_OK;
340  }
341 
342  //
343  // Terminate all threads.
344  //
345  cancelAsyncJob();
346 
351 
352  m_kin.close(); // close motors
353  m_imu.close(); // on usb device
354  m_i2cBus.close(); // sensors/watchdog on i2c device
355 
358 
359  // reset robot state
360  m_bIsConnected = false;
362  m_bIsEStopped = false;
363  m_bAlarmState = false;
364 
365  syncDb();
366 
367  LOGDIAG1("Disconnected from Laelaps.");
368 
369  return LAE_OK;
370 }
371 
373 {
374  LaeXmlTune xml; // xml parser
375  int rc; // return code
376 
377  // reload tune XML file and set tuning parameter overrides
379 
380  // re-tune Kinodynamics thread and hardware i/f
381  if( (rc = m_threadKin.reload(m_tunes)) != LAE_OK )
382  {
383  LOGERROR("Failed to reload kinodynamics tune parameters.");
384  return rc;
385  }
386 
387  // re-tune IMU thread and hardware i/f
388  else if( (rc = m_threadImu.reload(m_tunes)) != LAE_OK )
389  {
390  LOGERROR("Failed to reload IMU tune parameters.");
391  return rc;
392  }
393 
394  // re-tune Range thread and hardware i/f
395  else if( (rc = m_threadRange.reload(m_tunes)) != LAE_OK )
396  {
397  LOGERROR("Failed to reload range sensing tune parameters.");
398  return rc;
399  }
400 
401  // re-tune WatchDog thread and hardware i/f
402  else if( (rc = m_threadWatchDog.reload(m_tunes)) != LAE_OK )
403  {
404  LOGERROR("Failed to reload WatchDog tune parameters.");
405  return rc;
406  }
407 
408  if( rc == LAE_OK )
409  {
410  LOGDIAG2("Reloaded tuning parameters and reconfigured robot.");
411  }
412 
413  return rc;
414 }
415 
416 
417 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
418 // Action Methods.
419 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
420 
422 {
423  int rc; // return code
424 
425  LAE_TRY_NO_EXEC();
426  LAE_TRY_CONN();
427 
428  m_kin.estop();
429 
430  if( !m_kin.isEnabled() )
431  {
432  m_bIsEStopped = true;
433  m_bAlarmState = true;
434 
435  syncDb();
436 
437  rc = LAE_OK;
438 
439  LOGDIAG3("Laelaps emergency stopped.");
440  }
441  else
442  {
443  rc = -LAE_ECODE_MOT_CTLR;
444 
445  LOGERROR("Failed to emergency stop.");
446  }
447 
448  return rc;
449 }
450 
452 {
453  int rc; // return code
454 
455  LAE_TRY_NO_EXEC();
456  LAE_TRY_CONN();
457 
458  m_kin.resetEStop();
459 
460  if( m_kin.isEnabled() )
461  {
462  m_bIsEStopped = false;
463  m_bAlarmState = false;
464 
465  syncDb();
466 
467  rc = LAE_OK;
468 
469  LOGDIAG3("Laelaps emergency stopped reset.");
470  }
471  else
472  {
473  rc = -LAE_ECODE_MOT_CTLR;
474 
475  LOGERROR("Failed to reset emergency stopped condition.");
476  }
477 
478  return rc;
479 }
480 
482 {
483  return freeze();
484 }
485 
487 {
488  int rc;
489 
490  LAE_TRY_NO_EXEC();
491  LAE_TRY_CONN();
492 
493  if( (rc = m_kin.stop()) == LAE_OK )
494  {
495  LOGDIAG3("Laelaps frozen at current position.");
496  }
497 
498  return rc;
499 }
500 
502 {
503  int rc;
504 
505  LAE_TRY_NO_EXEC();
506  LAE_TRY_CONN();
507 
508  // release motor drives
509  if( (rc = m_kin.release()) == LAE_OK )
510  {
511  LOGDIAG3("Laelaps motor drives released.");
512  }
513 
514  return rc;
515 }
516 
517 int LaeRobot::move(const LaeMapVelocity &velocity)
518 {
519  int rc;
520 
521  LAE_TRY_CONN();
522 
523  rc = m_kin.setGoalVelocities(velocity);
524 
525  return rc;
526 }
527 
528 int LaeRobot::move(double fVelLinear, double fVelAngular)
529 {
530  LAE_TRY_CONN();
531 
532  return m_kin.setGoalTwist(fVelLinear, fVelAngular);
533 
534 }
535 
537 {
538  int rc;
539 
540  LAE_TRY_CONN();
541 
542  rc = m_kin.setGoalDutyCycles(duty);
543 
544  return rc;
545 }
546 
547 double LaeRobot::setGovernor(double fGovernor)
548 {
549  m_fGovernor = fcap(fGovernor, 0.0, 1.0);
550 
551  return m_fGovernor;
552 }
553 
554 double LaeRobot::incrementGovernor(double fDelta)
555 {
556  return setGovernor(m_fGovernor+fDelta);
557 }
558 
560 {
561  return m_fGovernor;
562 }
563 
565 {
566  m_eRobotMode = eRobotMode;
568 }
569 
570 int LaeRobot::setAuxPower(const string &strName, LaeTriState eState)
571 {
572  bool bGoal, bResult;
573  int rc = LAE_OK;
574 
575  LAE_TRY_CONN();
576 
577  bGoal = eState == LaeTriStateEnabled? true: false;
578 
579  if( strName == "aux_batt_en" )
580  {
581  rc = m_watchdog.cmdEnableAuxPortBatt(bGoal);
582  //bResult = bGoal? m_powerBatt.enable(): m_powerBatt.disable();
583  }
584  else if( strName == "aux_5v_en" )
585  {
586  rc = m_watchdog.cmdEnableAuxPort5V(bGoal);
587  //bResult = bGoal? m_power5V.enable(): m_power5V.disable();
588  }
589  else
590  {
591  LOGERROR("%s: Unknown auxilliary port name.", strName.c_str());
592  rc = -LAE_ECODE_BAD_VAL;
593  }
594 
595  return rc;
596 }
597 
599 {
600  LAE_TRY_CONN();
601 
602  return LAE_OK;
603 }
604 
606 {
607  rptBotStatus.clear();
608 
609  rptBotStatus.generate(this);
610 
611  return LAE_OK;
612 }
613 
614 int LaeRobot::configDigitalPin(uint_t pin, uint_t dir)
615 {
616  return m_watchdog.cmdConfigDPin(pin, dir);
617 }
618 
619 int LaeRobot::readDigitalPin(uint_t pin, uint_t &val)
620 {
621  return m_watchdog.cmdReadDPin(pin, val);
622 }
623 
624 int LaeRobot::writeDigitalPin(uint_t pin, uint_t val)
625 {
626  return m_watchdog.cmdWriteDPin(pin, val);
627 }
628 
629 int LaeRobot::readAnalogPin(uint_t pin, uint_t &val)
630 {
631  return m_watchdog.cmdReadAPin(pin, val);
632 }
633 
634 int LaeRobot::getImu(double accel[], double gyro[], double rpy[], Quaternion &q)
635 {
636  double mag[NumOfAxes]; // no magnetometer
637 
638  m_imu.getImuData(accel, gyro, mag, rpy, q);
639 
640  return LAE_OK;
641 }
642 
643 int LaeRobot::getRangeSensorProps(const string &strKey,
644  string &strRadiationType,
645  double &fFoV,
646  double &fBeamDir,
647  double &fMin,
648  double &fMax)
649 {
650  return m_range.getSensorProps(strKey,
651  strRadiationType,
652  fFoV, fBeamDir,
653  fMin, fMax);
654 }
655 
656 int LaeRobot::getRange(const string &strKey, double &fRange)
657 {
658  return m_range.getRange(strKey, fRange);
659 }
660 
661 int LaeRobot::getRange(vector<string> &vecNames, vector<double> &vecRanges)
662 {
663  return m_range.getRange(vecNames, vecRanges);
664 }
665 
666 int LaeRobot::getAmbientLight(const string &strKey, double &fAmbient)
667 {
668  return m_range.getAmbientLight(strKey, fAmbient);
669 }
670 
671 int LaeRobot::getAmbientLight(vector<string> &vecNames,
672  vector<double> &vecAmbient)
673 {
674  return m_range.getAmbientLight(vecNames, vecAmbient);
675 }
676 
677 
678 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
679 // Reports
680 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
681 
683 {
684  LAE_TRY_CONN();
685 
686  rptDynamics.clear();
687 
688  rptDynamics.generate(this);
689 
690  return LAE_OK;
691 }
692 
694 {
695  // TBD
696 
697  pathFeedback.clear();
698 
699  return LAE_OK;
700 }
701 
703 {
704  // TBD
705 
706  pathFeedback.clear();
707 
708  return LAE_OK;
709 }
710 
711 LaePowertrain *LaeRobot::getPowertrain(const string &strName)
712 {
713  return m_kin.getPowertrain(strName);
714 }
715 
717 {
718  return m_kin.getPowertrain(nMotorId);
719 }
720 
721 
722 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
723 // Attibute Methods.
724 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
725 
727 {
728  return m_bIsConnected;
729 }
730 
731 void LaeRobot::getVersion(int &nVerMajor, int &nVerMinor, int &nRevision)
732 {
733  uint_t uHwVer;
734 
735  uHwVer = m_descLaelaps.getProdHwVer();
736  nVerMajor = LAE_VER_MAJOR(uHwVer);
737  nVerMinor = LAE_VER_MINOR(uHwVer);
738  nRevision = LAE_VER_REV(uHwVer);
739 }
740 
742 {
744 }
745 
747 {
748  return m_descLaelaps;
749 }
750 
752 {
753  return m_descLaelaps.getProdId();
754 }
755 
757 {
758  return m_descLaelaps.getProdName();
759 }
760 
762 {
763  return m_descLaelaps.getProdBrief();
764 }
765 
767 {
768  return m_descLaelaps.isDescribed();
769 }
770 
772 {
773  return m_eRobotMode;
774 }
775 
777 {
778  return m_bIsEStopped;
779 }
780 
782 {
783  return m_kin.areMotorsPowered();
784 }
785 
787 {
788  return m_kin.isStopped()? false: true;
789 }
790 
792 {
793  bool bAlarmState = false;
794 
796  {
797  bAlarmState = true;
798  }
799  if( isEStopped() )
800  {
801  bAlarmState = true;
802  }
803 
804  return m_bAlarmState;
805 }
806 
808 {
809  // not safe to operate.
811  {
812  return false;
813  }
814  // emergency stopped
815  else if( m_bIsEStopped )
816  {
817  return false;
818  }
819  // motors are unpowered
820  else if( !areMotorsPowered() )
821  {
822  return false;
823  }
824  // we have a go!
825  else
826  {
827  return true;
828  }
829 }
830 
831 
832 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
833 // Datatbase Methods.
834 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
835 
837 {
842 }
843 
844 
845 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
846 // Hardare Connection and Configuration Methods.
847 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
848 
850 {
851  string strIdent;
852  uint_t uVerMajor, uVerMinor, uFwVer;
853  int rc;
854 
855  //
856  // Connect to the CleanFlight Intertial Measrurement Unit.
857  //
858  if( (rc = m_imu.open(LaeDevIMU, LaeBaudRateIMU)) < 0 )
859  {
860  LOGERROR("%s: Failed to open IMU at %d baud.", LaeDevIMU, LaeBaudRateIMU);
861  }
862 
863  else if( (rc = m_imu.readIdentity(strIdent)) < 0 )
864  {
865  LOGERROR("%s: Failed to read IMU identity.", LaeDevIMU);
866  }
867 
868  if( rc == LAE_OK )
869  {
870  LOGDIAG2("Connected to IMU %s.", strIdent.c_str());
871  }
872  else
873  {
874  m_imu.blacklist();
875  LOGWARN("IMU is blacklisted from the suite of robot sensors.");
876  rc = LAE_OK;
877  }
878 
879  //
880  // Connect to the Range Sensor Group.
881  //
882  if( (rc = m_range.setInterface(m_descLaelaps.getProdHwVer())) < 0 )
883  {
884  LOGERROR("Failed to set range sensor group interface.");
885  }
886 
887  else if((rc = m_range.getInterfaceVersion(uVerMajor, uVerMinor, uFwVer)) < 0)
888  {
889  LOGERROR("Failed to read range sensor group interface version.");
890  }
891 
892  if( rc == LAE_OK )
893  {
895 
896  LOGDIAG2("Connected to Range Sensor Group v%u.%u, fwver=%u.",
897  uVerMajor, uVerMinor, uFwVer);
898  }
899  else
900  {
901  m_range.blacklist();
902  LOGWARN("Range sensors are blacklisted from the suite of robot sensors.");
903  rc = LAE_OK;
904  }
905 
906  return rc;
907 }
908 
910 {
911  uint_t uFwVer;
912 
913  if( m_watchdog.cmdGetFwVersion(uFwVer) < 0 )
914  {
915  LOGWARN("WatchDog: Failed to get firmware version.");
916  }
917  else
918  {
919  LOGDIAG2("Connected to WatchDog sub-processor, fwver=%u.", uFwVer);
920 
921  // sync watchdog state with subprocessor
922  m_watchdog.sync();
923  }
924 
925  return LAE_OK;
926 }
927 
928 int LaeRobot::connMotorControllers(const std::string &strDevMotorCtlrs,
929  const int nBaudRate)
930 {
931  int rc;
932 
933  rc = m_kin.open(strDevMotorCtlrs, nBaudRate,
935 
936  if( rc < 0 )
937  {
938  LOGERROR("%s: Failed to open at motor controllers at %d baud.",
939  strDevMotorCtlrs.c_str(), nBaudRate);
940  }
941 
942  LOGDIAG2("Created front and rear motor controller interfaces.");
943 
944  return rc;
945 }
946 
948 {
949  int rc; // return code
950 
951  //
952  // Configure watchdog from product description
953  //
954  if( (rc = m_watchdog.configure(m_descLaelaps)) != LAE_OK )
955  {
956  LOGERROR("Failed to configure WatchDog.");
957  }
958 
959  //
960  // Configure watchdog from tunable parameters
961  //
962  else if( (rc = m_watchdog.configure(m_tunes)) != LAE_OK )
963  {
964  LOGERROR("Failed to tune WatchDog.");
965  }
966 
967  //
968  // Configure kinodynamics from product description.
969  //
970  else if( (rc = m_kin.configure(m_descLaelaps)) != LAE_OK )
971  {
972  LOGERROR("Failed to configure kinodynamics.");
973  }
974 
975  //
976  // Configure kinodynamics from tunable parameters.
977  //
978  else if( (rc = m_kin.configure(m_tunes)) != LAE_OK )
979  {
980  LOGERROR("Failed to tune kinodynamics.");
981  }
982 
983  //
984  // Configure IMU from product description.
985  //
986  else if( (rc = m_imu.configure(m_descLaelaps)) != LAE_OK )
987  {
988  LOGERROR("Failed to configure IMU.");
989  }
990 
991  //
992  // Configure IMU from tunable parameters.
993  //
994  else if( (rc = m_imu.configure(m_tunes)) != LAE_OK )
995  {
996  LOGERROR("Failed to tune IMU.");
997  }
998 
999  //
1000  // Configure range sensors from product description.
1001  //
1002  else if( (rc = m_range.configure(m_descLaelaps)) != LAE_OK )
1003  {
1004  LOGERROR("Failed to configure IMU.");
1005  }
1006 
1007  //
1008  // Configure range sensors from tunable parameters.
1009  //
1010  else if( (rc = m_range.configure(m_tunes)) != LAE_OK )
1011  {
1012  LOGERROR("Failed to configure range sensor group.");
1013  }
1014 
1015  //
1016  // Good
1017  //
1018  else
1019  {
1020  //
1021  // Enable power to top deck battery and regulated 5V power outputs.
1022  // Note: Moved to watchdog subprocessor.
1023  //
1024  //m_powerBatt.enable();
1025  //m_power5V.enable();
1026 
1027  rc = LAE_OK;
1028  }
1029 
1030  LOGDIAG2("Configured for operation.");
1031 
1032  return rc;
1033 }
1034 
1036 {
1037  int nPriority;
1038  double fHz;
1039  int rc;
1040 
1041  //
1042  // WatchDog thread.
1043  //
1044  nPriority = LaeThreadWd::ThreadWdPrioDft;
1046 
1047  if( (rc = startThread(&m_threadWatchDog, nPriority, fHz)) != LAE_OK )
1048  {
1049  return rc;
1050  }
1051 
1052  //
1053  // Time-of-Flight range sensors thread.
1054  //
1056  fHz = m_tunes.getRangeHz();
1057 
1058  if( (rc = startThread(&m_threadRange, nPriority, fHz)) != LAE_OK )
1059  {
1060  return rc;
1061  }
1062 
1063  //
1064  // Inertia Measurement Unit thread.
1065  //
1066  nPriority = LaeThreadImu::ThreadImuPrioDft;
1067  fHz = m_tunes.getImuHz();
1068 
1069  if( (rc = startThread(&m_threadImu, nPriority, fHz)) != LAE_OK )
1070  {
1071  return rc;
1072  }
1073 
1074  //
1075  // Kinodynamics thread.
1076  //
1077  nPriority = LaeThreadKin::ThreadKinPrioDft;
1078  fHz = m_tunes.getKinematicsHz();
1079 
1080  if( (rc = startThread(&m_threadKin, nPriority, fHz)) != LAE_OK )
1081  {
1082  return rc;
1083  }
1084 
1085  return LAE_OK;
1086 }
1087 
1088 int LaeRobot::startThread(LaeThread *pThread, int nPriority, double fHz)
1089 {
1090  string strName;
1091  int rc;
1092 
1093  strName = pThread->getThreadName();
1094 
1095  if( (rc = pThread->createThread(nPriority)) < 0 )
1096  {
1097  LOGERROR("%s thread: Failed to create.", strName.c_str());
1098  }
1099  else if( (rc = pThread->runThread(fHz)) < 0 )
1100  {
1101  LOGERROR("%s thread: Failed to start.", strName.c_str());
1102  }
1103  else
1104  {
1105  LOGDIAG2("%s thread started at %.3lfHz with priority %d.",
1106  strName.c_str(), fHz, nPriority);
1107  rc = LAE_OK;
1108  }
1109 
1110  return rc;
1111 }
1112 
1114 {
1115  int rc;
1116 
1117  if( (rc = m_threadAsync.createThread(m_pAsyncJob)) == LAE_OK )
1118  {
1120  }
1121 
1122  return rc;
1123 }
1124 
1126 {
1128 }
1129 
1131 {
1132  if( m_pAsyncJob != NULL )
1133  {
1134  return m_pAsyncJob->getState();
1135  }
1136  else
1137  {
1139  }
1140 }
1141 
1143 {
1144  if( m_pAsyncJob != NULL )
1145  {
1146  m_pAsyncJob->getRc();
1147  }
1148  else
1149  {
1150  return -LAE_ECODE_NO_RSRC;
1151  }
1152 }
int open(const std::string &strDevMotorCtlrs, const int nBaudRate, int(*fnEnable)(void *, bool)=NULL, void *pEnableArg=NULL)
Open communication with the <b><i>Laelaps</i></b> motor controllers.
Definition: laeKin.cxx:141
int getAsyncJobRc()
Get the last asynchronous job exit return code.
Definition: laeRobot.cxx:1142
double m_fGovernor
speed limit governor setting
Definition: laeRobot.h:649
std::map< std::string, double > LaeMapDutyCycle
Duty cycle trajectory type.
Definition: laeTraj.h:269
virtual int terminateThread()
Terminate the thread.
virtual int configure(const laelaps::LaeDesc &desc)
Configure IMU from product description.
Definition: laeImu.cxx:237
int startCoreThreads()
Create and start all real-time persistent core threads.
Definition: laeRobot.cxx:1035
double getImuHz() const
Get IMU tasks thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:319
JobState getState()
Get the current job state.
uint_t getProdHwVer() const
Get this robot&#39;s packed hardware version number.
Definition: laeDesc.h:608
#define LAE_TRY_NO_EXEC()
Test for no execute flag.
Definition: laeRobot.cxx:112
virtual int cmdReadDPin(uint_t pin, uint_t &val)
Read the value of a digital pin command.
Definition: laeWd.cxx:445
virtual bool areMotorsPowered()
Test if motors are powered.
Definition: laeKin.h:183
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
virtual int getRange(const std::string &strKey, double &fRange)
Get the shadowed range measurement.
virtual int terminateThread()
Terminate the thread.
Definition: laeThread.cxx:202
virtual int stop()
Stop all motors at the current position.
Definition: laeKin.cxx:1125
std::string getFullProdBrief()
Get the <b><i>Laelaps</i></b> full brief descirption.
Definition: laeRobot.cxx:761
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
double getWatchDogTimeout() const
Get watchdog timeout (seconds).
Definition: laeTune.cxx:334
Laelaps kinodynamics thread class interface.
void clear()
Clear data.
Definition: laeTraj.cxx:220
virtual int runThread(const double fHz=ThreadAsyncHzDft)
Run the thread.
std::string getProdName()
Convenience function to get this <b><i>Laelaps</i></b> description&#39;s base product name...
Definition: laeRobot.cxx:756
int setAuxPower(const std::string &strName, LaeTriState eState)
Set top deck auxilliary power out enable state.
Definition: laeRobot.cxx:570
LaeXmlTune <b><i>Laelaps</i></b> XML tuning class.
Definition: laeXmlTune.h:71
Trajectory classes interfaces.
const char *const LaeEtcTune
xml tune file
Definition: laelaps.h:247
Laelaps robotic mobile platform full description class.
Definition: laeDesc.h:451
void clearSensedData()
Clear sensed data.
Definition: laeVL6180.cxx:2388
int resetEStop()
Reset (clears) emergency stop condition.
Definition: laeRobot.cxx:451
LaePowertrain * getPowertrain(const std::string &strName)
Get pointer to powertrain by name (key).
double getKinematicsHz() const
Get kinematics thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:324
#define LAE_VER_REV(ver)
Get revision number from version.
Definition: laelaps.h:186
LaeThreadImu m_threadImu
IMU thread.
Definition: laeRobot.h:669
virtual bool isEnabled()
Test if motors are enabled.
Definition: laeKin.h:173
bool isEStopped()
Test if robot is current emergency stopped.
Definition: laeRobot.cxx:776
unknown mode state
Definition: laelaps.h:329
static bool isSafeToOperate()
Test if robot is safe to operate given the current alarm state.
Definition: laeAlarms.cxx:85
LaeThreadAsync m_threadAsync
asynchronous action thread
Definition: laeRobot.h:668
virtual int open(const std::string &strDevName, int nBaudRate)
Definition: laeImu.cxx:162
const int LaeBaudRateMotorCtlrs
motor controller serial baudrate
Definition: laeSysDev.h:92
int connect()
Connect to <b><i>Laelaps</i></b>.
Definition: laeRobot.cxx:193
int connSensors()
Connect to the <b><i>Laelaps</i></b> built-in sensors.
Definition: laeRobot.cxx:849
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
#define LAE_VER_MINOR(ver)
Get version minor number from version.
Definition: laelaps.h:177
virtual int readDigitalPin(uint_t pin, uint_t &val)
Read the value of a digital pin on the watchdog subprocessor.
Definition: laeRobot.cxx:619
static const u32_t LAE_ALARM_NONE
no alarms
Definition: laeAlarms.h:74
virtual int getRangeSensorProps(const std::string &strKey, std::string &strRadiationType, double &fFoV, double &fBeamDir, double &fMin, double &fMax)
Get range sensor properties.
Definition: laeRobot.cxx:643
LaeRobotMode
<b><i>Laelaps</i></b> mode of operation.
Definition: laelaps.h:327
static double optimizeHz(const double fWatchDogTimeout)
Optimize thread hertz rate given the watchdog timeout value.
Definition: laeThreadWd.cxx:79
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: laeUtils.h:162
void cancelAsyncJob()
Cancel any asynchronous job.
Definition: laeRobot.cxx:1125
LaeDbRobotStatus m_robotstatus
robot status data
Definition: laeDb.h:229
void clear()
Clear data.
Definition: laeTraj.cxx:94
LaePowertrain * getPowertrain(const std::string &strName)
Get the robotic joint in kinematic chain.
virtual int cmdWriteDPin(uint_t pin, uint_t val)
Write a value to a digital pin command.
Definition: laeWd.cxx:506
fully available
Definition: laelaps.h:331
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
virtual int configure(const LaeDesc &desc)
Configure watchdog from product description.
Definition: laeWd.cxx:159
virtual int setGoalVelocities(const LaeMapVelocity &velocity)
Set new or updated motor velocity goals.
Definition: laeKin.cxx:1274
static const double ThreadWdPrioDft
default priority
Definition: laeThreadWd.h:92
virtual int getInterfaceVersion(uint_t &uVerMajor, uint_t &uVerMinor, uint_t &uFwVer)
Get interface version.
Definition: laeVL6180.cxx:2393
static const double ThreadRangePrioDft
default priority
virtual int setGoalTwist(double fVelLinear, double fVelAngular)
Set new or updated robot twist velocity goals.
Definition: laeKin.cxx:1370
LaeRobotMode getRobotMode()
Get robot&#39;s operational mode.
Definition: laeRobot.cxx:771
RoboClaw motor controller class interface.
int startThread(LaeThread *pThread, int nPriority, double fHz)
Create and start a thread at the given priority and hertz.
Definition: laeRobot.cxx:1088
virtual void clearSensedData()
Clear IMU sensed data.
Definition: laeImu.cxx:252
bool canMove()
Test if robot is safe to operate, given the current robot and alarm state.
Definition: laeRobot.cxx:807
Laelaps WatchDog software class interface.
Laelaps PCA9548A I2C multiplexer switch interface.
double setGovernor(double fGovernor)
Set speed limit governor value.
Definition: laeRobot.cxx:547
int getRobotStatus(LaeRptRobotStatus &rptBotStatus)
Get the robot current status.
Definition: laeRobot.cxx:605
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
bool isDescribed()
Test if robot is fully described via configuration XML.
Definition: laeRobot.cxx:766
static const double GovernorDft
speed limit governor start-up default
Definition: laeRobot.h:106
Laelaps dynamics report.
Definition: laeReports.h:302
virtual int configDigitalPin(uint_t pin, uint_t dir)
Configure a digital pin on the the watchdog subprocessor.
Definition: laeRobot.cxx:614
LaeThreadKin m_threadKin
kinodynamics thread
Definition: laeRobot.h:670
LaeDesc & getLaelapsDesc()
Get the <b><i>Laelaps</i></b> product description.
Definition: laeRobot.cxx:746
Laelaps I2C class interface.
virtual int cmdEnableAuxPort5V(bool bEnable)
Enable/disable regulated 5 volt auxilliary port power out.
Definition: laeWd.cxx:759
LaeAlarmInfo m_system
system alarm summary state
Definition: laeDb.h:212
int configForOperation()
Configure <b><i>Laelaps</i></b> for normal operation.
Definition: laeRobot.cxx:947
Simple path feedback class.
Definition: laeTraj.h:510
std::string getProdBrief() const
Get this base description&#39;s brief.
Definition: laeDesc.h:588
virtual int configure(const LaeDesc &desc)
Configure kinematics chains and data from product description.
Definition: laeKin.cxx:331
virtual void getImuData(double accel[], double gyro[], double mag[], double rpy[], Quaternion &q)
Get the last sensed, converted, and computed IMU data.
Definition: laeImu.cxx:349
const char *const LaeSysCfgPath
System configuration search path.
Definition: laelaps.h:226
virtual bool isStopped()
Test if all motors are stopped.
Definition: laeKin.cxx:986
virtual int getRange(const std::string &strKey, double &fRange)
Get a range measurement.
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeDb.h:108
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
Definition: laeThreadWd.cxx:99
bool m_bIsConnected
critical hardware [not] connected
Definition: laeDb.h:107
LaeTunes m_tunes
tuning parameters
Definition: laeRobot.h:652
void clear()
Clear report.
Definition: laeReports.cxx:395
static const int LAE_ECODE_MOT_CTLR
motor controller error
Definition: laelaps.h:97
int getProdId() const
Get this base description&#39;s base product id.
Definition: laeDesc.h:568
virtual int configure(const laelaps::LaeDesc &desc)
Configure sensor group from product description.
Definition: laeVL6180.cxx:2401
<b><i>Laelaps</i></b> XML tuning class interface.
Laelaps Time-of-Flight sensors. The ToFs are used as a virtual bumper for close-in obstacle detection...
static const double ThreadKinPrioDft
default priority
Definition: laeThreadKin.h:85
bool isDescribed() const
Test if required base description is adequately described.
Definition: laeDesc.h:558
int disconnect()
Disconnect from <b><i>Laelaps</i></b>.
Definition: laeRobot.cxx:333
const byte_t LaeI2CAddrWd
watchdog I2C address synonym
Definition: laeWatchDog.h:165
int reload()
Reload <b><i>Laelaps</i></b>&#39;s reloadable configuration and reset operational parameters.
Definition: laeRobot.cxx:372
int estop()
Emergency stop.
Definition: laeRobot.cxx:421
virtual int load(LaeTunes &tunes, const std::string &strSearchPath=LaeSysCfgPath, const std::string &strXmlFileName=LaeEtcTune, bool bAllInstances=false)
Load XML file into DOM and set the <b><i>Laelaps</i></b> tuning parameters.
Definition: laeXmlTune.cxx:71
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
Interfaces of Laelaps requested and/or published report classes.
Laelaps robotic base mobile platform description class interface.
bool m_bIsConnected
critical hardware [not] connected
Definition: laeRobot.h:645
void generate(LaeRobot *pRobot)
Generate report.
Definition: laeReports.cxx:403
double getGovernor()
Get current speed limit governor setting.
Definition: laeRobot.cxx:559
int connMotorControllers(const std::string &strDevMotorCtlrs, const int nBaudRate)
Connect to the <b><i>Laelaps</i></b> motor controllers.
Definition: laeRobot.cxx:928
LaeAsyncJob::JobState getAsyncJobState()
Get the current asynchronous job state.
Definition: laeRobot.cxx:1130
void syncDb()
Synchronize real-time database with current robot state.
Definition: laeRobot.cxx:836
virtual void resetEStop()
Reset emergency stop condition.
Definition: laeKin.cxx:1085
const int NumOfAxes
maximum number of axes per sensor component.
Definition: laeImu.h:98
double incrementGovernor(double fDelta)
Increment/decrement speed limit governor value.
Definition: laeRobot.cxx:554
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
Laelaps common utilities.
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
const int LaeBaudRateIMU
IMU serial baudrate.
Definition: laeSysDev.h:154
Laelaps built-in Inertial Measurement Unit class interface.
Simple path feedback class.
Definition: laeTraj.h:821
std::string getVersionString()
Get the <b><i>Laelaps</i></b> robotic arm hardware version string.
Definition: laeRobot.cxx:741
bool isAlarmed()
Test if robot is alarmed.
Definition: laeRobot.cxx:791
LaeI2C m_i2cBus
I2C sensor bus.
Definition: laeRobot.h:659
The Laelaps kinematics and dynamics class interface.
Laelaps powertrain class interfaces.
int freeze()
Freeze robot and accessories at current position.
Definition: laeRobot.cxx:486
u32_t m_uAlarms
alarm or&#39;ed bits
Definition: laeAlarms.h:160
const char *const LaeDevIMU
IMU USB udev linked name.
Definition: laeSysDev.h:145
virtual int cmdReadAPin(uint_t pin, uint_t &val)
Read the value of an analog pin command.
Definition: laeWd.cxx:555
virtual int getImu(double accel[], double gyro[], double rpy[], sensor::imu::Quaternion &q)
Get the last read and converted inertia data.
Definition: laeRobot.cxx:634
Laelaps tuning.
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeDb.h:109
int getProdId()
Convenience function to get this <b><i>Laelaps</i></b> description&#39;s base product id...
Definition: laeRobot.cxx:751
virtual int createThread(int nPriority)
Create the thread.
Definition: laeThread.cxx:107
Laelasp Robot Class interface.
std::string getThreadName() const
Get assigned thread name.
Definition: laeThread.h:169
LaeThreadRange m_threadRange
ToF range sensors thread.
Definition: laeRobot.h:671
virtual int getAmbientLight(const std::string &strKey, double &fAmbient)
Get an ambient light illuminance measurement.
Laelaps system devices.
int getDynamics(LaeRptDynamics &rptDynamics)
Get the robot full dynamic state.
Definition: laeRobot.cxx:682
Quaternion class.
Definition: laeImu.h:118
static const int LAE_ECODE_BAD_OP
invalid operation error
Definition: laelaps.h:80
static const int LAE_ECODE_NO_RSRC
no resource available error
Definition: laelaps.h:83
int getNavigationState(LaeSimplePathFeedback &pathFeedback)
Get simple navigation feedback.
Definition: laeRobot.cxx:693
int getRc()
Get job&#39;s return code.
bool m_bNoExec
do [not] execute physical movements
Definition: laeRobot.h:643
Laelaps robotic platform control and dynamics state interface.
Laelaps built-in Arduino sub-processor.
virtual int cmdGetFwVersion(uint_t &uVerNum)
Get the firmware version command.
Definition: laeWd.cxx:263
virtual void blacklist()
Black list range sensor group from robot sensors.
Definition: laeVL6180.cxx:2356
Laelaps range sensors thread class interface.
virtual ~LaeRobot()
Destructor.
Definition: laeRobot.cxx:188
int connWatchDog()
Connect to the watchdog subprocessor.
Definition: laeRobot.cxx:909
bool isInMotion()
Test if any joint in any of the kinematic chains is moving.
Definition: laeRobot.cxx:786
virtual int setGoalDutyCycles(const LaeMapDutyCycle &duty)
Set new or updated motor duty cycle goals.
Definition: laeKin.cxx:1322
Laelaps asynchronouse thread class interface.
Laelaps motors, encoder, and controllers hardware abstraction interfaces.
Laelaps watchdog thread class interface.
int setInterface(uint_t uProdHwVer)
Set the interface, given the <b><i>Laelaps</i></b> hardware version.
Definition: laeVL6180.cxx:2368
static const int LAE_ECODE_BAD_VAL
bad value general error
Definition: laelaps.h:76
Laelaps alarm monitoring class interface.
bool areMotorsPowered()
Test if robot motor are currently being driven (powered).
Definition: laeRobot.cxx:781
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
int clearAlarms()
Attempt to clear all alarms.
Definition: laeRobot.cxx:598
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
virtual int close()
Close communication.
Definition: laeKin.cxx:221
Robot global status report.
Definition: laeReports.h:163
virtual int createThread(LaeAsyncJob *pJob, int nPriority=ThreadAsyncPrioDft)
Create the thread.
#define LAE_VER_MAJOR(ver)
Get version major number from version.
Definition: laelaps.h:168
virtual int cmdConfigDPin(uint_t pin, uint_t dir)
Configure a digital pin command.
Definition: laeWd.cxx:396
int setDutyCycles(const LaeMapDutyCycle &duty)
Set powertrain motor duty cycles.
Definition: laeRobot.cxx:536
void setRobotMode(LaeRobotMode eRobotMode)
Set robot&#39;s operational mode.
Definition: laeRobot.cxx:564
void getVersion(int &nVerMajor, int &nVerMinor, int &nRevision)
Get the <b><i>Laelaps</i></b> hardware version number.
Definition: laeRobot.cxx:731
int move(const LaeMapVelocity &velocity)
Move by setting powertrain angular wheel velocities.
Definition: laeRobot.cxx:517
LaeDbAlarms m_alarms
alarm state data
Definition: laeDb.h:238
Laelaps IMU thread class interface.
virtual int readIdentity(std::string &strIdent)
Read sensor identity values.
Definition: laeImu.cxx:376
virtual int release()
Release motors.
Definition: laeKin.cxx:1094
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
bool m_bAlarmState
robot is [not] alarmed
Definition: laeDb.h:110
Laelaps supported cameras.
virtual int getAmbientLight(const std::string &strKey, double &fAmbient)
Get the shadowed ambient light illuminance measurement.
std::string getProdHwVerString() const
Get this robot&#39;s hardware version string.
Definition: laeDesc.h:598
int release()
Release robot and accessories.
Definition: laeRobot.cxx:501
virtual int close()
Close I2C bus device.
Definition: laeI2C.cxx:144
LaeAsyncJob * m_pAsyncJob
asynchronous job
Definition: laeRobot.h:675
virtual int runThread(const double fHz)
Run the thread.
Definition: laeThread.cxx:174
std::map< std::string, double > LaeMapVelocity
Velocity trajectory type.
Definition: laeTraj.h:258
int stop()
Stop robot with full dynamic braking.
Definition: laeRobot.cxx:481
virtual int readAnalogPin(uint_t pin, uint_t &val)
Read the value of an analog pin on the watchdog subprocessor.
Definition: laeRobot.cxx:629
std::string getProdName() const
Get this base description&#39;s name.
Definition: laeDesc.h:578
virtual int getSensorProps(const std::string &strKey, std::string &strRadiationType, double &fFoV, double &fBeamDir, double &fMin, double &fMax)
Get range sensor properties.
Definition: laeVL6180.cxx:2437
virtual int close()
Close connection to motor controller.
Definition: laeImu.cxx:201
int i2cTryOpen(LaeI2C &i2cBus, uint_t addr)
Try to open a series of I2C devices to fine the required endpoint.
Definition: laeI2C.cxx:67
static int enableMotorCtlrs(void *pArg, bool bEnable)
Enable/disable power in to motor controllers.
Definition: laeWd.cxx:1117
virtual int cmdEnableAuxPortBatt(bool bEnable)
Enable/disable battery auxilliary port power out.
Definition: laeWd.cxx:808
static const double ThreadImuPrioDft
default priority
Definition: laeThreadImu.h:84
LaeTriState
<b><i>Laelaps</i></b> tri-state type.
Definition: laelaps.h:300
Powertrain data class.
bool isConnected()
Test if connected to <b><i>Laelaps</i></b> hardware.
Definition: laeRobot.cxx:726
double getRangeHz() const
Get range sensing thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:329
void generate(LaeRobot *pRobot)
Generate report.
Definition: laeReports.cxx:221
Laelaps real-time "database".
int runAsyncJob()
Run asynchronous job.
Definition: laeRobot.cxx:1113
const char *const LaeDevMotorCtlrs
odroid motor controllers&#39; serial device name
Definition: laeSysDev.h:81
LaeThreadWd m_threadWatchDog
watchdog thread
Definition: laeRobot.h:672
void clear()
Clear report.
Definition: laeReports.cxx:195
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
virtual void blacklist()
Black list IMU from robot sensors.
Definition: laeImu.cxx:220
virtual void sync()
Synchronize watchdog state with subprocessor state.
Definition: laeWd.cxx:142
virtual void estop()
Emergency stop the robot.
Definition: laeKin.cxx:1064
Top-level package include file.
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
virtual int writeDigitalPin(uint_t pin, uint_t val)
Write a value to a digital pin on the watchdog subprocessor.
Definition: laeRobot.cxx:624