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

Laelaps robotic manipulator plus accesories class. More...

#include <laeRobot.h>

Public Member Functions

 LaeRobot (bool bNoExec=false)
 Default initialization constructor. More...
 
virtual ~LaeRobot ()
 Destructor.
 
int connect ()
 Connect to Laelaps. More...
 
int disconnect ()
 Disconnect from Laelaps. More...
 
int reload ()
 Reload Laelaps's reloadable configuration and reset operational parameters. More...
 
int estop ()
 Emergency stop. More...
 
int resetEStop ()
 Reset (clears) emergency stop condition. More...
 
int freeze ()
 Freeze robot and accessories at current position. More...
 
int release ()
 Release robot and accessories. More...
 
int stop ()
 Stop robot with full dynamic braking. More...
 
int move (const LaeMapVelocity &velocity)
 Move by setting powertrain angular wheel velocities. More...
 
int move (double fVelLinear, double fVelAngular)
 Move at the given linear and angular velocities. More...
 
int setDutyCycles (const LaeMapDutyCycle &duty)
 Set powertrain motor duty cycles. More...
 
double setGovernor (double fGovernor)
 Set speed limit governor value. More...
 
double incrementGovernor (double fDelta)
 Increment/decrement speed limit governor value. More...
 
double getGovernor ()
 Get current speed limit governor setting. More...
 
void setRobotMode (LaeRobotMode eRobotMode)
 Set robot's operational mode. More...
 
int setAuxPower (const std::string &strName, LaeTriState eState)
 Set top deck auxilliary power out enable state. More...
 
int clearAlarms ()
 Attempt to clear all alarms. More...
 
virtual int configDigitalPin (uint_t pin, uint_t dir)
 Configure a digital pin on the the watchdog subprocessor. More...
 
virtual int readDigitalPin (uint_t pin, uint_t &val)
 Read the value of a digital pin on the watchdog subprocessor. More...
 
virtual int writeDigitalPin (uint_t pin, uint_t val)
 Write a value to a digital pin on the watchdog subprocessor. More...
 
virtual int readAnalogPin (uint_t pin, uint_t &val)
 Read the value of an analog pin on the watchdog subprocessor. More...
 
virtual int getImu (double accel[], double gyro[], double rpy[], sensor::imu::Quaternion &q)
 Get the last read and converted inertia data. More...
 
virtual int getRangeSensorProps (const std::string &strKey, std::string &strRadiationType, double &fFoV, double &fBeamDir, double &fMin, double &fMax)
 Get range sensor properties. More...
 
virtual int getRange (const std::string &strKey, double &fRange)
 Get a range measurement. More...
 
virtual int getRange (std::vector< std::string > &vecNames, std::vector< double > &vecRanges)
 Get all sensor range measurements. More...
 
virtual int getAmbientLight (const std::string &strKey, double &fAmbient)
 Get an ambient light illuminance measurement. More...
 
virtual int getAmbientLight (std::vector< std::string > &vecNames, std::vector< double > &vecAmbient)
 Get all sensor ambient light illuminance measurements. More...
 
int runAsyncJob ()
 Run asynchronous job. More...
 
void cancelAsyncJob ()
 Cancel any asynchronous job. More...
 
LaeAsyncJob::JobState getAsyncJobState ()
 Get the current asynchronous job state. More...
 
int getAsyncJobRc ()
 Get the last asynchronous job exit return code. More...
 
int getRobotStatus (LaeRptRobotStatus &rptBotStatus)
 Get the robot current status. More...
 
int getDynamics (LaeRptDynamics &rptDynamics)
 Get the robot full dynamic state. More...
 
int getNavigationState (LaeSimplePathFeedback &pathFeedback)
 Get simple navigation feedback. More...
 
int getNavigationState (LaePathFeedback &pathFeedback)
 Get navigation feedback. More...
 
bool isConnected ()
 Test if connected to Laelaps hardware. More...
 
void getVersion (int &nVerMajor, int &nVerMinor, int &nRevision)
 Get the Laelaps hardware version number. More...
 
std::string getVersionString ()
 Get the Laelaps robotic arm hardware version string. More...
 
LaeDescgetLaelapsDesc ()
 Get the Laelaps product description. More...
 
int getProdId ()
 Convenience function to get this Laelaps description's base product id. More...
 
std::string getProdName ()
 Convenience function to get this Laelaps description's base product name. More...
 
std::string getFullProdBrief ()
 Get the Laelaps full brief descirption. More...
 
bool isDescribed ()
 Test if robot is fully described via configuration XML. More...
 
LaeRobotMode getRobotMode ()
 Get robot's operational mode. More...
 
bool isEStopped ()
 Test if robot is current emergency stopped. More...
 
bool areMotorsPowered ()
 Test if robot motor are currently being driven (powered). More...
 
bool isInMotion ()
 Test if any joint in any of the kinematic chains is moving. More...
 
bool isAlarmed ()
 Test if robot is alarmed. More...
 
bool canMove ()
 Test if robot is safe to operate, given the current robot and alarm state. More...
 
LaePowertraingetPowertrain (const std::string &strName)
 Get the robotic joint in kinematic chain. More...
 
LaePowertraingetPowertrain (int nMotorId)
 Get robotic joint in kinematic chain. More...
 

Static Public Attributes

static const double GovernorDft = 1.0
 speed limit governor start-up default
 

Protected Member Functions

void syncDb ()
 Synchronize real-time database with current robot state.
 
int connSensors ()
 Connect to the Laelaps built-in sensors. More...
 
int connWatchDog ()
 Connect to the watchdog subprocessor. More...
 
int connMotorControllers (const std::string &strDevMotorCtlrs, const int nBaudRate)
 Connect to the Laelaps motor controllers. More...
 
int configForOperation ()
 Configure Laelaps for normal operation. More...
 
int startCoreThreads ()
 Create and start all real-time persistent core threads. More...
 
int startThread (LaeThread *pThread, int nPriority, double fHz)
 Create and start a thread at the given priority and hertz. More...
 

Protected Attributes

bool m_bNoExec
 do [not] execute physical movements
 
LaeDesc m_descLaelaps
  Laelaps description
 
bool m_bIsConnected
 critical hardware [not] connected
 
LaeRobotMode m_eRobotMode
 robot operating mode
 
bool m_bIsEStopped
 robot is [not] emergency stopped
 
bool m_bAlarmState
 robot is [not] alarmed
 
double m_fGovernor
 speed limit governor setting
 
LaeTunes m_tunes
 tuning parameters
 
