![]() |
Hekateros
3.4.3
RoadNarrows Robotics Robot Arm Project
|
Hekateros power, joint limits, and alarm monitoring class. More...
#include <hekMonitor.h>
Public Types | |
| enum | MonStateId { MonStateIdInit, MonStateIdRunNormal, MonStateIdRunAlarmed, MonStateIdHalting, MonStateIdHalted } |
| Hekateros internal monitor states. More... | |
| enum | MonThStateId { MonThStateIdInit, MonThStateIdIdle, MonThStateIdRun, MonThStateIdExit } |
| monitor thread states. More... | |
| typedef map< int, HekJointOptical > | MapOpticalLimits |
| Map of optical limit switches for all joints in all kinematic chains. More... | |
Public Member Functions | |
| HekMonitor () | |
| Default constructor. | |
| virtual | ~HekMonitor () |
| Destructor. | |
| int | open (uint_t uHekHwVer, const std::string &strDevArduino=HekDevArduino, int nBaudRateArduino=HekBaudRateArduino) |
| Open resources to monitor hardware. More... | |
| int | close () |
| Close resources to monitor hardware. More... | |
| int | start (double fHz=30.0) |
| Start monitoring added objects. More... | |
| int | stop () |
| Stop monitoring. More... | |
| void | addServoChainToMonitor (DynaChain *pDynaChain) |
| Add servo chain to monitor for alarms and health. More... | |
| int | addJointLimitsToMonitor (HekSpecJoint_T *pSpecJoint, HekRobotJoint *pJoint) |
| Add any joint limit switches to quick look-up map. More... | |
| void | addKinematicsToMonitor (HekKinematics *pKin) |
| Add kinematics for safety control. More... | |
| MonStateId | getMonState () |
| Get the current monitor state. More... | |
| void | markAlarmCond (bool bAlarmedCond) |
| Mark alarm condition. More... | |
| void | markEStopCond (bool bEStopCond) |
| Mark emergency stop condition. More... | |
| void | markPoweredCond (bool bPoweredCond) |
| Mark motors are powered condition. More... | |
| byte_t | readFwVersion () |
| Read firmware version. More... | |
| byte_t | readLimitSwitches () |
| Read joint limit switch states. More... | |
| byte_t | readEEGpio () |
| Read End Effector GPIO states. More... | |
| byte_t | readEEGpioPin (byte_t byPin) |
| Read one End Effector GPIO pin state. More... | |
| int | writeEEGpioPin (byte_t byPin, byte_t byVal) |
| Write state to one End Effector GPIO pin. More... | |
| int | configEEGpioPin (byte_t byPin, char cDir) |
| Configure End Effector GPIO pin direction. More... | |
| void | writeAlarmLED (bool bState) |
| Write alarm LED. More... | |
| void | writeStatusLED (bool bState) |
| Write CPU status LED. More... | |
| void | writeStartHaltingSystem () |
| Write system is halting. | |
| void | testInterface () |
| Test interface. More... | |
| int | getAlarmCond () |
| Get monitoring alarm condition. More... | |
| int | getEStopCond () |
| Get monitoring emergency stop condition. More... | |
| int | getPoweredCond () |
| Get motors are powered condition. More... | |
| HekOpticalLimit_T * | getJointLimitInfo (byte_t byMask) |
| Get joint limits information. More... | |
| byte_t | getJointLimitBits () |
| Get current limit switch bit values. More... | |
| byte_t | getEEAuxBits () |
| Get current End Effector auxilliary bit values. More... | |
| HekTriState | getJointLimitTriState (HekRobotJoint *pJoint, int nLimit) |
| Get current joint limit tri-state. More... | |
Protected Member Functions | |
| void | lock () |
| Lock the monitor thread mutex. More... | |
| void | unlock () |
| Unlock the monitor thread mutex. More... | |
| int | createMonThread () |
| Create the monitor thread. More... | |
| void | destroyMonThread () |
| Destroy the monitor thread. More... | |
| void | signalMonThread (MonThStateId eNewState) |
| Signal monitor thread of new state. More... | |
| void | idleWait () |
| Monitor thread block wait in idle state. | |
| void | runWait () |
| Monitor thread block timed wait in run state. | |
| const char * | getThStateName (MonThStateId eNewState) |
| Get thread state name string. More... | |
| void | monJointLimits () |
| Monitor joint (optical) limits for state transitions. More... | |
| void | monEEAuxIO () |
| Monitor End Effector auxillary I/O. | |
| void | monServoAlarms () |
| Monitor servos for alarms. | |
Static Protected Member Functions | |
| static void * | monThread (void *pArg) |
| Monitor thread. More... | |
Protected Attributes | |
| MonStateId | m_eMonState |
| Hekateros monitor state | |
| bool | m_bIsOpen |
| hardware is [not] open | |
| bool | m_bEStopCond |
| estop condition | |
| bool | m_bAlarmCond |
| alarm condition | |
| bool | m_bPoweredCond |
| power to motors condition | |
| DynaChain * | m_pDynaChain |
| dynamixel servo chain alarms | |
| MapOpticalLimits | m_opticalLimits |
| joint optical limits map | |
| HekKinematics * | m_pKin |
| kinematics | |
| HekUno | m_hwif |
| arduino compatible subproc i/f | |
| byte_t | m_byLimitBits |
| limit bit state | |
| byte_t | m_byEEAuxBits |
| end effector auxilliary bit state | |
| MonThStateId | m_eMonThState |
| monitoring thread state | |
| MonThStateId | m_eMonThStateOld |
| monitoring thread old state | |
| double | m_fHz |
| monitoring hertz | |
| struct timespec | m_tPeriod |
| derived monitoring period | |
| struct timespec | m_tStart |
| start time for next monitor work | |
| pthread_mutex_t | m_mutexMon |
| monitor mutex | |
| pthread_cond_t | m_condMon |
| monitor condition | |
| pthread_t | m_threadMon |
| monitor pthread identifier | |
Hekateros power, joint limits, and alarm monitoring class.
Definition at line 100 of file hekMonitor.h.
| typedef map<int, HekJointOptical> hekateros::HekMonitor::MapOpticalLimits |
Map of optical limit switches for all joints in all kinematic chains.
| key: | i/o expander bit mask |
| mapped type: | joint optical limit data |
Definition at line 112 of file hekMonitor.h.
| enum hekateros::HekMonitor::MonStateId |
Hekateros internal monitor states.
| Enumerator | |
|---|---|
| MonStateIdInit |
power on and/or (re)initializing |
| MonStateIdRunNormal |
running in normal mode |
| MonStateIdRunAlarmed |
running in alarmed mode |
| MonStateIdHalting |
halting |
| MonStateIdHalted |
halted |
Definition at line 117 of file hekMonitor.h.
| enum hekateros::HekMonitor::MonThStateId |
monitor thread states.
| Enumerator | |
|---|---|
| MonThStateIdInit |
S0. |
| MonThStateIdIdle |
no work |
| MonThStateIdRun |
process thread work |
| MonThStateIdExit |
exit/no thread |
Definition at line 129 of file hekMonitor.h.
| int HekMonitor::addJointLimitsToMonitor | ( | HekSpecJoint_T * | pSpecJoint, |
| HekRobotJoint * | pJoint | ||
| ) |
Add any joint limit switches to quick look-up map.
Only add when monitor thread does not exist or is in the idle state.
| [in] | pSpecJoint | Pointer to joint spcecification. |
| [in] | pJoint | Pointer to associated master servo joint. |
Definition at line 355 of file hekMonitor.cxx.
References hekateros::degToRad(), hekateros::HekOpticalLimit_T::m_fCenterPos, hekateros::HekOpticalLimit_T::m_fMaxBlackPos, hekateros::HekOpticalLimit_T::m_fMaxEdgePos, hekateros::HekOpticalLimit_T::m_fMinBlackPos, hekateros::HekOpticalLimit_T::m_fMinEdgePos, hekateros::HekSpecJoint_T::m_limit, hekateros::HekJointOptical::m_limit, hekateros::HekJointOptical::m_pJoint, hekateros::HekOpticalLimit_T::m_uBit, hekateros::HekJointOptical::m_uCurVal, and hekateros::HekJointOptical::m_uMask.
Referenced by addServoChainToMonitor().
|
inline |
Add kinematics for safety control.
Only add when monitor thread does not exist or is in the idle state.
| pKin | Pointer to kinematics. |
Definition at line 232 of file hekMonitor.h.
References m_pKin.
|
inline |
Add servo chain to monitor for alarms and health.
Only add when monitor thread does not exist or is in the idle state.
| pDynaChain | Pointer to dynamixel chain. |
Definition at line 205 of file hekMonitor.h.
References addJointLimitsToMonitor(), and m_pDynaChain.
| int HekMonitor::close | ( | ) |
Close resources to monitor hardware.
Cancels monitor thread.
Definition at line 253 of file hekMonitor.cxx.
| int HekMonitor::configEEGpioPin | ( | byte_t | byPin, |
| char | cDir | ||
| ) |
Configure End Effector GPIO pin direction.
| byPin | GPIO pin. |
| cDir | 'i' == input, 'o' == output. |
Definition at line 463 of file hekMonitor.cxx.
Referenced by markPoweredCond().
|
protected |
Create the monitor thread.
Definition at line 522 of file hekMonitor.cxx.
Referenced by unlock().
|
protected |
Destroy the monitor thread.
Definition at line 545 of file hekMonitor.cxx.
Referenced by unlock().
|
inline |
Get monitoring alarm condition.
Definition at line 371 of file hekMonitor.h.
References m_bAlarmCond.
Referenced by hekateros::HekRobot::isAlarmed().
|
inline |
Get current End Effector auxilliary bit values.
Definition at line 423 of file hekMonitor.h.
References getJointLimitTriState(), and m_byEEAuxBits.
|
inline |
Get monitoring emergency stop condition.
Definition at line 381 of file hekMonitor.h.
References m_bEStopCond.
|
inline |
Get current limit switch bit values.
Definition at line 413 of file hekMonitor.h.
References m_byLimitBits.
|
inline |
Get joint limits information.
| byMask | Limit switch bit mask (index). |
Definition at line 403 of file hekMonitor.h.
References m_opticalLimits.
| HekTriState HekMonitor::getJointLimitTriState | ( | HekRobotJoint * | pJoint, |
| int | nLimit | ||
| ) |
Get current joint limit tri-state.
| pJoint | Joint. |
| nLimit | Joint limit switch index. |
Definition at line 499 of file hekMonitor.cxx.
References hekateros::HekRobotJoint::m_byOptLimitMask.
Referenced by getEEAuxBits().
|
inline |
Get the current monitor state.
Definition at line 247 of file hekMonitor.h.
References m_eMonState, markAlarmCond(), and markEStopCond().
|
inline |
Get motors are powered condition.
Definition at line 391 of file hekMonitor.h.
References m_bPoweredCond.
|
protected |
Get thread state name string.
define/undef to enable/disable debug test of i/f
| eNewState | Monitor thread's new state. |
Definition at line 604 of file hekMonitor.cxx.
Referenced by monThread(), and unlock().
|
inlineprotected |
Lock the monitor thread mutex.
The calling thread will block while waiting for the mutex to become available. Once locked, the monitor thread will block.
The lock()/unlock() primitives provide a safe mechanism safely access monitor resources.
Definition at line 488 of file hekMonitor.h.
| void HekMonitor::markAlarmCond | ( | bool | bAlarmedCond | ) |
Mark alarm condition.
| bAlarm |
Definition at line 396 of file hekMonitor.cxx.
Referenced by getMonState().
| void HekMonitor::markEStopCond | ( | bool | bEStopCond | ) |
Mark emergency stop condition.
| bEStopCond |
Definition at line 403 of file hekMonitor.cxx.
Referenced by getMonState(), and hekateros::HekRobot::resetEStop().
|
inline |
Mark motors are powered condition.
| bPoweredCond |
Definition at line 271 of file hekMonitor.h.
References configEEGpioPin(), m_bPoweredCond, readEEGpio(), readEEGpioPin(), readFwVersion(), readLimitSwitches(), writeAlarmLED(), and writeEEGpioPin().
|
protected |
Monitor joint (optical) limits for state transitions.
Any limited rotation joint will be stopped when an optical limit switch transitions from lit to blocked.
Definition at line 681 of file hekMonitor.cxx.
References hekateros::degToRad(), hekateros::HekRobotJoint::doStopAtLimits(), hekateros::HekRobotJoint::m_fMaxSoftLimitRads, hekateros::HekRobotJoint::m_fMinSoftLimitRads, and hekateros::HekRobotJoint::m_strName.
Referenced by monThread(), and unlock().
|
staticprotected |
Monitor thread.
| pArg | Thread argument (point to HekMonitor object). |
Definition at line 623 of file hekMonitor.cxx.
References getThStateName(), idleWait(), m_eMonThState, m_eMonThStateOld, monEEAuxIO(), monJointLimits(), monServoAlarms(), runWait(), testInterface(), and unlock().
Referenced by unlock().
| int HekMonitor::open | ( | uint_t | uHekHwVer, |
| const std::string & | strDevArduino = HekDevArduino, |
||
| int | nBaudRateArduino = HekBaudRateArduino |
||
| ) |
Open resources to monitor hardware.
Creates monitor thread.
| uHekHwVer |
Definition at line 216 of file hekMonitor.cxx.
| byte_t HekMonitor::readEEGpio | ( | ) |
Read End Effector GPIO states.
Definition at line 435 of file hekMonitor.cxx.
Referenced by markPoweredCond().
| byte_t hekateros::HekMonitor::readEEGpioPin | ( | byte_t | byPin | ) |
Read one End Effector GPIO pin state.
| byPin | GPIO pin. |
Referenced by markPoweredCond().
| byte_t hekateros::HekMonitor::readFwVersion | ( | ) |
| byte_t HekMonitor::readLimitSwitches | ( | ) |
Read joint limit switch states.
Definition at line 420 of file hekMonitor.cxx.
Referenced by markPoweredCond().
|
protected |
Signal monitor thread of new state.
| eNewState | Monitor thread's new state. |
Definition at line 557 of file hekMonitor.cxx.
Referenced by unlock().
| int HekMonitor::start | ( | double | fHz = 30.0 | ) |
Start monitoring added objects.
| fHz | Monitoring hertz. |
Definition at line 290 of file hekMonitor.cxx.
| int HekMonitor::stop | ( | ) |
Stop monitoring.
Definition at line 328 of file hekMonitor.cxx.
| void HekMonitor::testInterface | ( | ) |
Test interface.
Diagnostics printed to stderr.
Definition at line 485 of file hekMonitor.cxx.
Referenced by monThread(), and writeStartHaltingSystem().
|
inlineprotected |
Unlock the monitor thread mutex.
The monitor thread will be available to run.
Definition at line 502 of file hekMonitor.h.
References createMonThread(), destroyMonThread(), getThStateName(), idleWait(), monEEAuxIO(), monJointLimits(), monServoAlarms(), monThread(), runWait(), and signalMonThread().
Referenced by monThread().
| void HekMonitor::writeAlarmLED | ( | bool | bState | ) |
Write alarm LED.
| bState | On/off state of LED. |
Definition at line 476 of file hekMonitor.cxx.
Referenced by markPoweredCond().
| int HekMonitor::writeEEGpioPin | ( | byte_t | byPin, |
| byte_t | byVal | ||
| ) |
Write state to one End Effector GPIO pin.
| byPin | GPIO pin. |
| byVal | GPIO pin new value. 0 or 1. |
Definition at line 450 of file hekMonitor.cxx.
Referenced by markPoweredCond().
|
inline |
Write CPU status LED.
| bState | On/off state of LED. |
Definition at line 343 of file hekMonitor.h.