LaeI2C m_i2cBus
 I2C sensor bus.
 
sensor::vl6180::LaeRangeSensorGroup m_range
 range sensor group.
 
sensor::imu::LaeImuCleanFlight m_imu
 inertia measurement unit
 
LaeWd m_watchdog
 watchdog sub-processor
 
LaeKinematics m_kin
 robot base dynamics and kinematics
 
LaeThreadAsync m_threadAsync
 asynchronous action thread
 
LaeThreadImu m_threadImu
 IMU thread.
 
LaeThreadKin m_threadKin
 kinodynamics thread
 
LaeThreadRange m_threadRange
 ToF range sensors thread.
 
LaeThreadWd m_threadWatchDog
 watchdog thread
 
LaeAsyncJobm_pAsyncJob
 asynchronous job
 

Friends

class LaeRptDynamics
 
class LaeRptRobotStatus
 

Detailed Description

Laelaps robotic manipulator plus accesories class.

Definition at line 103 of file laeRobot.h.

Constructor & Destructor Documentation

LaeRobot::LaeRobot ( bool  bNoExec = false)

Default initialization constructor.

Parameters
bNoExecDo [not] execute on physical hardware. All commands and responses are supported but the lower level hardware commands will not be issued.

Definition at line 164 of file laeRobot.cxx.

References GovernorDft, laelaps::LaeRobotModeUnknown, m_bAlarmState, m_bIsConnected, m_bIsEStopped, m_bNoExec, m_eRobotMode, m_pAsyncJob, setGovernor(), and syncDb().

164  :
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 }
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
LaeThreadImu m_threadImu
IMU thread.
Definition: laeRobot.h:669
unknown mode state
Definition: laelaps.h:329
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
double setGovernor(double fGovernor)
Set speed limit governor value.
Definition: laeRobot.cxx:547
static const double GovernorDft
speed limit governor start-up default
Definition: laeRobot.h:106
LaeThreadKin m_threadKin
kinodynamics thread
Definition: laeRobot.h:670
bool m_bIsConnected
critical hardware [not] connected
Definition: laeRobot.h:645
void syncDb()
Synchronize real-time database with current robot state.
Definition: laeRobot.cxx:836
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
LaeI2C m_i2cBus
I2C sensor bus.
Definition: laeRobot.h:659
LaeThreadRange m_threadRange
ToF range sensors thread.
Definition: laeRobot.h:671
bool m_bNoExec
do [not] execute physical movements
Definition: laeRobot.h:643
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
LaeAsyncJob * m_pAsyncJob
asynchronous job
Definition: laeRobot.h:675
LaeThreadWd m_threadWatchDog
watchdog thread
Definition: laeRobot.h:672
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646

Member Function Documentation

bool LaeRobot::areMotorsPowered ( )

Test if robot motor are currently being driven (powered).

Returns
Returns true or false.

Definition at line 781 of file laeRobot.cxx.

References laelaps::LaeKinematics::areMotorsPowered(), and m_kin.

Referenced by canMove().

782 {
783  return m_kin.areMotorsPowered();
784 }
virtual bool areMotorsPowered()
Test if motors are powered.
Definition: laeKin.h:183
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
void LaeRobot::cancelAsyncJob ( )

Cancel any asynchronous job.

Note
There may be a little delay between canceling an async job and the job actually stopping.

Definition at line 1125 of file laeRobot.cxx.

References m_threadAsync, and laelaps::LaeThreadAsync::terminateThread().

Referenced by disconnect().

1126 {
1128 }
virtual int terminateThread()
Terminate the thread.
LaeThreadAsync m_threadAsync
asynchronous action thread
Definition: laeRobot.h:668
bool LaeRobot::canMove ( )

Test if robot is safe to operate, given the current robot and alarm state.

Returns
Returns true or false.

Definition at line 807 of file laeRobot.cxx.

References areMotorsPowered(), laelaps::LaeAlarms::isSafeToOperate(), and m_bIsEStopped.

Referenced by laelaps::LaeRptRobotStatus::generate().

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 }
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
static bool isSafeToOperate()
Test if robot is safe to operate given the current alarm state.
Definition: laeAlarms.cxx:85
bool areMotorsPowered()
Test if robot motor are currently being driven (powered).
Definition: laeRobot.cxx:781
int LaeRobot::clearAlarms ( )

Attempt to clear all alarms.

Note
For Laelaps, most alarms are not clearable (e.g. temperature, low battery). Only external intervention is effective.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 598 of file laeRobot.cxx.

References laelaps::LAE_OK, and LAE_TRY_CONN.

599 {
600  LAE_TRY_CONN();
601 
602  return LAE_OK;
603 }
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::configDigitalPin ( uint_t  pin,
uint_t  dir 
)
virtual

Configure a digital pin on the the watchdog subprocessor.

Parameters
pinDigital pin number.
dirPin direction. 0 == input, 1 == output.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 614 of file laeRobot.cxx.

References laelaps::LaeWd::cmdConfigDPin(), and m_watchdog.

615 {
616  return m_watchdog.cmdConfigDPin(pin, dir);
617 }
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
virtual int cmdConfigDPin(uint_t pin, uint_t dir)
Configure a digital pin command.
Definition: laeWd.cxx:396
int LaeRobot::configForOperation ( )
protected

Configure Laelaps for normal operation.

The arm, end effector, and accessory effectors are configured for normal operation.

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

Definition at line 947 of file laeRobot.cxx.

References laelaps::LaeWd::configure(), laelaps::LaeKinematics::configure(), sensor::imu::LaeImu::configure(), sensor::vl6180::LaeRangeSensorGroup::configure(), laelaps::LAE_OK, m_descLaelaps, m_imu, m_kin, m_range, m_tunes, and m_watchdog.

Referenced by connect().

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 }
virtual int configure(const laelaps::LaeDesc &desc)
Configure IMU from product description.
Definition: laeImu.cxx:237
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
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
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
virtual int configure(const LaeDesc &desc)
Configure kinematics chains and data from product description.
Definition: laeKin.cxx:331
LaeTunes m_tunes
tuning parameters
Definition: laeRobot.h:652
virtual int configure(const laelaps::LaeDesc &desc)
Configure sensor group from product description.
Definition: laeVL6180.cxx:2401
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::connect ( )

Connect to Laelaps.

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

Definition at line 193 of file laeRobot.cxx.

References configForOperation(), connMotorControllers(), connSensors(), connWatchDog(), disconnect(), freeze(), laelaps::i2cTryOpen(), laelaps::LaeDesc::isDescribed(), laelaps::LAE_ECODE_BAD_OP, laelaps::LAE_OK, laelaps::LaeBaudRateMotorCtlrs, laelaps::LaeDevMotorCtlrs, laelaps::LaeEtcTune, laelaps::LaeI2CAddrWd, laelaps::LaeRobotModeAuto, laelaps::LaeRobotModeUnknown, laelaps::LaeSysCfgPath, laelaps::LaeXmlTune::load(), m_bAlarmState, m_bIsConnected, m_bIsEStopped, m_descLaelaps, m_eRobotMode, m_i2cBus, m_tunes, startCoreThreads(), and syncDb().

Referenced by main().

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 }
int startCoreThreads()
Create and start all real-time persistent core threads.
Definition: laeRobot.cxx:1035
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
LaeXmlTune <b><i>Laelaps</i></b> XML tuning class.
Definition: laeXmlTune.h:71
const char *const LaeEtcTune
xml tune file
Definition: laelaps.h:247
unknown mode state
Definition: laelaps.h:329
const int LaeBaudRateMotorCtlrs
motor controller serial baudrate
Definition: laeSysDev.h:92
int connSensors()
Connect to the <b><i>Laelaps</i></b> built-in sensors.
Definition: laeRobot.cxx:849
fully available
Definition: laelaps.h:331
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
int configForOperation()
Configure <b><i>Laelaps</i></b> for normal operation.
Definition: laeRobot.cxx:947
const char *const LaeSysCfgPath
System configuration search path.
Definition: laelaps.h:226
LaeTunes m_tunes
tuning parameters
Definition: laeRobot.h:652
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
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
bool m_bIsConnected
critical hardware [not] connected
Definition: laeRobot.h:645
int connMotorControllers(const std::string &strDevMotorCtlrs, const int nBaudRate)
Connect to the <b><i>Laelaps</i></b> motor controllers.
Definition: laeRobot.cxx:928
void syncDb()
Synchronize real-time database with current robot state.
Definition: laeRobot.cxx:836
LaeI2C m_i2cBus
I2C sensor bus.
Definition: laeRobot.h:659
int freeze()
Freeze robot and accessories at current position.
Definition: laeRobot.cxx:486
static const int LAE_ECODE_BAD_OP
invalid operation error
Definition: laelaps.h:80
int connWatchDog()
Connect to the watchdog subprocessor.
Definition: laeRobot.cxx:909
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
int i2cTryOpen(LaeI2C &i2cBus, uint_t addr)
Try to open a series of I2C devices to fine the required endpoint.
Definition: laeI2C.cxx:67
const char *const LaeDevMotorCtlrs
odroid motor controllers&#39; serial device name
Definition: laeSysDev.h:81
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::connMotorControllers ( const std::string &  strDevMotorCtlrs,
const int  nBaudRate 
)
protected

Connect to the Laelaps motor controllers.

Motors controller serial interface support multi-drop, so one serial device can support up to 8 motor controllers.

Parameters
strDevMotorCtlrsMotor controllers serial device name.
nBaudRateMotor controllers serial baudrate.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 928 of file laeRobot.cxx.

References laelaps::LaeWd::enableMotorCtlrs(), m_kin, m_watchdog, and laelaps::LaeKinematics::open().

Referenced by connect().

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 }
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
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
static int enableMotorCtlrs(void *pArg, bool bEnable)
Enable/disable power in to motor controllers.
Definition: laeWd.cxx:1117
int LaeRobot::connSensors ( )
protected

Connect to the Laelaps built-in sensors.

Sensors are not critical to core operation, so failed sensors are simply blacklisted, rather than failing the robot.

Sensors:
  • IMU
  • ToF infrared distance sensors
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 849 of file laeRobot.cxx.

References sensor::imu::LaeImu::blacklist(), sensor::vl6180::LaeRangeSensorGroup::blacklist(), sensor::vl6180::LaeRangeSensorGroup::clearSensedData(), sensor::vl6180::LaeRangeSensorGroup::getInterfaceVersion(), laelaps::LaeDesc::getProdHwVer(), laelaps::LAE_OK, laelaps::LaeBaudRateIMU, laelaps::LaeDevIMU, m_descLaelaps, m_imu, m_range, sensor::imu::LaeImu::open(), sensor::imu::LaeImuCleanFlight::readIdentity(), and sensor::vl6180::LaeRangeSensorGroup::setInterface().

Referenced by connect().

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 }
uint_t getProdHwVer() const
Get this robot&#39;s packed hardware version number.
Definition: laeDesc.h:608
void clearSensedData()
Clear sensed data.
Definition: laeVL6180.cxx:2388
virtual int open(const std::string &strDevName, int nBaudRate)
Definition: laeImu.cxx:162
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
virtual int getInterfaceVersion(uint_t &uVerMajor, uint_t &uVerMinor, uint_t &uFwVer)
Get interface version.
Definition: laeVL6180.cxx:2393
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
const int LaeBaudRateIMU
IMU serial baudrate.
Definition: laeSysDev.h:154
const char *const LaeDevIMU
IMU USB udev linked name.
Definition: laeSysDev.h:145
virtual void blacklist()
Black list range sensor group from robot sensors.
Definition: laeVL6180.cxx:2356
int setInterface(uint_t uProdHwVer)
Set the interface, given the <b><i>Laelaps</i></b> hardware version.
Definition: laeVL6180.cxx:2368
virtual int readIdentity(std::string &strIdent)
Read sensor identity values.
Definition: laeImu.cxx:376
virtual void blacklist()
Black list IMU from robot sensors.
Definition: laeImu.cxx:220
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::connWatchDog ( )
protected

Connect to the watchdog subprocessor.

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

Definition at line 909 of file laeRobot.cxx.

References laelaps::LaeWd::cmdGetFwVersion(), laelaps::LAE_OK, m_watchdog, and laelaps::LaeWd::sync().

Referenced by connect().

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 }
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
virtual int cmdGetFwVersion(uint_t &uVerNum)
Get the firmware version command.
Definition: laeWd.cxx:263
virtual void sync()
Synchronize watchdog state with subprocessor state.
Definition: laeWd.cxx:142
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::disconnect ( )

Disconnect from Laelaps.

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

Definition at line 333 of file laeRobot.cxx.

References cancelAsyncJob(), sensor::imu::LaeImu::clearSensedData(), sensor::vl6180::LaeRangeSensorGroup::clearSensedData(), laelaps::LaeI2C::close(), laelaps::LaeKinematics::close(), sensor::imu::LaeImu::close(), isConnected(), laelaps::LAE_OK, laelaps::LaeRobotModeUnknown, m_bAlarmState, m_bIsConnected, m_bIsEStopped, m_eRobotMode, m_i2cBus, m_imu, m_kin, m_range, m_threadImu, m_threadKin, m_threadRange, m_threadWatchDog, syncDb(), and laelaps::LaeThread::terminateThread().

Referenced by connect(), main(), and ~LaeRobot().

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 }
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
virtual int terminateThread()
Terminate the thread.
Definition: laeThread.cxx:202
void clearSensedData()
Clear sensed data.
Definition: laeVL6180.cxx:2388
LaeThreadImu m_threadImu
IMU thread.
Definition: laeRobot.h:669
unknown mode state
Definition: laelaps.h:329
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
void cancelAsyncJob()
Cancel any asynchronous job.
Definition: laeRobot.cxx:1125
virtual void clearSensedData()
Clear IMU sensed data.
Definition: laeImu.cxx:252
LaeThreadKin m_threadKin
kinodynamics thread
Definition: laeRobot.h:670
bool m_bIsConnected
critical hardware [not] connected
Definition: laeRobot.h:645
void syncDb()
Synchronize real-time database with current robot state.
Definition: laeRobot.cxx:836
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
LaeI2C m_i2cBus
I2C sensor bus.
Definition: laeRobot.h:659
LaeThreadRange m_threadRange
ToF range sensors thread.
Definition: laeRobot.h:671
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
virtual int close()
Close communication.
Definition: laeKin.cxx:221
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
virtual int close()
Close I2C bus device.
Definition: laeI2C.cxx:144
virtual int close()
Close connection to motor controller.
Definition: laeImu.cxx:201
bool isConnected()
Test if connected to <b><i>Laelaps</i></b> hardware.
Definition: laeRobot.cxx:726
LaeThreadWd m_threadWatchDog
watchdog thread
Definition: laeRobot.h:672
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::estop ( )

Emergency stop.

All motor will stop driving, so arm or accessories may fall.

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

Definition at line 421 of file laeRobot.cxx.

References laelaps::LaeKinematics::estop(), laelaps::LaeKinematics::isEnabled(), laelaps::LAE_ECODE_MOT_CTLR, laelaps::LAE_OK, LAE_TRY_CONN, LAE_TRY_NO_EXEC, m_bAlarmState, m_bIsEStopped, m_kin, and syncDb().

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 }
#define LAE_TRY_NO_EXEC()
Test for no execute flag.
Definition: laeRobot.cxx:112
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
virtual bool isEnabled()
Test if motors are enabled.
Definition: laeKin.h:173
static const int LAE_ECODE_MOT_CTLR
motor controller error
Definition: laelaps.h:97
void syncDb()
Synchronize real-time database with current robot state.
Definition: laeRobot.cxx:836
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
virtual void estop()
Emergency stop the robot.
Definition: laeKin.cxx:1064
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::freeze ( )

Freeze robot and accessories at current position.

Motors are still being driven. The motors are either dynamically or regeneratively braked.

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

Definition at line 486 of file laeRobot.cxx.

References laelaps::LAE_OK, LAE_TRY_CONN, LAE_TRY_NO_EXEC, m_kin, and laelaps::LaeKinematics::stop().

Referenced by connect(), and stop().

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 }
#define LAE_TRY_NO_EXEC()
Test for no execute flag.
Definition: laeRobot.cxx:112
virtual int stop()
Stop all motors at the current position.
Definition: laeKin.cxx:1125
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
virtual int laelaps::LaeRobot::getAmbientLight ( const std::string &  strKey,
double &  fAmbient 
)
virtual

Get an ambient light illuminance measurement.

Parameters
strKeySensor's unique name (key).
[out]fAmbientSensed ambient light (lux).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Referenced by getRangeSensorProps().

virtual int laelaps::LaeRobot::getAmbientLight ( std::vector< std::string > &  vecNames,
std::vector< double > &  vecAmbient 
)
virtual

Get all sensor ambient light illuminance measurements.

Parameters
[out]vecNamesVector of sensor unique names.
[out]vecAmbientVector of associated sensor measured ambients (lux).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.
int LaeRobot::getAsyncJobRc ( )

Get the last asynchronous job exit return code.

Returns
Returns LAE_OK when job terminated successfully. Otherwise, returns < 0 laelaps_ecodes.

Definition at line 1142 of file laeRobot.cxx.

References laelaps::LaeAsyncJob::getRc(), laelaps::LAE_ECODE_NO_RSRC, and m_pAsyncJob.

1143 {
1144  if( m_pAsyncJob != NULL )
1145  {
1146  m_pAsyncJob->getRc();
1147  }
1148  else
1149  {
1150  return -LAE_ECODE_NO_RSRC;
1151  }
1152 }
static const int LAE_ECODE_NO_RSRC
no resource available error
Definition: laelaps.h:83
int getRc()
Get job&#39;s return code.
LaeAsyncJob * m_pAsyncJob
asynchronous job
Definition: laeRobot.h:675
LaeAsyncJob::JobState LaeRobot::getAsyncJobState ( )

Get the current asynchronous job state.

Returns
Job state enum value.

Definition at line 1130 of file laeRobot.cxx.

References laelaps::LaeAsyncJob::getState(), laelaps::LaeAsyncJob::JobStateNoJob, and m_pAsyncJob.

1131 {
1132  if( m_pAsyncJob != NULL )
1133  {
1134  return m_pAsyncJob->getState();
1135  }
1136  else
1137  {
1139  }
1140 }
JobState getState()
Get the current job state.
LaeAsyncJob * m_pAsyncJob
asynchronous job
Definition: laeRobot.h:675
int LaeRobot::getDynamics ( LaeRptDynamics rptDynamics)

Get the robot full dynamic state.

Parameters
[in,out]rptDynamicsRobot dynamics state report.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 682 of file laeRobot.cxx.

References laelaps::LaeRptDynamics::clear(), laelaps::LaeRptDynamics::generate(), laelaps::LAE_OK, and LAE_TRY_CONN.

683 {
684  LAE_TRY_CONN();
685 
686  rptDynamics.clear();
687 
688  rptDynamics.generate(this);
689 
690  return LAE_OK;
691 }
void clear()
Clear report.
Definition: laeReports.cxx:395
void generate(LaeRobot *pRobot)
Generate report.
Definition: laeReports.cxx:403
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
string LaeRobot::getFullProdBrief ( )

Get the Laelaps full brief descirption.

Returns
Returns product brief description.

Definition at line 761 of file laeRobot.cxx.

References laelaps::LaeDesc::getProdBrief(), and m_descLaelaps.

762 {
763  return m_descLaelaps.getProdBrief();
764 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
std::string getProdBrief() const
Get this base description&#39;s brief.
Definition: laeDesc.h:588
double LaeRobot::getGovernor ( )

Get current speed limit governor setting.

Note
Software governor is not implemented as yet.
Returns
Return value.

Definition at line 559 of file laeRobot.cxx.

References m_fGovernor.

560 {
561  return m_fGovernor;
562 }
double m_fGovernor
speed limit governor setting
Definition: laeRobot.h:649
int LaeRobot::getImu ( double  accel[],
double  gyro[],
double  rpy[],
sensor::imu::Quaternion q 
)
virtual

Get the last read and converted inertia data.

Not applicable data are set to zero.

Parameters
[out]accelAccelerometer data (m/s^2). The array size must be ≥ NumOfAxes.
[out]gyroGyroscope data (radians/s). The array size must be ≥ NumOfAxes.
[out]rpyRoll,pitch,yaw data (radians). The array size must be ≥ NumOfAxes.
[out]qVehicle quaternion.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 634 of file laeRobot.cxx.

References sensor::imu::LaeImu::getImuData(), laelaps::LAE_OK, m_imu, and sensor::imu::NumOfAxes.

635 {
636  double mag[NumOfAxes]; // no magnetometer
637 
638  m_imu.getImuData(accel, gyro, mag, rpy, q);
639 
640  return LAE_OK;
641 }
sensor::imu::LaeImuCleanFlight m_imu
inertia measurement unit
Definition: laeRobot.h:661
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 int NumOfAxes
maximum number of axes per sensor component.
Definition: laeImu.h:98
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
LaeDesc & LaeRobot::getLaelapsDesc ( )

Get the Laelaps product description.

Returns
Returns reference to description.

Definition at line 746 of file laeRobot.cxx.

References m_descLaelaps.

Referenced by main().

747 {
748  return m_descLaelaps;
749 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
int LaeRobot::getNavigationState ( LaeSimplePathFeedback pathFeedback)

Get simple navigation feedback.

Parameters
[in,out]pathFeedbackNavigation feedback state.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 693 of file laeRobot.cxx.

References laelaps::LaeSimplePathFeedback::clear(), and laelaps::LAE_OK.

694 {
695  // TBD
696 
697  pathFeedback.clear();
698 
699  return LAE_OK;
700 }
void clear()
Clear data.
Definition: laeTraj.cxx:94
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::getNavigationState ( LaePathFeedback pathFeedback)

Get navigation feedback.

Parameters
[in,out]pathFeedbackNavigation feedback state.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 702 of file laeRobot.cxx.

References laelaps::LaePathFeedback::clear(), laelaps::LaeKinematics::getPowertrain(), getPowertrain(), laelaps::LAE_OK, and m_kin.

703 {
704  // TBD
705 
706  pathFeedback.clear();
707 
708  return LAE_OK;
709 }
void clear()
Clear data.
Definition: laeTraj.cxx:220
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
LaePowertrain* laelaps::LaeRobot::getPowertrain ( const std::string &  strName)

Get the robotic joint in kinematic chain.

Parameters
strNamePowertrain unique name (primary key).
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Referenced by getNavigationState().

LaePowertrain * LaeRobot::getPowertrain ( int  nMotorId)

Get robotic joint in kinematic chain.

Parameters
nMotorIdMotor id (secondary key).
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Definition at line 716 of file laeRobot.cxx.

References laelaps::LaeKinematics::getPowertrain(), and m_kin.

717 {
718  return m_kin.getPowertrain(nMotorId);
719 }
LaePowertrain * getPowertrain(const std::string &strName)
Get pointer to powertrain by name (key).
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
int LaeRobot::getProdId ( )

Convenience function to get this Laelaps description's base product id.

Returns
Returns product id. See LaeProdId.

Definition at line 751 of file laeRobot.cxx.

References laelaps::LaeDesc::getProdId(), and m_descLaelaps.

752 {
753  return m_descLaelaps.getProdId();
754 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
int getProdId() const
Get this base description&#39;s base product id.
Definition: laeDesc.h:568
string LaeRobot::getProdName ( )

Convenience function to get this Laelaps description's base product name.

Returns
Returns product name. See LaeProdName.

Definition at line 756 of file laeRobot.cxx.

References laelaps::LaeDesc::getProdName(), and m_descLaelaps.

757 {
758  return m_descLaelaps.getProdName();
759 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
std::string getProdName() const
Get this base description&#39;s name.
Definition: laeDesc.h:578
virtual int laelaps::LaeRobot::getRange ( const std::string &  strKey,
double &  fRange 
)
virtual

Get a range measurement.

Parameters
strKeySensor's unique name (key).
[out]fRangeSensed object range (meters).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Referenced by getRangeSensorProps().

virtual int laelaps::LaeRobot::getRange ( std::vector< std::string > &  vecNames,
std::vector< double > &  vecRanges 
)
virtual

Get all sensor range measurements.

Parameters
[out]vecNamesVector of sensor unique names.
[out]vecRangesVector of associated sensor measured ranges (meters).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.
int LaeRobot::getRangeSensorProps ( const std::string &  strKey,
std::string &  strRadiationType,
double &  fFoV,
double &  fBeamDir,
double &  fMin,
double &  fMax 
)
virtual

Get range sensor properties.

Parameters
strKeySensor's unique name id (key).
[out]strRadiationTypeRadiation type.
[out]fFoVField of View (radians).
[out]fBeamdirCenter of beam direction (radians).
[out]fMinMinimum range (meters).
[out]fMaxMaximum range (meters).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 643 of file laeRobot.cxx.

References getAmbientLight(), sensor::vl6180::LaeRangeSensorGroup::getAmbientLight(), getRange(), sensor::vl6180::LaeRangeSensorGroup::getRange(), sensor::vl6180::LaeRangeSensorGroup::getSensorProps(), and m_range.

649 {
650  return m_range.getSensorProps(strKey,
651  strRadiationType,
652  fFoV, fBeamDir,
653  fMin, fMax);
654 }
sensor::vl6180::LaeRangeSensorGroup m_range
range sensor group.
Definition: laeRobot.h:660
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
LaeRobotMode LaeRobot::getRobotMode ( )

Get robot's operational mode.

Returns
Robot operation mode. See LaeRobotMode.

Definition at line 771 of file laeRobot.cxx.

References m_eRobotMode.

772 {
773  return m_eRobotMode;
774 }
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646
int LaeRobot::getRobotStatus ( LaeRptRobotStatus rptBotStatus)

Get the robot current status.

Parameters
[in,out]rptBotStatusRobot status report.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 605 of file laeRobot.cxx.

References laelaps::LaeRptRobotStatus::clear(), laelaps::LaeRptRobotStatus::generate(), and laelaps::LAE_OK.

606 {
607  rptBotStatus.clear();
608 
609  rptBotStatus.generate(this);
610 
611  return LAE_OK;
612 }
void generate(LaeRobot *pRobot)
Generate report.
Definition: laeReports.cxx:221
void clear()
Clear report.
Definition: laeReports.cxx:195
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
void LaeRobot::getVersion ( int &  nVerMajor,
int &  nVerMinor,
int &  nRevision 
)

Get the Laelaps hardware version number.

Parameters
[out]nVerMajorMajor version number.
[out]nVerMinorMinor version number.
[out]nVerRevisionRevision version number.

Definition at line 731 of file laeRobot.cxx.

References laelaps::LaeDesc::getProdHwVer(), LAE_VER_MAJOR, LAE_VER_MINOR, LAE_VER_REV, and m_descLaelaps.

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 }
uint_t getProdHwVer() const
Get this robot&#39;s packed hardware version number.
Definition: laeDesc.h:608
#define LAE_VER_REV(ver)
Get revision number from version.
Definition: laelaps.h:186
#define LAE_VER_MINOR(ver)
Get version minor number from version.
Definition: laelaps.h:177
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
#define LAE_VER_MAJOR(ver)
Get version major number from version.
Definition: laelaps.h:168
string LaeRobot::getVersionString ( )

Get the Laelaps robotic arm hardware version string.

Version number strings are of the dotted form maj.min.rev.

Returns
Version string.

Definition at line 741 of file laeRobot.cxx.

References laelaps::LaeDesc::getProdHwVerString(), and m_descLaelaps.

742 {
744 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
std::string getProdHwVerString() const
Get this robot&#39;s hardware version string.
Definition: laeDesc.h:598
double LaeRobot::incrementGovernor ( double  fDelta)

Increment/decrement speed limit governor value.

Note
Software governor is not implemented as yet.

Governor is defined as:
speed = set_speed * governor

Parameters
fDeltaGovernor ± delta.
Returns
Returns new governor value.

Definition at line 554 of file laeRobot.cxx.

References m_fGovernor, and setGovernor().

555 {
556  return setGovernor(m_fGovernor+fDelta);
557 }
double m_fGovernor
speed limit governor setting
Definition: laeRobot.h:649
double setGovernor(double fGovernor)
Set speed limit governor value.
Definition: laeRobot.cxx:547
bool LaeRobot::isAlarmed ( )

Test if robot is alarmed.

Returns
Returns true or false.

Definition at line 791 of file laeRobot.cxx.

References isEStopped(), laelaps::LAE_ALARM_NONE, laelaps::LaeDb::m_alarms, m_bAlarmState, laelaps::LaeDbAlarms::m_system, laelaps::LaeAlarmInfo::m_uAlarms, and laelaps::RtDb.

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 }
bool isEStopped()
Test if robot is current emergency stopped.
Definition: laeRobot.cxx:776
static const u32_t LAE_ALARM_NONE
no alarms
Definition: laeAlarms.h:74
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
LaeAlarmInfo m_system
system alarm summary state
Definition: laeDb.h:212
u32_t m_uAlarms
alarm or&#39;ed bits
Definition: laeAlarms.h:160
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
LaeDbAlarms m_alarms
alarm state data
Definition: laeDb.h:238
bool LaeRobot::isConnected ( )

Test if connected to Laelaps hardware.

Returns
Returns true or false.

Definition at line 726 of file laeRobot.cxx.

References m_bIsConnected.

Referenced by disconnect(), and main().

727 {
728  return m_bIsConnected;
729 }
bool m_bIsConnected
critical hardware [not] connected
Definition: laeRobot.h:645
bool LaeRobot::isDescribed ( )

Test if robot is fully described via configuration XML.

Returns
Returns true or false.

Definition at line 766 of file laeRobot.cxx.

References laelaps::LaeDesc::isDescribed(), and m_descLaelaps.

767 {
768  return m_descLaelaps.isDescribed();
769 }
LaeDesc m_descLaelaps
<b><i>Laelaps</i></b> description
Definition: laeRobot.h:644
bool isDescribed() const
Test if required base description is adequately described.
Definition: laeDesc.h:558
bool LaeRobot::isEStopped ( )

Test if robot is current emergency stopped.

Returns
Returns true or false.

Definition at line 776 of file laeRobot.cxx.

References m_bIsEStopped.

Referenced by isAlarmed().

777 {
778  return m_bIsEStopped;
779 }
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
bool LaeRobot::isInMotion ( )

Test if any joint in any of the kinematic chains is moving.

Note
RS160D motor controller provide no feedback.
Returns
Returns true or false.

Definition at line 786 of file laeRobot.cxx.

References laelaps::LaeKinematics::isStopped(), and m_kin.

787 {
788  return m_kin.isStopped()? false: true;
789 }
virtual bool isStopped()
Test if all motors are stopped.
Definition: laeKin.cxx:986
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
int LaeRobot::move ( const LaeMapVelocity velocity)

Move by setting powertrain angular wheel velocities.

The robot is controlled by setting the goal velocities of a [sub]set of powertrain motors.

Parameters
velocityMap of powertrain velocities.
Keys are left_front, right_front, left_rear, and right_rear.
Values are drive shaft/wheel angular velocities (radians/second).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 517 of file laeRobot.cxx.

References LAE_TRY_CONN, m_kin, and laelaps::LaeKinematics::setGoalVelocities().

518 {
519  int rc;
520 
521  LAE_TRY_CONN();
522 
523  rc = m_kin.setGoalVelocities(velocity);
524 
525  return rc;
526 }
virtual int setGoalVelocities(const LaeMapVelocity &velocity)
Set new or updated motor velocity goals.
Definition: laeKin.cxx:1274
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
int LaeRobot::move ( double  fVelLinear,
double  fVelAngular 
)

Move at the given linear and angular velocities.

This move is typically used with the ROS Twist message where:

  • linear velocity is the x component Twist.linear.x
  • angular velocity is the yaw component Twist.angular.z
Parameters
fVelLinearLinear velocity (meters/second).
fVelAngularAngular velocity (radians/second).
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 528 of file laeRobot.cxx.

References LAE_TRY_CONN, m_kin, and laelaps::LaeKinematics::setGoalTwist().

529 {
530  LAE_TRY_CONN();
531 
532  return m_kin.setGoalTwist(fVelLinear, fVelAngular);
533 
534 }
virtual int setGoalTwist(double fVelLinear, double fVelAngular)
Set new or updated robot twist velocity goals.
Definition: laeKin.cxx:1370
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
int LaeRobot::readAnalogPin ( uint_t  pin,
uint_t &  val 
)
virtual

Read the value of an analog pin on the watchdog subprocessor.

Parameters
pinAnalog pin number.
[out]valAnalog 10-bit value [0-1023].
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 629 of file laeRobot.cxx.

References laelaps::LaeWd::cmdReadAPin(), and m_watchdog.

630 {
631  return m_watchdog.cmdReadAPin(pin, val);
632 }
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
virtual int cmdReadAPin(uint_t pin, uint_t &val)
Read the value of an analog pin command.
Definition: laeWd.cxx:555
int LaeRobot::readDigitalPin ( uint_t  pin,
uint_t &  val 
)
virtual

Read the value of a digital pin on the watchdog subprocessor.

Parameters
pinDigital pin number.
[out]valDigital pin low (0) or high (1) value.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 619 of file laeRobot.cxx.

References laelaps::LaeWd::cmdReadDPin(), and m_watchdog.

620 {
621  return m_watchdog.cmdReadDPin(pin, val);
622 }
virtual int cmdReadDPin(uint_t pin, uint_t &val)
Read the value of a digital pin command.
Definition: laeWd.cxx:445
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
int LaeRobot::release ( )

Release robot and accessories.

Motors will stop being driven. The robot will coast to a stop (on a flat surface) and is capabable of being externally pushed.

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

Definition at line 501 of file laeRobot.cxx.

References laelaps::LAE_OK, LAE_TRY_CONN, LAE_TRY_NO_EXEC, m_kin, and laelaps::LaeKinematics::release().

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 }
#define LAE_TRY_NO_EXEC()
Test for no execute flag.
Definition: laeRobot.cxx:112
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
virtual int release()
Release motors.
Definition: laeKin.cxx:1094
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::reload ( )

Reload Laelaps's reloadable configuration and reset operational parameters.

The robot connection and calibration states are uneffected.

Definition at line 372 of file laeRobot.cxx.

References laelaps::LAE_OK, laelaps::LaeEtcTune, laelaps::LaeSysCfgPath, laelaps::LaeXmlTune::load(), m_threadImu, m_threadKin, m_threadRange, m_threadWatchDog, m_tunes, laelaps::LaeThreadImu::reload(), laelaps::LaeThreadKin::reload(), laelaps::LaeThreadRange::reload(), and laelaps::LaeThreadWd::reload().

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 }
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
LaeXmlTune <b><i>Laelaps</i></b> XML tuning class.
Definition: laeXmlTune.h:71
const char *const LaeEtcTune
xml tune file
Definition: laelaps.h:247
LaeThreadImu m_threadImu
IMU thread.
Definition: laeRobot.h:669
LaeThreadKin m_threadKin
kinodynamics thread
Definition: laeRobot.h:670
const char *const LaeSysCfgPath
System configuration search path.
Definition: laelaps.h:226
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
Definition: laeThreadWd.cxx:99
LaeTunes m_tunes
tuning parameters
Definition: laeRobot.h:652
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
LaeThreadRange m_threadRange
ToF range sensors thread.
Definition: laeRobot.h:671
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
LaeThreadWd m_threadWatchDog
watchdog thread
Definition: laeRobot.h:672
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::resetEStop ( )

Reset (clears) emergency stop condition.

Note
Motors are not re-powered until an move or freeze action is called.

Definition at line 451 of file laeRobot.cxx.

References laelaps::LaeKinematics::isEnabled(), laelaps::LAE_ECODE_MOT_CTLR, laelaps::LAE_OK, LAE_TRY_CONN, LAE_TRY_NO_EXEC, m_bAlarmState, m_bIsEStopped, m_kin, laelaps::LaeKinematics::resetEStop(), and syncDb().

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 }
#define LAE_TRY_NO_EXEC()
Test for no execute flag.
Definition: laeRobot.cxx:112
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeRobot.h:647
virtual bool isEnabled()
Test if motors are enabled.
Definition: laeKin.h:173
static const int LAE_ECODE_MOT_CTLR
motor controller error
Definition: laelaps.h:97
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
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
bool m_bAlarmState
robot is [not] alarmed
Definition: laeRobot.h:648
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::runAsyncJob ( )

Run asynchronous job.

The new job object must be already created.

Context:
Calling thread.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 1113 of file laeRobot.cxx.

References laelaps::LaeThreadAsync::createThread(), laelaps::LAE_OK, m_pAsyncJob, m_threadAsync, and laelaps::LaeThreadAsync::runThread().

1114 {
1115  int rc;
1116 
1117  if( (rc = m_threadAsync.createThread(m_pAsyncJob)) == LAE_OK )
1118  {
1120  }
1121 
1122  return rc;
1123 }
virtual int runThread(const double fHz=ThreadAsyncHzDft)
Run the thread.
LaeThreadAsync m_threadAsync
asynchronous action thread
Definition: laeRobot.h:668
virtual int createThread(LaeAsyncJob *pJob, int nPriority=ThreadAsyncPrioDft)
Create the thread.
LaeAsyncJob * m_pAsyncJob
asynchronous job
Definition: laeRobot.h:675
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::setAuxPower ( const std::string &  strName,
LaeTriState  eState 
)

Set top deck auxilliary power out enable state.

Parameters
strNameAux. power port name. One of: aux_batt_en aux_5v_en
eStateAux. power state. One of: DISABLED(0) ENABLED(1)
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 570 of file laeRobot.cxx.

References laelaps::LaeWd::cmdEnableAuxPort5V(), laelaps::LaeWd::cmdEnableAuxPortBatt(), laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_OK, LAE_TRY_CONN, laelaps::LaeTriStateEnabled, and m_watchdog.

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 }
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662
virtual int cmdEnableAuxPort5V(bool bEnable)
Enable/disable regulated 5 volt auxilliary port power out.
Definition: laeWd.cxx:759
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
static const int LAE_ECODE_BAD_VAL
bad value general error
Definition: laelaps.h:76
virtual int cmdEnableAuxPortBatt(bool bEnable)
Enable/disable battery auxilliary port power out.
Definition: laeWd.cxx:808
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::setDutyCycles ( const LaeMapDutyCycle duty)

Set powertrain motor duty cycles.

The robot is controlled by setting the goal duties of a [sub]set of powertrain motors.

Parameters
dutyMap of powertrain duty cycles.
Keys are left_front, right_front, left_rear, and right_rear.
Values are normalized duty cycles [-1.0, 1.0].
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 536 of file laeRobot.cxx.

References LAE_TRY_CONN, m_kin, and laelaps::LaeKinematics::setGoalDutyCycles().

537 {
538  int rc;
539 
540  LAE_TRY_CONN();
541 
542  rc = m_kin.setGoalDutyCycles(duty);
543 
544  return rc;
545 }
#define LAE_TRY_CONN()
Test for connection.
Definition: laeRobot.cxx:129
virtual int setGoalDutyCycles(const LaeMapDutyCycle &duty)
Set new or updated motor duty cycle goals.
Definition: laeKin.cxx:1322
LaeKinematics m_kin
robot base dynamics and kinematics
Definition: laeRobot.h:665
double LaeRobot::setGovernor ( double  fGovernor)

Set speed limit governor value.

Note
Software governor is not implemented as yet.

Governor is defined as:
speed = cap(set_speed, min_speed * governor, max_speed * governor)

Parameters
fGovernorGovernor value between [0.0, 1.0].
Returns
Returns new governor value.

Definition at line 547 of file laeRobot.cxx.

References laelaps::fcap(), and m_fGovernor.

Referenced by incrementGovernor(), and LaeRobot().

548 {
549  m_fGovernor = fcap(fGovernor, 0.0, 1.0);
550 
551  return m_fGovernor;
552 }
double m_fGovernor
speed limit governor setting
Definition: laeRobot.h:649
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: laeUtils.h:162
void LaeRobot::setRobotMode ( LaeRobotMode  eRobotMode)

Set robot's operational mode.

Parameters
eRobotModeRobot operation mode. See LaeRobotMode.

Definition at line 564 of file laeRobot.cxx.

References laelaps::LaeDbRobotStatus::m_eRobotMode, m_eRobotMode, laelaps::LaeDb::m_robotstatus, and laelaps::RtDb.

565 {
566  m_eRobotMode = eRobotMode;
568 }
LaeDbRobotStatus m_robotstatus
robot status data
Definition: laeDb.h:229
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeDb.h:108
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeRobot.h:646
int LaeRobot::startCoreThreads ( )
protected

Create and start all real-time persistent core threads.

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

Definition at line 1035 of file laeRobot.cxx.

References laelaps::LaeTunes::getImuHz(), laelaps::LaeTunes::getKinematicsHz(), laelaps::LaeTunes::getRangeHz(), laelaps::LaeTunes::getWatchDogTimeout(), laelaps::LAE_OK, m_threadImu, m_threadKin, m_threadRange, m_threadWatchDog, m_tunes, laelaps::LaeThreadWd::optimizeHz(), startThread(), laelaps::LaeThreadImu::ThreadImuPrioDft, laelaps::LaeThreadKin::ThreadKinPrioDft, laelaps::LaeThreadRange::ThreadRangePrioDft, and laelaps::LaeThreadWd::ThreadWdPrioDft.

Referenced by connect().

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 }
double getImuHz() const
Get IMU tasks thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:319
double getWatchDogTimeout() const
Get watchdog timeout (seconds).
Definition: laeTune.cxx:334
double getKinematicsHz() const
Get kinematics thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:324
LaeThreadImu m_threadImu
IMU thread.
Definition: laeRobot.h:669
static double optimizeHz(const double fWatchDogTimeout)
Optimize thread hertz rate given the watchdog timeout value.
Definition: laeThreadWd.cxx:79
static const double ThreadWdPrioDft
default priority
Definition: laeThreadWd.h:92
static const double ThreadRangePrioDft
default priority
int startThread(LaeThread *pThread, int nPriority, double fHz)
Create and start a thread at the given priority and hertz.
Definition: laeRobot.cxx:1088
LaeThreadKin m_threadKin
kinodynamics thread
Definition: laeRobot.h:670
LaeTunes m_tunes
tuning parameters
Definition: laeRobot.h:652
static const double ThreadKinPrioDft
default priority
Definition: laeThreadKin.h:85
LaeThreadRange m_threadRange
ToF range sensors thread.
Definition: laeRobot.h:671
static const double ThreadImuPrioDft
default priority
Definition: laeThreadImu.h:84
double getRangeHz() const
Get range sensing thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:329
LaeThreadWd m_threadWatchDog
watchdog thread
Definition: laeRobot.h:672
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::startThread ( LaeThread pThread,
int  nPriority,
double  fHz 
)
protected

Create and start a thread at the given priority and hertz.

Parameters
pThreadPointer the thread object.
nPriorityThread priority.
fHzThread execution hertz.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 1088 of file laeRobot.cxx.

References laelaps::LaeThread::createThread(), laelaps::LaeThread::getThreadName(), laelaps::LAE_OK, and laelaps::LaeThread::runThread().

Referenced by startCoreThreads().

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 }
virtual int createThread(int nPriority)
Create the thread.
Definition: laeThread.cxx:107
std::string getThreadName() const
Get assigned thread name.
Definition: laeThread.h:169
virtual int runThread(const double fHz)
Run the thread.
Definition: laeThread.cxx:174
static const int LAE_OK
not an error, success
Definition: laelaps.h:71
int LaeRobot::stop ( )

Stop robot with full dynamic braking.

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

Definition at line 481 of file laeRobot.cxx.

References freeze().

Referenced by laelaps_tune_motors.window::createLeftButtons().

482 {
483  return freeze();
484 }
int freeze()
Freeze robot and accessories at current position.
Definition: laeRobot.cxx:486
int LaeRobot::writeDigitalPin ( uint_t  pin,
uint_t  val 
)
virtual

Write a value to a digital pin on the watchdog subprocessor.

Parameters
pinDigital pin number.
valDigital pin low (0) or high (1) value.
Returns
On success, OK(0) is returned.
On error, RC_ERROR(-1) is returned.

Definition at line 624 of file laeRobot.cxx.

References laelaps::LaeWd::cmdWriteDPin(), and m_watchdog.

625 {
626  return m_watchdog.cmdWriteDPin(pin, val);
627 }
virtual int cmdWriteDPin(uint_t pin, uint_t val)
Write a value to a digital pin command.
Definition: laeWd.cxx:506
LaeWd m_watchdog
watchdog sub-processor
Definition: laeRobot.h:662

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