Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekateros::HekRobot Class Reference

Hekateros robotic manipulator plus accesories class. More...

#include <hekRobot.h>

Public Types

enum  AsyncTaskId {
  AsyncTaskIdNone,
  AsyncTaskIdCalibrate
}
 Asynchronous task id. More...
 
typedef map< std::string, int > IMapRobotJoints
 Indirect map of robot joints. More...
 
typedef std::map< std::string, double > MapDouble
 Map of doubles.
 

Public Member Functions

 HekRobot (bool bNoExec=false)
 Default initialization constructor. More...
 
virtual ~HekRobot ()
 Destructor.
 
int connect (const std::string &strDevDynabus=HekDevDynabus, int nBaudRateDynabus=HekBaudRateDynabus, const std::string &strDevArduino=HekDevArduino, int nBaudRateArduino=HekBaudRateArduino)
 Connect to Hekateros. More...
 
int disconnect ()
 Disconnect from Hekateros. More...
 
int calibrate (bool bForceRecalib=true)
 Calibrate Hekateros's odometers and limit switch positions. More...
 
int calibrateAsync (bool bForceRecalib=true)
 Asynchronously calibrate Hekateros's odometers and limit switch positions. More...
 
void reload ()
 Reload Hekateros's reloadable configuration and reset operational parameters. More...
 
int gotoBalancedPos ()
 Move robotic arm to its pre-defined balanced position. More...
 
int gotoParkedPos ()
 Move robotic arm to its pre-defined parked position. More...
 
int gotoZeroPtPos ()
 Move robotic arm to its pre-defined calibrated zero point position. More...
 
int openGripper ()
 Open gripper to its maximum opened position. More...
 
int closeGripper ()
 Close gripper to its minimum closed position. More...
 
int estop ()
 Emergency stop. More...
 
int freeze ()
 Freeze arm and accessories at current position. More...
 
int release ()
 Release arm and accessories. More...
 
int stop (const std::vector< std::string > &vecNames)
 Stops specified joints at current position. More...
 
int clearAlarms ()
 Attempt to clear all servo alarms in all kinematic chains. More...
 
void resetEStop ()
 Reset (clears) emergency stop condition. More...
 
int moveArm (HekJointTrajectoryPoint &trajectoryPoint)
 Move arm through trajectory point. More...
 
int getRobotState (HekRobotState &robotState)
 Get the robot current state. More...
 
int getJointState (HekJointStatePoint &jointStatePoint)
 Get the joint states of a kinematic chain. More...
 
int getTrajectoryState (HekJointTrajectoryFeedback &trajectoryFeedback)
 Get trajectory feedback. More...
 
void setRobotMode (HekRobotMode eRobotMode)
 Set robot's operational mode. More...
 
bool isInMotion ()
 Test if any joint in any of the kinematic chains is moving. More...
 
void cancelAsyncTask ()
 Cancel any asynchronous task. More...
 
HekAsyncTaskState getAsyncState ()
 Get the current asynchronous task state. More...
 
int getAsyncRc ()
 Get the last asynchronous task return code. More...
 
bool isConnected ()
 Test if connected to Hekateros hardware. More...
 
void getVersion (int &nVerMajor, int &nVerMinor, int &nRevision)
 Get the Hekateros robotic arm hardware version numbers. More...
 
uint_t getVersionNum ()
 Get the Hekateros robotic arm hardware version compact number. More...
 
std::string getVersion ()
 Get the Hekateros robotic arm hardware version string. More...
 
HekDescgetHekDesc ()
 Get the Hekateros product description. More...
 
int getProdId ()
 Convenience function to get this Hekateros description's base product id. More...
 
std::string getProdName ()
 Convenience function to get this Hekateros description's base product name. More...
 
std::string getFullProdBrief ()
 Get the Hekateros full brief descirption. More...
 
int isDescribed ()
 Test if robot is fully described via configuration XML. More...
 
int isCalibrated ()
 Test if robot is calibrated. More...
 
int isEStopped ()
 Test if robot is current emergency stopped. More...
 
int areServosPowered ()
 Test if robot servos are currently being driven (powered). More...
 
int isAlarmed ()
 Test if robot is alarmed. More...
 
int isAtBalancedPos ()
 Test if robot is as pre-defined balanced position. More...
 
int isAtParkedPos ()
 Test if robot is as pre-defined parked position. More...
 
DynaChain * getDynaChain ()
 Get the dynamixel chain object. More...
 
void getTrajectoryParams (HekNorm &eNorm, double &fEpsilon)
 Get trajectory parameters. More...
 
HekRobotJointgetArmJointAt (int index)
 Get robotic joint in arm+ee kinematic chain at the given index. More...
 
HekRobotJointgetArmJoint (const std::string &strName)
 Get robotic joint in arm+ee kinematic chain. More...
 
HekRobotJointgetArmJoint (int nServoId)
 Get robotic joint in arm+ee kinematic chain. More...
 
DynaServo * getMasterServo (HekRobotJoint &joint)
 Get robotic joint's master servo. More...
 
double pctOfMaxJointVelocity (HekRobotJoint &joint, double fVelPct)
 Convert percent of maximum to joint velocity. More...
 

Protected Member Functions

int scanHw ()
 Scan Hekateros hardware and match against description. More...
 
int scanDynaBus (int nMaxTries)
 Scan Hekateros dynamixel bus hardware and match against description. More...
 
int convertSpecs ()
 Convert specification(s) to operational parameters. More...
 
int addRobotJoint (HekSpecJoint_T *pSpecJoint, HekSpecServo_T *pSpecServo, MapRobotJoints &kin, IMapRobotJoints &imap)
 Add a joint to robot's kinematic chain. More...
 
void adjustTuningFromSpecs ()
 Adjust tuning parameters for values in compiled product specifications.
 
void fauxcalibrate ()
 Faux calibrate Hekateros. More...
 
int configServos ()
 Configure Hekateros servos. More...
 
int configEEPROMForAllServos (MapRobotJoints &kin)
 Configure the EEPROM for all Hekateros servos in kinematic chain. More...
 
int configEEPROMForServo (int nServoId, HekRobotJoint &joint)
 Configure one Hekateros servo EEPROM. More...
 
int configRAMForAllServos (MapRobotJoints &kin)
 Configure the RAM for all Hekateros servos in kinematic chain. More...
 
int configRAMForServo (int nServoId, HekRobotJoint &joint)
 Configure one Hekateros servo RAM. More...
 
void resetCalibStateForAllJoints (bool bForceRecalib)
 Mark all relevant joints for recalibration. More...
 
HekOpState determineRobotOpState ()
 Determine robot operational state from collective joint operational states. More...
 
int moveWait (DynaServo *pServo, int nOdGoalPos, int nSpeed)
 Move servo to position. More...
 
void stopWait (const std::vector< std::string > &vecNames, int nMaxTries=10)
 Wait for the specified joints to stop moving. More...
 
void moveWristRot ()
 Move wrist rotation for any necessary final position adjustments. More...
 
void setAllJointGoalsToNull ()
 Set all joint goals to a null trajectory. More...
 
void setJointGoalsToNull (const std::vector< std::string > &vecNames)
 Set a set of joint goals to a null trajectory. More...
 
void setJointGoalToNull (const std::string &strName)
 Set joint goal to null a trajectory. More...
 
int createAsyncThread ()
 Create the asynchronous thread. More...
 
void lock ()
 Lock the robot mutex. More...
 
void unlock ()
 Unlock the robot mutex. More...
 
bool trylock ()
 Try to lock the robot mutex. More...
 

Static Protected Member Functions

static void cbWristRot (void *pUserArg)
 Callback to control wrist rotation. More...
 
static void * asyncThread (void *pArg)
 Asynchronous operation thread. More...
 

Protected Attributes

bool m_bNoExec
 do [not] execute physical movements
 
HekDesc m_descHek
  Hekateros description
 
HekRobotMode m_eRobotMode
 robot operating mode
 
HekOpState m_eOpState
 arm operational state
 
bool m_bIsEStopped
 arm is [not] emergency stopped
 
bool m_bAlarmState
 robot is [not] alarmed
 
bool m_bAreServosPowered
 arm servos are [not] driven
 
bool m_bAtBalancedPos
 arm is [not] at balanced position
 
bool m_bAtParkedPos
 arm is [not] at parked position
 
HekTunes m_tunes
 tune parameters
 
DynaComm * m_pDynaComm
 dynamixel communication
 
DynaChain * m_pDynaChain
 dynamixel chain
 
DynaBgThread * m_pDynaBgThread
 dynamixel background thread
 
MapRobotJoints m_jointsArm
 robot arm + end effector joints
 
MapRobotJoints m_jointsEquipDeck
 robot equipement deck kin. joints
 
MapRobotJoints m_jointsAux
 robot auxiliary kinematic joints
 
IMapRobotJoints m_imapJoints
 joints indirect map
 
HekKinematicsm_pKin
 dynamics and kinematics
 
HekJointTrajectoryPoint m_lastTrajArm
 last trajectory point for arm
 
HekMonitor m_monitor
 power, health, and safety monitor
 
HekAsyncTaskState m_eAsyncTaskState
 asynchronous task state
 
int m_rcAsyncTask
 last async task return code
 
AsyncTaskId m_eAsyncTaskId
 asynchronous task id
 
void * m_pAsyncTaskArg
 asynchronous argument
 
pthread_t m_threadAsync
 async pthread identifier
 
pthread_mutex_t m_mutex
 synchronization mutex
 

Friends

class HekCalib
 
class HekCalibStretch
 

Detailed Description

Hekateros robotic manipulator plus accesories class.

Includes up to 3 kinematic chains.

Definition at line 88 of file hekRobot.h.

Member Typedef Documentation

typedef map<std::string, int> hekateros::HekRobot::IMapRobotJoints

Indirect map of robot joints.

key: joint name
mapped type: master servo id

Definition at line 99 of file hekRobot.h.

Member Enumeration Documentation

enum hekateros::HekRobot::AsyncTaskId

Asynchronous task id.

Enumerator
AsyncTaskIdNone 

no task

AsyncTaskIdCalibrate 

calibrate hekateros arm task id

Definition at line 104 of file hekRobot.h.

105  {
106  AsyncTaskIdNone, ///< no task
107  AsyncTaskIdCalibrate ///< calibrate hekateros arm task id
108 
109  // add others here, as needed
110  };
calibrate hekateros arm task id
Definition: hekRobot.h:107

Constructor & Destructor Documentation

HekRobot::HekRobot ( bool  bNoExec = false)

Default initialization constructor.

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

Definition at line 194 of file hekRobot.cxx.

195 {
196  // state
197  m_bNoExec = bNoExec;
200  m_bIsEStopped = false;
201  m_bAlarmState = false;
202  m_bAreServosPowered = false;
203  m_bAtBalancedPos = false;
204  m_bAtParkedPos = false;
205 
206  // dynamixel i/f
207  m_pDynaComm = NULL;
208  m_pDynaChain = NULL;
209  m_pDynaBgThread = NULL;
210 
211  // asynchronous task control and synchronization
215  m_pAsyncTaskArg = NULL;
216 
217  pthread_mutex_init(&m_mutex, NULL);
218 }
void * m_pAsyncTaskArg
asynchronous argument
Definition: hekRobot.h:715
HekRobotMode m_eRobotMode
robot operating mode
Definition: hekRobot.h:680
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bAtBalancedPos
arm is [not] at balanced position
Definition: hekRobot.h:685
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
bool m_bNoExec
do [not] execute physical movements
Definition: hekRobot.h:678
int m_rcAsyncTask
last async task return code
Definition: hekRobot.h:713
bool m_bAtParkedPos
arm is [not] at parked position
Definition: hekRobot.h:686
fully available
Definition: hekateros.h:510
DynaComm * m_pDynaComm
dynamixel communication
Definition: hekRobot.h:692
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
DynaBgThread * m_pDynaBgThread
dynamixel background thread
Definition: hekRobot.h:694
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: hekRobot.h:714
pthread_mutex_t m_mutex
synchronization mutex
Definition: hekRobot.h:717
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
idle, no async task running
Definition: hekateros.h:528
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682

Member Function Documentation

int HekRobot::addRobotJoint ( HekSpecJoint_T pSpecJoint,
HekSpecServo_T pSpecServo,
MapRobotJoints kin,
IMapRobotJoints imap 
)
protected

Add a joint to robot's kinematic chain.

Parameters
[in]pSpecJointPointer to joint spcecification.
[in]pSpecServoPointer to master servo spcecification.
[out]kinModified kinematics chain of joints.
[out]imapIndirect map of kinematic chain.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1271 of file hekRobot.cxx.

References hekateros::degToRad(), hekateros::fcap(), hekateros::HekSpecServo_T::m_bIsContinuous, hekateros::HekRobotJoint::m_bIsServoContinuous, hekateros::HekRobotJoint::m_bStopAtOptLimits, hekateros::HekRobotJoint::m_byOptLimitMask, hekateros::HekRobotJoint::m_eJointType, hekateros::HekSpecJoint_T::m_eJointType, hekateros::HekRobotJoint::m_eLimitTypes, hekateros::HekSpecJoint_T::m_eLimitTypes, hekateros::HekRobotJoint::m_eOpState, hekateros::HekSpecJoint_T::m_fBalancedPos, hekateros::HekRobotJoint::m_fBalPosRads, hekateros::HekSpecJoint_T::m_fCalibPos, hekateros::HekRobotJoint::m_fCalibPosRads, hekateros::HekRobotJoint::m_fGearRatio, hekateros::HekSpecJoint_T::m_fGearRatio, hekateros::HekRobotJoint::m_fMaxJointRadsPerSec, hekateros::HekSpecJoint_T::m_fMaxPhyLimit, hekateros::HekRobotJoint::m_fMaxPhyLimitRads, hekateros::HekRobotJoint::m_fMaxServoRadsPerSec, hekateros::HekRobotJoint::m_fMaxSoftLimitRads, hekateros::HekSpecJoint_T::m_fMinPhyLimit, hekateros::HekRobotJoint::m_fMinPhyLimitRads, hekateros::HekRobotJoint::m_fMinSoftLimitRads, hekateros::HekRobotJoint::m_fOverTorqueThDft, hekateros::HekSpecJoint_T::m_fParkedPos, hekateros::HekRobotJoint::m_fParkPosRads, hekateros::HekRobotJoint::m_fTicksPerJointRad, hekateros::HekRobotJoint::m_fTicksPerServoRad, hekateros::HekSpecServo_T::m_fTorqueLimitPct, hekateros::HekSpecJoint_T::m_limit, hekateros::HekSpecServo_T::m_nDir, hekateros::HekRobotJoint::m_nMasterServoDir, hekateros::HekRobotJoint::m_nMasterServoId, hekateros::HekSpecJoint_T::m_nMasterServoId, hekateros::HekRobotJoint::m_nMaxPhyLimitOd, hekateros::HekRobotJoint::m_nMaxSoftLimitOd, hekateros::HekRobotJoint::m_nMinPhyLimitOd, hekateros::HekRobotJoint::m_nMinSoftLimitOd, hekateros::HekRobotJoint::m_nSlaveServoId, hekateros::HekSpecJoint_T::m_nSlaveServoId, hekateros::HekRobotJoint::m_strName, hekateros::HekSpecJoint_T::m_strName, M_TAU, and hekateros::HekOpticalLimit_T::m_uBit.

1275 {
1276  int nMasterServoId; // master servo id
1277  DynaServo *pServo; // servo
1278  uint_t uTicks; // ticks
1279  double fAngleMin; // min angle(deg) in servo mode
1280  double fAngleMax; // max angle(deg) in servo mode
1281  double fMaxRpm; // max unloaded rpm
1282  double fDegrees; // working degrees
1283  double fRadians; // working radians
1284  HekRobotJoint joint; // robotic joint
1285  int i; // working index
1286 
1287  // master servo id associated with joint
1288  nMasterServoId = pSpecJoint->m_nMasterServoId;
1289 
1290  // dynamixel servo object in dynamixel chain
1291  if( (pServo = m_pDynaChain->GetServo(nMasterServoId)) == NULL )
1292  {
1293  LOGERROR("Servo %d: Cannot find servo in dynamixel chain.", nMasterServoId);
1294  return -HEK_ECODE_NO_EXEC;
1295  }
1296 
1297  //
1298  // Dynamixel servo specification loaded during scan.
1299  //
1300  uTicks = pServo->GetSpecification().m_uRawPosModulo;
1301  fAngleMin = pServo->GetSpecification().m_fAngleMin;
1302  fAngleMax = pServo->GetSpecification().m_fAngleMax;
1303  fMaxRpm = pServo->GetSpecification().m_fMaxSpeed;
1304 
1305  //
1306  // Servo rotation range.
1307  //
1308  fDegrees = pSpecServo->m_bIsContinuous? 360.0: fAngleMax - fAngleMin;
1309  fRadians = degToRad(fDegrees);
1310 
1311  //
1312  // Populate joint data.
1313  //
1314  // Some data, such as joint rotation limits may be refined during
1315  // calibration.
1316  //
1317  joint.m_strName = pSpecJoint->m_strName;
1318  joint.m_nMasterServoId = nMasterServoId;
1319  joint.m_nSlaveServoId = pSpecJoint->m_nSlaveServoId;
1320  joint.m_bIsServoContinuous = pSpecServo->m_bIsContinuous;
1321  joint.m_nMasterServoDir = pSpecServo->m_nDir;
1322  joint.m_eJointType = pSpecJoint->m_eJointType;
1323  joint.m_fGearRatio = pSpecJoint->m_fGearRatio;
1324  joint.m_fTicksPerServoRad = (double)uTicks / fRadians;
1326  pSpecJoint->m_fGearRatio;
1327  joint.m_fMaxServoRadsPerSec = fMaxRpm * M_TAU / 60.0;
1329  joint.m_fGearRatio;
1330  joint.m_fMinPhyLimitRads = degToRad(pSpecJoint->m_fMinPhyLimit);
1331  joint.m_fMaxPhyLimitRads = degToRad(pSpecJoint->m_fMaxPhyLimit);
1332  joint.m_nMinPhyLimitOd = (int)(joint.m_fTicksPerJointRad *
1333  joint.m_fMinPhyLimitRads);
1334  joint.m_nMaxPhyLimitOd = (int)(joint.m_fTicksPerJointRad *
1335  joint.m_fMaxPhyLimitRads );
1338  joint.m_nMinSoftLimitOd = joint.m_nMinPhyLimitOd;
1339  joint.m_nMaxSoftLimitOd = joint.m_nMaxPhyLimitOd;
1340  joint.m_fCalibPosRads = degToRad(pSpecJoint->m_fCalibPos);
1341  joint.m_fBalPosRads = degToRad(pSpecJoint->m_fBalancedPos);
1342  joint.m_fParkPosRads = degToRad(pSpecJoint->m_fParkedPos);
1343  joint.m_eLimitTypes = pSpecJoint->m_eLimitTypes;
1344 
1345  joint.m_fOverTorqueThDft = fcap(pSpecServo->m_fTorqueLimitPct,
1347  HekTuneOverTorqueThMax) / 100.0;
1348 
1350  joint.m_bStopAtOptLimits = false;
1351 
1352  for(i=0; i<HekOptLimitMaxPerJoint; ++i)
1353  {
1354  joint.m_byOptLimitMask[i] = pSpecJoint->m_limit[i].m_uBit;
1355  }
1356 
1357  //
1358  // Sanity checks.
1359  //
1360  joint.m_fCalibPosRads = fcap(joint.m_fCalibPosRads,
1361  joint.m_fMinPhyLimitRads,
1362  joint.m_fMaxPhyLimitRads);
1363  joint.m_fBalPosRads = fcap(joint.m_fBalPosRads,
1364  joint.m_fMinPhyLimitRads,
1365  joint.m_fMaxPhyLimitRads);
1366  joint.m_fParkPosRads = fcap(joint.m_fParkPosRads,
1367  joint.m_fMinPhyLimitRads,
1368  joint.m_fMaxPhyLimitRads);
1369 
1370  //
1371  // Add to kinematic chain.
1372  //
1373  kin[nMasterServoId] = joint; // kinematic chain
1374  imap[joint.m_strName] = nMasterServoId; // indirect map by joint name
1375 
1376  return HEK_OK;
1377 }
int m_nSlaveServoId
linked slave servo id (if any)
Definition: hekJoint.h:151
int m_nSlaveServoId
linked slave servo id, if any
Definition: hekSpec.h:176
double m_fCalibPos
joint calibrated position (degrees)
Definition: hekSpec.h:184
HekOpticalLimit_T m_limit[HekOptLimitMaxPerJoint]
optical limits
Definition: hekSpec.h:182
std::string m_strName
joint name
Definition: hekSpec.h:174
int m_nMaxSoftLimitOd
joint max soft limit (odometer ticks)
Definition: hekJoint.h:169
byte_t m_uBit
i/o expander bit position
Definition: hekOptical.h:177
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
HekOpState m_eOpState
current operational state
Definition: hekJoint.h:179
double m_fMinSoftLimitRads
joint min soft limit (radians)
Definition: hekJoint.h:166
int m_eLimitTypes
joint limit types
Definition: hekJoint.h:173
double m_fBalancedPos
joint balanced position (degrees)
Definition: hekSpec.h:185
Operational robotic joint description class.
Definition: hekJoint.h:80
double m_fGearRatio
joint gear ratio
Definition: hekSpec.h:178
double m_fTicksPerJointRad
encoder/odom. ticks per joint radian
Definition: hekJoint.h:157
double m_fTicksPerServoRad
encoder/odom. ticks per servo radian
Definition: hekJoint.h:156
double m_fMaxServoRadsPerSec
maximum servo radians per second
Definition: hekJoint.h:158
int m_eJointType
joint type
Definition: hekJoint.h:154
static const int HEK_ECODE_NO_EXEC
cannot execute error
Definition: hekateros.h:84
double m_fMaxJointRadsPerSec
maximum joint radians per second
Definition: hekJoint.h:159
#define M_TAU
tau = 2 * pi
Definition: hekUtils.h:67
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: hekUtils.h:163
bool m_bIsContinuous
servo should [not] be configured in 360 mode
Definition: hekSpec.h:219
int m_nMinPhyLimitOd
joint min phys limit (odometer ticks)
Definition: hekJoint.h:164
int m_nMasterServoId
master servo id
Definition: hekJoint.h:150
double m_fTorqueLimitPct
torque limit(%). Set to 0 for no limit
Definition: hekSpec.h:221
double m_fParkPosRads
joint parked position (radians)
Definition: hekJoint.h:172
int m_eLimitTypes
joint limit types
Definition: hekSpec.h:181
double m_fCalibPosRads
joint calibrated position (radians)
Definition: hekJoint.h:170
double m_fMinPhyLimitRads
joint min physical limit (radians)
Definition: hekJoint.h:162
bool m_bIsServoContinuous
servo should [not] be continuous mode
Definition: hekJoint.h:152
int m_nMinSoftLimitOd
joint min soft limit (odometer ticks)
Definition: hekJoint.h:168
double m_fMinPhyLimit
joint minimum physical limit (degrees)
Definition: hekSpec.h:179
int m_nMaxPhyLimitOd
joint max phys limit (odometer ticks)
Definition: hekJoint.h:165
byte_t m_byOptLimitMask[HekOptLimitMaxPerJoint]
optical limit mask array
Definition: hekJoint.h:175
bool m_bStopAtOptLimits
do [not] stop at optical limits
Definition: hekJoint.h:180
int m_nMasterServoId
master servo id
Definition: hekSpec.h:175
double m_fParkedPos
joint parked position (degrees)
Definition: hekSpec.h:186
int m_nDir
normalize cw/ccw direction.
Definition: hekSpec.h:220
double m_fMaxPhyLimit
joint maximum physical limit (degrees)
Definition: hekSpec.h:180
std::string m_strName
joint name
Definition: hekJoint.h:149
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
static const int HekOptLimitMaxPerJoint
max limits/joint
Definition: hekOptical.h:120
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
double m_fMaxSoftLimitRads
joint max soft limit (radians)
Definition: hekJoint.h:167
int m_eJointType
joint type
Definition: hekSpec.h:177
double m_fBalPosRads
joint balanced position (radians)
Definition: hekJoint.h:171
static const double HekTuneOverTorqueThMin
Minimum joint over torque threshold (% of maximum)
Definition: hekTune.h:143
int m_nMasterServoDir
master servo normalized direction
Definition: hekJoint.h:153
double m_fGearRatio
joint gear ratio
Definition: hekJoint.h:155
double m_fMaxPhyLimitRads
joint max physical limit (radians)
Definition: hekJoint.h:163
static const double HekTuneOverTorqueThMax
Maximum joint over torque threshold (% of maximum)
Definition: hekTune.h:148
double m_fOverTorqueThDft
joint over torque th default (norm).
Definition: hekJoint.h:174
int hekateros::HekRobot::areServosPowered ( )
inline

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

Returns
Returns true or false.

Definition at line 528 of file hekRobot.h.

References m_bAreServosPowered.

529  {
530  return m_bAreServosPowered;
531  }
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
void * HekRobot::asyncThread ( void *  pArg)
staticprotected

Asynchronous operation thread.

Parameters
pArgThread argument (point to HekRobot object).
Returns
Returns NULL on thread exit.

Definition at line 1709 of file hekRobot.cxx.

References calibrate(), m_eAsyncTaskId, m_eAsyncTaskState, m_pAsyncTaskArg, and m_rcAsyncTask.

1710 {
1711  HekRobot *pThis = (HekRobot *)pArg;
1712  int oldstate;
1713  int rc;
1714 
1715  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
1716  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
1717  //pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldstate);
1718 
1719  LOGDIAG3("Async robot task thread created.");
1720 
1721  //
1722  // Execute asychronous task.
1723  //
1724  // For now, only calibrate task is supported asynchronously.
1725  //
1726  switch( pThis->m_eAsyncTaskId )
1727  {
1728  // Calibrate the robot.
1729  case AsyncTaskIdCalibrate:
1730  {
1731  bool bForceRecalib = (bool)pThis->m_pAsyncTaskArg;
1732  rc = pThis->calibrate(bForceRecalib);
1733  }
1734  break;
1735 
1736  // Unknown task id.
1737  default:
1738  LOGERROR("Unknown async task id = %d.", (int)pThis->m_eAsyncTaskId);
1739  rc = -HEK_ECODE_BAD_VAL;
1740  break;
1741  }
1742 
1744  pThis->m_pAsyncTaskArg = NULL;
1745  pThis->m_rcAsyncTask = rc;
1747 
1748  LOGDIAG3("Async robot task thread exited.");
1749 
1750  return NULL;
1751 }
void * m_pAsyncTaskArg
asynchronous argument
Definition: hekRobot.h:715
int m_rcAsyncTask
last async task return code
Definition: hekRobot.h:713
calibrate hekateros arm task id
Definition: hekRobot.h:107
int calibrate(bool bForceRecalib=true)
Calibrate <b><i>Hekateros</i></b>&#39;s odometers and limit switch positions.
Definition: hekRobot.cxx:436
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: hekRobot.h:714
Hekateros robotic manipulator plus accesories class.
Definition: hekRobot.h:88
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
static const int HEK_ECODE_BAD_VAL
bad value general error
Definition: hekateros.h:75
idle, no async task running
Definition: hekateros.h:528
int HekRobot::calibrate ( bool  bForceRecalib = true)

Calibrate Hekateros's odometers and limit switch positions.

Parameters
bForceRecalibIf true, recalibrate all joints. Otherwise calibrate only the uncalibrated.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 436 of file hekRobot.cxx.

References hekateros::HekCalibStretch::calibrate(), HEK_TRY_CONN, and HEK_TRY_NO_EXEC.

Referenced by asyncThread().

437 {
438  HekCalibStretch calib(*this);
439  int rc;
440 
441  HEK_TRY_NO_EXEC();
442  HEK_TRY_CONN();
443 
444  // lock the arm
445  freeze();
446 
447  // robot is now uncalibrated
449 
450  // mark relevant joints for recalibration
451  resetCalibStateForAllJoints(bForceRecalib);
452 
453  // robot calibration started
455 
456  // now physically calibrate the arm
457  if( (rc = calib.calibrate()) < 0 )
458  {
459  LOGERROR("Failed to calibrate Hekateros.");
461  return rc;
462  }
463 
464  //
465  // Should be all calibrated at this point.
466  //
467 
468  // synchronize robot operation state to collective joint operational states
470  {
471  LOGERROR("BUG: Failed to calibrate Hekateros.");
472  return -HEK_ECODE_INTERNAL;
473  }
474 
475  // arm is calibrated
476  gotoZeroPtPos();
477 
478  LOGDIAG1("Hekateros calibrated.");
479 
480  return HEK_OK;
481 }
Hekateros robotic manipulator calibration by stretching class.
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
#define HEK_TRY_NO_EXEC()
Define if heketeros has RN system board.
Definition: hekRobot.cxx:100
int freeze()
Freeze arm and accessories at current position.
Definition: hekRobot.cxx:794
static const int HEK_ECODE_INTERNAL
internal error (bug)
Definition: hekateros.h:74
HekOpState determineRobotOpState()
Determine robot operational state from collective joint operational states.
Definition: hekRobot.cxx:1620
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
int gotoZeroPtPos()
Move robotic arm to its pre-defined calibrated zero point position.
Definition: hekRobot.cxx:643
void resetCalibStateForAllJoints(bool bForceRecalib)
Mark all relevant joints for recalibration.
Definition: hekRobot.cxx:1607
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
int HekRobot::calibrateAsync ( bool  bForceRecalib = true)

Asynchronously calibrate Hekateros's odometers and limit switch positions.

Call cancelAsync() to cancel operation.

Parameters
bForceRecalibIf true, recalibrate all joints. Otherwise calibrate only the uncalibrated.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 483 of file hekRobot.cxx.

484 {
486  {
487  LOGERROR("Already executing asynchronous task.");
488  return -HEK_ECODE_NO_RSRC;
489  }
490  else
491  {
493  m_pAsyncTaskArg = (void *)bForceRecalib;
494 
495  return createAsyncThread();
496  }
497 }
void * m_pAsyncTaskArg
asynchronous argument
Definition: hekRobot.h:715
int createAsyncThread()
Create the asynchronous thread.
Definition: hekRobot.cxx:1635
calibrate hekateros arm task id
Definition: hekRobot.h:107
static const int HEK_ECODE_NO_RSRC
no resource available error
Definition: hekateros.h:82
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: hekRobot.h:714
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
idle, no async task running
Definition: hekateros.h:528
void HekRobot::cancelAsyncTask ( )

Cancel any asynchronous task.

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

Definition at line 1662 of file hekRobot.cxx.

Referenced by setRobotMode().

1663 {
1664  MapRobotJoints::iterator iter;
1665 
1667  {
1668  // cancel thread
1669  pthread_cancel(m_threadAsync);
1670  pthread_join(m_threadAsync, NULL);
1671 
1672  // cleanup
1673  switch( m_eAsyncTaskId )
1674  {
1675  case AsyncTaskIdCalibrate:
1676  freeze();
1677  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
1678  {
1679  if( iter->second.m_eOpState != HekOpStateCalibrated )
1680  {
1681  iter->second.m_eOpState = HekOpStateUncalibrated;
1683  }
1684  }
1685  break;
1686  default:
1687  break;
1688  }
1689 
1690  // clear state
1692  m_pAsyncTaskArg = NULL;
1695  LOGDIAG3("Async task canceled.");
1696  }
1697 }
void * m_pAsyncTaskArg
asynchronous argument
Definition: hekRobot.h:715
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
int m_rcAsyncTask
last async task return code
Definition: hekRobot.h:713
calibrate hekateros arm task id
Definition: hekRobot.h:107
static const int HEK_ECODE_INTR
operation interrupted
Definition: hekateros.h:93
int freeze()
Freeze arm and accessories at current position.
Definition: hekRobot.cxx:794
pthread_t m_threadAsync
async pthread identifier
Definition: hekRobot.h:716
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: hekRobot.h:714
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
idle, no async task running
Definition: hekateros.h:528
static void hekateros::HekRobot::cbWristRot ( void *  pUserArg)
staticprotected

Callback to control wrist rotation.

The wrist rotation is coupled to wrist pitch.

Parameters
pUserArgPoint to this.
int HekRobot::clearAlarms ( )

Attempt to clear all servo alarms in all kinematic chains.

Note
Not all alarms are clearable (e.g. temperature).
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 847 of file hekRobot.cxx.

References HEK_TRY_CONN.

848 {
849  int iter; // servo iterator
850  int nServoId; // servo id
851  DynaServo *pServo; // servo
852 
853  HEK_TRY_CONN();
854 
855  release();
856 
857  //
858  // Try to clear alarms for all servos.
859  //
860  for(nServoId = m_pDynaChain->IterStart(&iter);
861  nServoId != DYNA_ID_NONE;
862  nServoId = m_pDynaChain->IterNext(&iter))
863  {
864  pServo = m_pDynaChain->GetServo(nServoId);
865 
866  // over torque alarm zero's torque limit - reload from EEPROM
867  pServo->ReloadMaxTorqueLimit();
868  }
869 
870  //
871  // Clear hekateros alarm led to provide visual feedback to the user. The
872  // background check may relight the alarm led if alarms still persist.
873  //
874  m_bAlarmState = false;
876 
877  return HEK_OK;
878 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
int release()
Release arm and accessories.
Definition: hekRobot.cxx:812
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
void markAlarmCond(bool bAlarmedCond)
Mark alarm condition.
Definition: hekMonitor.cxx:396
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
int HekRobot::closeGripper ( )

Close gripper to its minimum closed position.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 739 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryPoint::append(), hekateros::degToRad(), HEK_TRY_CALIB, HEK_TRY_CONN, HEK_TRY_NOT_ESTOP, hekateros::HekRobotJoint::m_fMinSoftLimitRads, and hekateros::HekRobotJoint::m_strName.

740 {
741  HekJointTrajectoryPoint trajPoint;
742 
743  HekRobotJoint *pJoint;
744  int rc;
745 
746  HEK_TRY_CONN();
747  HEK_TRY_CALIB();
749 
750  if( (pJoint = getArmJoint(HekServoIdGraboid)) == NULL )
751  {
752  LOGERROR("No gripper end effector found.");
753  return -HEK_ECODE_NO_RSRC;
754  }
755 
756  trajPoint.append(pJoint->m_strName, pJoint->m_fMinSoftLimitRads,
757  degToRad(60.0));
758 
759  if( (rc = moveArm(trajPoint)) < 0 )
760  {
761  LOGERROR("Move to pre-defined gripper closed position failed.");
762  }
763  else
764  {
765  LOGDIAG2("Hekateros gripper closed.");
766  }
767 
768  return rc;
769 }
HekRobotJoint * getArmJoint(const std::string &strName)
Get robotic joint in arm+ee kinematic chain.
Definition: hekRobot.h:610
double m_fMinSoftLimitRads
joint min soft limit (radians)
Definition: hekJoint.h:166
Joint trajectory point class.
Definition: hekTraj.h:180
Operational robotic joint description class.
Definition: hekJoint.h:80
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
static const int HEK_ECODE_NO_RSRC
no resource available error
Definition: hekateros.h:82
std::string m_strName
joint name
Definition: hekJoint.h:149
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
void append(const std::string &strName, double fPosition, double fVelocity, double fAcceleration=0.0)
Append joint point to end of trajectory.
Definition: hekTraj.h:264
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
static const int HekServoIdGraboid
graboid
Definition: hekateros.h:272
int moveArm(HekJointTrajectoryPoint &trajectoryPoint)
Move arm through trajectory point.
Definition: hekRobot.cxx:880
int HekRobot::configEEPROMForAllServos ( MapRobotJoints kin)
protected

Configure the EEPROM for all Hekateros servos in kinematic chain.

For each servo, ensure that the proper servo EEPROM values are set.

Parameters
kinKinematic chain of joints.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1430 of file hekRobot.cxx.

1431 {
1432  MapRobotJoints::iterator iter;
1433 
1434  int nServoId;
1435  int rc;
1436 
1437  for(iter = kin.begin(); iter != kin.end(); ++iter)
1438  {
1439  nServoId = iter->second.m_nMasterServoId;
1440 
1441  if( (rc = configEEPROMForServo(nServoId, iter->second)) < 0 )
1442  {
1443  LOGERROR("Servo %d: Failed to configure servo EEPROM memory map.",
1444  nServoId);
1445  return rc;
1446  }
1447 
1448  nServoId = iter->second.m_nSlaveServoId;
1449 
1450  if( nServoId != DYNA_ID_NONE )
1451  {
1452  if( (rc = configEEPROMForServo(nServoId, iter->second)) < 0 )
1453  {
1454  LOGERROR("Servo %d: Failed to configure servo EEPROM memory map.",
1455  nServoId);
1456  return rc;
1457  }
1458  }
1459  }
1460 
1461  return HEK_OK;
1462 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
int configEEPROMForServo(int nServoId, HekRobotJoint &joint)
Configure one <b><i>Hekateros</i></b> servo EEPROM.
Definition: hekRobot.cxx:1464
int HekRobot::configEEPROMForServo ( int  nServoId,
HekRobotJoint joint 
)
protected

Configure one Hekateros servo EEPROM.

A read, then write if necessary is performed to limit EEPROM wear.

Note
System reads, writes, and sleeps are pthread cancelation points.
Parameters
nServoIdServo id.
jointAssociated robotic joint.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1464 of file hekRobot.cxx.

References HEK_TRY_GET_SERVO, and hekateros::HekRobotJoint::m_bIsServoContinuous.

1465 {
1466  DynaServo *pServo;
1467  uint_t uPosMin;
1468  uint_t uPosMax;
1469  uint_t uTorqueMax;
1470  uint_t uVal;
1471  uint_t uMask;
1472  int rc;
1473 
1474  // dynamixel servo object in dynamixel chain
1475  HEK_TRY_GET_SERVO(nServoId, pServo);
1476 
1477  uPosMin = pServo->GetSpecification().m_uRawPosMin;
1478  uPosMax = pServo->GetSpecification().m_uRawPosMax;
1479  uTorqueMax = pServo->GetSpecification().m_uRawTorqueMax;
1480 
1481  // --
1482  // Ensure servo is in the correct servo mode.
1483  // --
1484 
1485  // get servo must be in continuous mode
1486  if( joint.m_bIsServoContinuous &&
1487  (pServo->GetServoMode() != DYNA_MODE_CONTINUOUS))
1488  {
1489  if( (rc = pServo->CfgWriteServoModeContinuous()) < 0 )
1490  {
1491  LOGERROR("Servo %d: Cannot configure EEPROM for continuous mode.",
1492  nServoId);
1493  return -HEK_ECODE_DYNA;
1494  }
1495  }
1496 
1497  // servo must be in servo mode
1498  else if( !joint.m_bIsServoContinuous &&
1499  (pServo->GetServoMode() == DYNA_MODE_CONTINUOUS) )
1500  {
1501  if( (rc = pServo->CfgWriteServoMode(uPosMin, uPosMax)) < 0 )
1502  {
1503  LOGERROR("Servo %d: Cannot configure EEPROM for servo mode.", nServoId);
1504  return -HEK_ECODE_DYNA;
1505  }
1506  }
1507 
1508  // --
1509  // Ensure maximum torque limit reload value is at the maximum.
1510  // --
1511 
1512  // always set maximum torque limit
1513  if( (rc = pServo->CfgReadMaxTorqueLimit(&uVal)) < 0 )
1514  {
1515  LOGWARN("Servo %d: Cannot read EEPROM maximum torque limit.", nServoId);
1516  }
1517  else if( uVal < uTorqueMax )
1518  {
1519  if( (rc = pServo->CfgWriteMaxTorqueLimit(uTorqueMax)) < 0 )
1520  {
1521  LOGWARN("Servo %d: Cannot configure EEPROM maximum torque limit.",
1522  nServoId);
1523  }
1524  }
1525 
1526  // --
1527  // Ensure alarm shutdown mask as the correct values.
1528  // --
1529 
1530  // for servos with no torque limit, disable over-load alarms
1531  uMask = DYNA_ALARM_VOLTAGE | DYNA_ALARM_ANGLE | DYNA_ALARM_TEMP |
1532  DYNA_ALARM_LOAD;
1533 
1534  if( (rc = pServo->CfgReadAlarmShutdownMask(&uVal)) < 0 )
1535  {
1536  LOGWARN("Servo %d: Cannot read EEPROM alarm shutdown mask.", nServoId);
1537  }
1538  else if( uVal != uMask )
1539  {
1540  if( (rc = pServo->CfgWriteAlarmShutdownMask(uMask)) < 0 )
1541  {
1542  LOGWARN("Servo %d: Cannot configure EEPROM alarm shutdown mask.",
1543  nServoId);
1544  }
1545  }
1546 
1547  return HEK_OK;
1548 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bIsServoContinuous
servo should [not] be continuous mode
Definition: hekJoint.h:152
static const int HEK_ECODE_DYNA
dynamixel error
Definition: hekateros.h:86
#define HEK_TRY_GET_SERVO(nServoId, pServo)
Convenience macro for trying to get a servo object from dynamixel chain.
Definition: hekRobot.cxx:124
int HekRobot::configRAMForAllServos ( MapRobotJoints kin)
protected

Configure the RAM for all Hekateros servos in kinematic chain.

For each servo, ensure that the proper servo RAM values are set.

Parameters
kinKinematic chain of joints.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1550 of file hekRobot.cxx.

1551 {
1552  MapRobotJoints::iterator iter;
1553  int nServoId;
1554  int rc;
1555 
1556  for(iter = kin.begin(); iter != kin.end(); ++iter)
1557  {
1558  nServoId = iter->second.m_nMasterServoId;
1559 
1560  if( (rc = configRAMForServo(nServoId, iter->second)) < 0 )
1561  {
1562  LOGERROR("Servo %d: Failed to configure servo RAM memory map.",
1563  nServoId);
1564  return rc;
1565  }
1566 
1567 
1568  // no slave configuration
1569  }
1570 
1571  return HEK_OK;
1572 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
int configRAMForServo(int nServoId, HekRobotJoint &joint)
Configure one <b><i>Hekateros</i></b> servo RAM.
Definition: hekRobot.cxx:1574
int HekRobot::configRAMForServo ( int  nServoId,
HekRobotJoint joint 
)
protected

Configure one Hekateros servo RAM.

Note
System reads, writes, and sleeps are pthread cancelation points.
Parameters
nServoIdServo id.
jointAssociated robotic joint.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1574 of file hekRobot.cxx.

References HEK_TRY_GET_SERVO.

1575 {
1576  DynaServo *pServo;
1577  uint_t uTorqueMax;
1578  int rc;
1579 
1580  // get dynamixel servo object in dynamixel chain
1581  HEK_TRY_GET_SERVO(nServoId, pServo);
1582 
1583  uTorqueMax = pServo->GetSpecification().m_uRawTorqueMax;
1584 
1585  // --
1586  // Ensure running torque limit is at the maximum.
1587  // --
1588 
1589  if( (rc = pServo->WriteMaxTorqueLimit(uTorqueMax)) < 0 )
1590  {
1591  LOGWARN("Servo %d: Cannot write RAM alarm shutdown mask.", nServoId);
1592  }
1593 
1594  // --
1595  // Disable servo drive on start up.
1596  // --
1597 
1598  if( (rc = pServo->WriteTorqueEnable(false)) < 0 )
1599  {
1600  LOGERROR("Servo %d: Cannot enable servo drive.", nServoId);
1601  return -HEK_ECODE_DYNA;
1602  }
1603 
1604  return HEK_OK;
1605 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_DYNA
dynamixel error
Definition: hekateros.h:86
#define HEK_TRY_GET_SERVO(nServoId, pServo)
Convenience macro for trying to get a servo object from dynamixel chain.
Definition: hekRobot.cxx:124
int HekRobot::configServos ( )
protected

Configure Hekateros servos.

Each servo's EEPROM and RAM control tables must match the joint descriptions.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1411 of file hekRobot.cxx.

1412 {
1413  int rc;
1414 
1415  if( (rc = configEEPROMForAllServos(m_jointsArm)) < 0 )
1416  {
1417  LOGERROR("Failed to configure servo EEPROM for all servos.");
1418  return rc;
1419  }
1420 
1421  if( (rc = configRAMForAllServos(m_jointsArm)) < 0 )
1422  {
1423  LOGERROR("Failed to configure servo RAM for all servos.");
1424  return rc;
1425  }
1426 
1427  return HEK_OK;
1428 }
int configEEPROMForAllServos(MapRobotJoints &kin)
Configure the EEPROM for all <b><i>Hekateros</i></b> servos in kinematic chain.
Definition: hekRobot.cxx:1430
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
int configRAMForAllServos(MapRobotJoints &kin)
Configure the RAM for all <b><i>Hekateros</i></b> servos in kinematic chain.
Definition: hekRobot.cxx:1550
int HekRobot::connect ( const std::string &  strDevDynabus = HekDevDynabus,
int  nBaudRateDynabus = HekBaudRateDynabus,
const std::string &  strDevArduino = HekDevArduino,
int  nBaudRateArduino = HekBaudRateArduino 
)

Connect to Hekateros.

Parameters
strDevDynabusDynabus serial device name.
nBaudRateDynabusDynabus baud rate.
strDevArduinoArduino serial device name.
nBaudRateArduinoArduino baud rate.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 226 of file hekRobot.cxx.

References hekateros::getRealDeviceName(), and hekateros::HekXmlTune::load().

228 {
229  string strDevName; // real device name
230  int rc; // return code
231 
232  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
233  // Pre-connect requirements.
234  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
235 
236  //
237  // Need a robot description before preceeding. The controlling application,
238  // typically a ROS node, provides the description. The desription is normally
239  // the parsed data found in /etc/hekaeros/hekateros.conf.
240  //
241  if( !m_descHek.isDescribed() )
242  {
243  LOGERROR("Undefined Hekateros description - "
244  "don't know how to initialized properly.");
245  return -HEK_ECODE_BAD_OP;
246  }
247 
248 
249  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
250  // Dynabus communication and configuration.
251  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
252 
253  // get the real device name, not a symbolic link
254  strDevName = getRealDeviceName(strDevDynabus);
255 
256  // open (proxied) serial device to dynamixel bus
257  m_pDynaComm = DynaComm::New(strDevName.c_str(), nBaudRateDynabus);
258 
259  if( m_pDynaComm == NULL )
260  {
261  LOGERROR("Failed to create dynamixel interface on '%s'@%d.",
262  strDevName.c_str(), nBaudRateDynabus);
263  return -HEK_ECODE_DYNA;
264  }
265  LOGDIAG2("Created dynamixel interface on '%s'@%d.",
266  strDevName.c_str(), nBaudRateDynabus);
267 
268  // create dynamixel bus chain
269  m_pDynaChain = new DynaChain(*m_pDynaComm);
270 
271  // scan Dynabus for all attached servos
272  if( (rc = scanDynaBus(3)) < 0 )
273  {
274  LOGERROR("Hekateros dynamixel bus scan failed.");
275  disconnect();
276  return rc;
277  }
278  LOGDIAG2("Scanned for servos.");
279 
280  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
281  // Build specifications, set tuning parameters, and configure.
282  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
283 
284  //
285  // Convert fixed specifications to joint operation descriptions. The
286  // specifications are compliled-in, product-specific link, joint, servo data.
287  //
288  // Required: product descriptions, scanned servos, and monitor object.
289  //
290  if( (rc = convertSpecs()) < 0 )
291  {
292  LOGERROR("Failed to convert product specifications to "
293  "operations parameters.");
294  disconnect();
295  return rc;
296  }
297  LOGDIAG2("Converted product specifications to operations parameters.");
298 
299  //
300  // Adjust tuning parameters from any defaults specified in the converted
301  // joint descriptions.
302  //
303  // Required: joint descriptions and tuning paramaters.
304  //
306 
307  //
308  // Override any tuning parameters from the optional, user-specified tuning
309  // XML file.
310  //
311  HekXmlTune xml;
312 
313  // parse tune XML file and set tuning parameter overrides
315 
316  //
317  // Configure servos EEPROM and RAM control tables for operation.
318  //
319  // Required: joint descriptions and scanned servos.
320  //
321  configServos();
322 
323  //
324  // Mark all joints for calibration.
325  //
327 
328 
329  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
330  // Kinodynmics thread.
331  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
332 
333  // create active dynamics and kinematics chain
334  m_pKin = new HekKinematics(*m_pDynaChain, m_jointsArm, m_tunes);
335 
336  // run kinematics thread at the given Hertz
338 
339  LOGDIAG2("Kinematics thread started.");
340 
341  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
342  // Health and safety monitoring thread.
343  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
344 
345  // get the real device name, not a symbolic link
346  strDevName = getRealDeviceName(strDevArduino);
347 
348  // open all interfaces to monitoring hardware and create monitoring thread
349  if( (rc = m_monitor.open(getVersionNum(), strDevName, nBaudRateArduino)) < 0 )
350  {
351  LOGERROR("Hekateros monitor interface failed to open on '%s'@%d.",
352  strDevName.c_str(), nBaudRateArduino);
353  disconnect();
354  return rc;
355  }
356  LOGDIAG2("Hekateros monitor interface open on '%s'@%d.",
357  strDevName.c_str(), nBaudRateArduino);
358 
359  m_bAlarmState = false;
360  m_monitor.markAlarmCond(m_bAlarmState);
361 
362  // add chain to monitor
363  m_monitor.addServoChainToMonitor(m_pDynaChain);
364 
365  // add kinematics to monitor
367 
368  // start robot monitoring health and safety thread
369  m_monitor.start();
370 
371  LOGDIAG2("Monitor thread started.");
372 
373 
374  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
375  // Final touches
376  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
377 
378  LOGDIAG1("Connected to Hekateros.");
379 
380  //
381  // DBG DANGER, WILL ROBINSON
382  //
383  // Uncomment the next line to circumvent calibration step. Make sure arm
384  // is at the zero point.
385  //
386  //fauxcalibrate();
387  //
388  // DBG DANGER, WILL ROBINSON
389  //
390 
391  return HEK_OK;
392 }
const char *const HekSysCfgPath
System configuration search path.
Definition: hekateros.h:322
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
void adjustTuningFromSpecs()
Adjust tuning parameters for values in compiled product specifications.
Definition: hekRobot.cxx:1379
int scanDynaBus(int nMaxTries)
Scan <b><i>Hekateros</i></b> dynamixel bus hardware and match against description.
Definition: hekRobot.cxx:1090
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
static const int HEK_ECODE_BAD_OP
invalid operation error
Definition: hekateros.h:79
HekTunes m_tunes
tune parameters
Definition: hekRobot.h:689
void addServoChainToMonitor(DynaChain *pDynaChain)
Add servo chain to monitor for alarms and health.
Definition: hekMonitor.h:205
void addKinematicsToMonitor(HekKinematics *pKin)
Add kinematics for safety control.
Definition: hekMonitor.h:232
int runThread(const double fHz=HekTuneKinHzDft)
Run the kinematics thread.
Definition: hekKin.cxx:871
HekXmlTune <b><i>Hekateros</i></b> XML tuning class.
Definition: hekXmlTune.h:72
DynaComm * m_pDynaComm
dynamixel communication
Definition: hekRobot.h:692
const char *const HekEtcTune
xml tune file
Definition: hekateros.h:343
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
static const int HEK_ECODE_DYNA
dynamixel error
Definition: hekateros.h:86
int configServos()
Configure <b><i>Hekateros</i></b> servos.
Definition: hekRobot.cxx:1411
void markAlarmCond(bool bAlarmedCond)
Mark alarm condition.
Definition: hekMonitor.cxx:396
double getKinematicsHz() const
Get kinematics thread cycle rate tune parameter (hertz).
Definition: hekTune.h:441
uint_t getVersionNum()
Get the <b><i>Hekateros</i></b> robotic arm hardware version compact number.
Definition: hekRobot.h:434
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
int open(uint_t uHekHwVer, const std::string &strDevArduino=HekDevArduino, int nBaudRateArduino=HekBaudRateArduino)
Open resources to monitor hardware.
Definition: hekMonitor.cxx:216
std::string getRealDeviceName(const std::string &strDevName)
Get real device name.
virtual int load(HekTunes &tunes, const std::string &strSearchPath=HekSysCfgPath, const std::string &strXmlFileName=HekEtcTune, bool bAllInstances=false)
Load XML file into DOM and set the <b><i>Hekateros</i></b> tuning parameters.
Definition: hekXmlTune.cxx:72
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int start(double fHz=30.0)
Start monitoring added objects.
Definition: hekMonitor.cxx:290
int convertSpecs()
Convert specification(s) to operational parameters.
Definition: hekRobot.cxx:1175
int disconnect()
Disconnect from <b><i>Hekateros</i></b>.
Definition: hekRobot.cxx:394
bool isDescribed()
Test if required descriptions are described.
Definition: hekDesc.h:165
void resetCalibStateForAllJoints(bool bForceRecalib)
Mark all relevant joints for recalibration.
Definition: hekRobot.cxx:1607
int HekRobot::convertSpecs ( )
protected

Convert specification(s) to operational parameters.

The specifications must be defined and the connecton to the Hekateros hardware must be open.

There are up to 3 kinematic chains, given the specifications and the hardware:

  • arm + end effector
  • equipment deck effector
  • auxiliary effector
Note
A kinematic chain differs from the dynamixel chain. Hekateros supports one dynamixel bus in which all servos hang. A dynamixel chain defines this communication bus. Servos on the bus can be associated with any of the above three kinematic chains.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1175 of file hekRobot.cxx.

References hekateros::HekSpec::getJointSpecAt(), hekateros::HekSpec::getServoSpec(), hekateros::HekSpec::m_nDoF, hekateros::HekSpecJoint_T::m_nMasterServoId, hekateros::HekDescEE::m_spec, and hekateros::HekDescArm::m_spec.

1176 {
1177  HekDescArm *pDescArm;
1178  HekDescEE *pDescEE;
1179  HekSpecJoint_T *pSpecJoint;
1180  HekSpecServo_T *pSpecServo;
1181  int nServoId;
1182  HekRobotJoint *pJoint;
1183  int i;
1184  int rc;
1185 
1186  m_jointsArm.clear();
1187  m_jointsEquipDeck.clear();
1188  m_jointsAux.clear();
1189  m_imapJoints.clear();
1190 
1191  pDescArm = m_descHek.getArmDesc();
1192  pDescEE = m_descHek.getEEDesc();
1193 
1194  //
1195  // Build up arm kinematic chain.
1196  //
1197  for(i = 0; i < pDescArm->m_spec.m_nDoF; ++i)
1198  {
1199  // joint specification
1200  pSpecJoint = pDescArm->m_spec.getJointSpecAt(i);
1201 
1202  // master servo id associated with joint
1203  nServoId = pSpecJoint->m_nMasterServoId;
1204  pJoint = &m_jointsArm[nServoId];
1205 
1206  // servo specification
1207  if( (pSpecServo = pDescArm->m_spec.getServoSpec(nServoId)) == NULL )
1208  {
1209  LOGERROR("Servo %d: Cannot find servo specification.", nServoId);
1210  return -HEK_ECODE_NO_EXEC;
1211  }
1212 
1213  // add rebotic joint
1214  rc = addRobotJoint(pSpecJoint, pSpecServo, m_jointsArm, m_imapJoints);
1215  if( rc < 0 )
1216  {
1217  LOGERROR("Servo %d: Cannot add to kinematic chain.", nServoId);
1218  return rc;
1219  }
1220 
1221  // add any optical limit switches
1222  if( (rc = m_monitor.addJointLimitsToMonitor(pSpecJoint, pJoint)) < 0 )
1223  {
1224  LOGERROR("Servo %d: Cannot add to optical limit(s).", nServoId);
1225  return rc;
1226  }
1227  }
1228 
1229  //
1230  // Add end effector joints to arm kinematic chain.
1231  //
1232  for(i = 0; i < pDescEE->m_spec.m_nDoF; ++i)
1233  {
1234  // joint specification
1235  pSpecJoint = pDescEE->m_spec.getJointSpecAt(i);
1236 
1237  // master servo id associated with joint
1238  nServoId = pSpecJoint->m_nMasterServoId;
1239  pJoint = &m_jointsArm[nServoId];
1240 
1241  // servo specification
1242  if( (pSpecServo = pDescEE->m_spec.getServoSpec(nServoId)) == NULL )
1243  {
1244  LOGERROR("Servo %d: Cannot find servo specification.", nServoId);
1245  return -HEK_ECODE_NO_EXEC;
1246  }
1247 
1248  // add rebotic joint
1249  rc = addRobotJoint(pSpecJoint, pSpecServo, m_jointsArm, m_imapJoints);
1250  if( rc < 0 )
1251  {
1252  LOGERROR("Servo %d: Cannot add to kinematic chain.", nServoId);
1253  return rc;
1254  }
1255 
1256  // add any optical limit switches
1257  if( (rc = m_monitor.addJointLimitsToMonitor(pSpecJoint, pJoint)) < 0 )
1258  {
1259  LOGERROR("Servo %d: Cannot add to optical limit(s).", nServoId);
1260  return rc;
1261  }
1262  }
1263 
1264  //
1265  // TODO: Add equipment deck and auxiliary effector chains here.
1266  //
1267 
1268  return HEK_OK;
1269 }
HekSpecServo_T * getServoSpec(int nServoId)
Get servo spec associated with servo id.
Definition: hekSpec.cxx:290
MapRobotJoints m_jointsAux
robot auxiliary kinematic joints
Definition: hekRobot.h:699
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
Hekateros end effector tool description class.
Definition: hekDescEE.h:71
Operational robotic joint description class.
Definition: hekJoint.h:80
static const int HEK_ECODE_NO_EXEC
cannot execute error
Definition: hekateros.h:84
int addRobotJoint(HekSpecJoint_T *pSpecJoint, HekSpecServo_T *pSpecServo, MapRobotJoints &kin, IMapRobotJoints &imap)
Add a joint to robot&#39;s kinematic chain.
Definition: hekRobot.cxx:1271
HekSpec m_spec
fixed specification
Definition: hekDescArm.h:260
IMapRobotJoints m_imapJoints
joints indirect map
Definition: hekRobot.h:700
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
HekSpecJoint_T * getJointSpecAt(int index)
Get joint spec at the given index.
Definition: hekSpec.h:347
MapRobotJoints m_jointsEquipDeck
robot equipement deck kin. joints
Definition: hekRobot.h:698
Hekateros robotic arm (manipulator) description class.
Definition: hekDescArm.h:77
int m_nMasterServoId
master servo id
Definition: hekSpec.h:175
int addJointLimitsToMonitor(HekSpecJoint_T *pSpecJoint, HekRobotJoint *pJoint)
Add any joint limit switches to quick look-up map.
Definition: hekMonitor.cxx:355
int m_nDoF
degrees of freedom
Definition: hekSpec.h:403
HekDescEE * getEEDesc()
Get the <b><i>Hekateros</i></b> end effector product description.
Definition: hekDesc.h:187
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
HekSpec m_spec
fixed specification
Definition: hekDescEE.h:258
Robotic joint specification.
Definition: hekSpec.h:139
Robotic servo specification.
Definition: hekSpec.h:199
int HekRobot::createAsyncThread ( )
protected

Create the asynchronous thread.

Context:
Calling thread.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1635 of file hekRobot.cxx.

1636 {
1637  int rc;
1638 
1641 
1642  rc = pthread_create(&m_threadAsync, NULL, HekRobot::asyncThread, (void*)this);
1643 
1644  if( rc == 0 )
1645  {
1646  rc = HEK_OK;
1647  }
1648 
1649  else
1650  {
1652  LOGSYSERROR("pthread_create()");
1655  m_pAsyncTaskArg = NULL;
1656  rc = m_rcAsyncTask;
1657  }
1658 
1659  return rc;
1660 }
void * m_pAsyncTaskArg
asynchronous argument
Definition: hekRobot.h:715
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
int m_rcAsyncTask
last async task return code
Definition: hekRobot.h:713
static const int HEK_ECODE_SYS
system (errno) error
Definition: hekateros.h:73
static void * asyncThread(void *pArg)
Asynchronous operation thread.
Definition: hekRobot.cxx:1709
pthread_t m_threadAsync
async pthread identifier
Definition: hekRobot.h:716
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: hekRobot.h:714
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
idle, no async task running
Definition: hekateros.h:528
HekOpState HekRobot::determineRobotOpState ( )
protected

Determine robot operational state from collective joint operational states.

Returns
Determined robot operational state synchronized with joint states.

Definition at line 1620 of file hekRobot.cxx.

1621 {
1622  MapRobotJoints::iterator iter;
1623 
1624  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
1625  {
1626  if( iter->second.m_eOpState != HekOpStateCalibrated )
1627  {
1628  return HekOpStateUncalibrated;
1629  }
1630  }
1631 
1632  return HekOpStateCalibrated;
1633 }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
int HekRobot::disconnect ( )

Disconnect from Hekateros.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 394 of file hekRobot.cxx.

395 {
396  // close monitor
397  m_monitor.close();
398 
399  if( m_pKin != NULL )
400  {
401  delete m_pKin;
402  m_pKin = NULL;
403  }
404 
405  // delete dynamixel chain
406  if( m_pDynaChain != NULL )
407  {
408  m_pDynaChain->EStop(); // == force release of arm motors
409  delete m_pDynaChain;
410  m_pDynaChain = NULL;
411  }
412 
413  // close connection and delete dynamixel communication object
414  if( m_pDynaComm != NULL )
415  {
416  if( m_pDynaComm->IsOpen() )
417  {
418  m_pDynaComm->Close();
419  }
420  delete m_pDynaComm;
421  m_pDynaComm = NULL;
422  }
423 
424  // reset robot state
427  m_bIsEStopped = false;
428  m_bAlarmState = false;
429  m_bAreServosPowered = false;
430  m_bAtBalancedPos = false;
431  m_bAtParkedPos = false;
432 
433  LOGDIAG1("Disconnected from Hekateros.");
434 }
HekRobotMode m_eRobotMode
robot operating mode
Definition: hekRobot.h:680
bool m_bAtBalancedPos
arm is [not] at balanced position
Definition: hekRobot.h:685
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
bool m_bAtParkedPos
arm is [not] at parked position
Definition: hekRobot.h:686
fully available
Definition: hekateros.h:510
DynaComm * m_pDynaComm
dynamixel communication
Definition: hekRobot.h:692
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
int close()
Close resources to monitor hardware.
Definition: hekMonitor.cxx:253
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682
int HekRobot::estop ( )

Emergency stop.

All servos will stop driving, so arm or accessories may fall. Emergency stop requires recalibration.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 771 of file hekRobot.cxx.

References HEK_TRY_CONN, and HEK_TRY_NO_EXEC.

772 {
773  HEK_TRY_NO_EXEC();
774  HEK_TRY_CONN();
775 
776  m_pKin->estop();
777 
778  m_bIsEStopped = true;
779  m_bAreServosPowered = false;
780 
783 
785 
786  m_bAlarmState = true;
788 
789  LOGDIAG1("Hekateros emergency stopped.");
790 
791  return HEK_OK;
792 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
void markEStopCond(bool bEStopCond)
Mark emergency stop condition.
Definition: hekMonitor.cxx:403
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
#define HEK_TRY_NO_EXEC()
Define if heketeros has RN system board.
Definition: hekRobot.cxx:100
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
void clear()
Clear data.
Definition: hekTraj.h:291
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
void markAlarmCond(bool bAlarmedCond)
Mark alarm condition.
Definition: hekMonitor.cxx:396
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
HekJointTrajectoryPoint m_lastTrajArm
last trajectory point for arm
Definition: hekRobot.h:706
void markPoweredCond(bool bPoweredCond)
Mark motors are powered condition.
Definition: hekMonitor.h:271
virtual void estop()
Emergency stop the kinematics chain.
Definition: hekKin.cxx:356
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682
void HekRobot::fauxcalibrate ( )
protected

Faux calibrate Hekateros.

DANGER:
This function should in place of calibrate() for debugging. Make suere the arm is placed at the zero point prior to starting.

Definition at line 1397 of file hekRobot.cxx.

1398 {
1399  MapRobotJoints::iterator iter;
1400 
1401  freeze();
1402 
1403  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
1404  {
1405  iter->second.m_eOpState = HekOpStateCalibrated;
1406  }
1409 }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
virtual int resetServoOdometersForAllJoints()
Reset all joints&#39; master servos odometers to the current respective encoder positions.
Definition: hekKin.cxx:220
int freeze()
Freeze arm and accessories at current position.
Definition: hekRobot.cxx:794
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
int HekRobot::freeze ( )

Freeze arm and accessories at current position.

Servos are still being driven.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 794 of file hekRobot.cxx.

References HEK_TRY_CONN, and HEK_TRY_NO_EXEC.

795 {
796  HEK_TRY_NO_EXEC();
797  HEK_TRY_CONN();
798 
799  m_bAreServosPowered = true;
800 
802 
804 
805  m_pKin->freeze();
806 
807  LOGDIAG2("Hekateros frozen at current position.");
808 
809  return HEK_OK;
810 }
virtual void freeze()
Freeze kinematics chain at the current position.
Definition: hekKin.cxx:373
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
#define HEK_TRY_NO_EXEC()
Define if heketeros has RN system board.
Definition: hekRobot.cxx:100
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
void clear()
Clear data.
Definition: hekTraj.h:291
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
HekJointTrajectoryPoint m_lastTrajArm
last trajectory point for arm
Definition: hekRobot.h:706
void markPoweredCond(bool bPoweredCond)
Mark motors are powered condition.
Definition: hekMonitor.h:271
HekRobotJoint* hekateros::HekRobot::getArmJoint ( const std::string &  strName)
inline

Get robotic joint in arm+ee kinematic chain.

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

Definition at line 610 of file hekRobot.h.

References m_imapJoints, and m_jointsArm.

611  {
612  IMapRobotJoints::iterator iter;
613 
614  if( (iter = m_imapJoints.find(strName)) != m_imapJoints.end() )
615  {
616  return &(m_jointsArm[iter->second]);
617  }
618  else
619  {
620  return NULL;
621  }
622  }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
IMapRobotJoints m_imapJoints
joints indirect map
Definition: hekRobot.h:700
HekRobotJoint* hekateros::HekRobot::getArmJoint ( int  nServoId)
inline

Get robotic joint in arm+ee kinematic chain.

Parameters
nServoIdMaster servo id (primary key).
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Definition at line 631 of file hekRobot.h.

References m_jointsArm.

632  {
633  MapRobotJoints::iterator iter;
634 
635  if( (iter = m_jointsArm.find(nServoId)) != m_jointsArm.end() )
636  {
637  return &(iter->second);
638  }
639  else
640  {
641  return NULL;
642  }
643  }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
HekRobotJoint* hekateros::HekRobot::getArmJointAt ( int  index)
inline

Get robotic joint in arm+ee kinematic chain at the given index.

Parameters
indexJoint index.
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Definition at line 598 of file hekRobot.h.

References m_jointsArm.

599  {
600  return index < m_jointsArm.size()? &m_jointsArm.at(index): NULL;
601  }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
int HekRobot::getAsyncRc ( )

Get the last asynchronous task return code.

Returns
Returns HEK_OK when task terminated successfully. Otherwise, returns < 0 Hekateros Error Codes.

Definition at line 1704 of file hekRobot.cxx.

Referenced by setRobotMode().

1705 {
1706  return m_rcAsyncTask;
1707 }
int m_rcAsyncTask
last async task return code
Definition: hekRobot.h:713
HekAsyncTaskState HekRobot::getAsyncState ( )

Get the current asynchronous task state.

Returns
HekAsyncTaskState enum value.

Definition at line 1699 of file hekRobot.cxx.

Referenced by setRobotMode().

1700 {
1701  return m_eAsyncTaskState;
1702 }
HekAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: hekRobot.h:712
DynaChain* hekateros::HekRobot::getDynaChain ( )
inline

Get the dynamixel chain object.

Returns
Returns point to DynaChain object.

Definition at line 570 of file hekRobot.h.

References m_pDynaChain.

571  {
572  return m_pDynaChain;
573  }
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
std::string hekateros::HekRobot::getFullProdBrief ( )
inline

Get the Hekateros full brief descirption.

Returns
Returns product brief description.

Definition at line 488 of file hekRobot.h.

References hekateros::HekDesc::getFullProdBrief(), and m_descHek.

489  {
490  return m_descHek.getFullProdBrief();
491  }
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
std::string getFullProdBrief()
Get the <b><i>Hekateros</i></b> full brief descirption.
Definition: hekDesc.h:208
HekDesc* hekateros::HekRobot::getHekDesc ( )
inline

Get the Hekateros product description.

Returns
Returns pointer to description.

Definition at line 456 of file hekRobot.h.

References m_descHek.

457  {
458  return &m_descHek;
459  }
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int HekRobot::getJointState ( HekJointStatePoint jointStatePoint)

Get the joint states of a kinematic chain.

Parameters
[in,out]jointStatePointJoint state point.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 979 of file hekRobot.cxx.

References hekateros::HekJointStatePoint::append(), hekateros::HekJointStatePoint::clear(), HEK_TRY_CONN, HEK_TRY_GET_SERVO, hekateros::HekRobotJoint::m_eOpState, hekateros::HekJointState::m_eOpState, hekateros::HekJointState::m_eOptSwitch, hekateros::HekJointState::m_fEffort, hekateros::HekJointState::m_fPosition, hekateros::HekJointState::m_fVelocity, hekateros::HekJointState::m_nEncPos, hekateros::HekJointState::m_nMasterServoId, hekateros::HekJointState::m_nOdPos, hekateros::HekRobotJoint::m_nSlaveServoId, hekateros::HekJointState::m_nSlaveServoId, hekateros::HekJointState::m_nSpeed, hekateros::HekRobotJoint::m_strName, hekateros::HekJointState::m_strName, and hekateros::HekJointStatePoint::setKinematicChainName().

Referenced by resetEStop().

980 {
981  MapRobotJoints::iterator iter; // kinematic chain iterator
982  int nMasterServoId; // master servo id
983  HekRobotJoint *pJoint; // robotic joint
984  DynaServo *pServo; // servo
985  HekJointState jointState; // working joint state
986  byte_t uMask; // working bit mask
987  int i; // working index
988 
989  HEK_TRY_CONN();
990 
991  jointStatePoint.clear();
992 
993  jointStatePoint.setKinematicChainName("arm");
994 
995  //
996  // Build joint state point.
997  //
998  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
999  {
1000  nMasterServoId = iter->first;
1001  pJoint = &(iter->second);
1002 
1003  HEK_TRY_GET_SERVO(nMasterServoId, pServo);
1004 
1005  // identifiers
1006  jointState.m_strName = pJoint->m_strName;
1007  jointState.m_eOpState = pJoint->m_eOpState;
1008  jointState.m_nMasterServoId = nMasterServoId;
1009  jointState.m_nSlaveServoId = pJoint->m_nSlaveServoId;
1010 
1011  // joint dynamics
1013  jointState.m_fPosition,
1014  jointState.m_fVelocity);
1015 
1016  // servo dynamics
1017  jointState.m_nOdPos = pServo->GetOdometer();
1018  jointState.m_nEncPos = pServo->OdometerToEncoder(jointState.m_nOdPos);
1019  jointState.m_nSpeed = pServo->GetCurSpeed();
1020  jointState.m_fEffort = (double)pServo->GetCurLoad();
1021 
1022  // optical limit switch states
1023  for(int i=0; i<HekOptLimitMaxPerJoint; ++i)
1024  {
1025  jointState.m_eOptSwitch[i] = m_monitor.getJointLimitTriState(pJoint, i);
1026  }
1027 
1028  // add state
1029  jointStatePoint.append(jointState);
1030  }
1031 
1032  return HEK_OK;
1033 }
int m_nSlaveServoId
linked slave servo id (if any)
Definition: hekJoint.h:151
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
HekTriState getJointLimitTriState(HekRobotJoint *pJoint, int nLimit)
Get current joint limit tri-state.
Definition: hekMonitor.cxx:499
HekOpState m_eOpState
current operational state
Definition: hekJoint.h:179
int m_nOdPos
current master servo odometer pos (ticks)
Definition: hekJoint.h:323
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
Operational robotic joint description class.
Definition: hekJoint.h:80
int m_nSpeed
current master servo raw speed (unitless)
Definition: hekJoint.h:325
void clear()
Clear all state data.
Definition: hekJoint.h:464
double m_fPosition
current joint position (radians)
Definition: hekJoint.h:320
double m_fVelocity
current joint velocity (% of max)
Definition: hekJoint.h:321
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
HekOpState m_eOpState
joint operational state
Definition: hekJoint.h:317
void append(const HekJointState &jointState)
Append joint state to end of joint state point.
Definition: hekJoint.h:429
int m_nMasterServoId
master servo id
Definition: hekJoint.h:318
void setKinematicChainName(std::string strKinName)
Set the kinematic chain name.
Definition: hekJoint.h:400
std::string m_strName
joint name
Definition: hekJoint.h:316
std::string m_strName
joint name
Definition: hekJoint.h:149
static const int HekOptLimitMaxPerJoint
max limits/joint
Definition: hekOptical.h:120
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
int m_nSlaveServoId
linked slave servo id (if any)
Definition: hekJoint.h:319
#define HEK_TRY_GET_SERVO(nServoId, pServo)
Convenience macro for trying to get a servo object from dynamixel chain.
Definition: hekRobot.cxx:124
Joint state class.
Definition: hekJoint.h:287
double m_fEffort
current joint effort (servo load)
Definition: hekJoint.h:322
virtual void getFilteredJointCurPosVel(const std::string &strJointName, double &fJointCurPos, double &fJointCurVel)
Get the smoothed (filtered) current joint position and velocity.
Definition: hekKin.cxx:254
int m_nEncPos
current master servo encoder pos (ticks)
Definition: hekJoint.h:324
HekTriState m_eOptSwitch[HekOptLimitMaxPerJoint]
current state of optical switch(es)
Definition: hekJoint.h:326
DynaServo* hekateros::HekRobot::getMasterServo ( HekRobotJoint joint)
inline

Get robotic joint's master servo.

Parameters
jointRobotic joint.
Returns
If found, returns pointer to servo. Otherwise returns NULL.

Definition at line 652 of file hekRobot.h.

References hekateros::HekRobotJoint::m_nMasterServoId, and m_pDynaChain.

653  {
654  return m_pDynaChain!=NULL? m_pDynaChain->GetServo(joint.m_nMasterServoId):
655  NULL;
656  }
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
int hekateros::HekRobot::getProdId ( )
inline

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

Returns
Returns product id. See HekProdId.

Definition at line 467 of file hekRobot.h.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDescArm::getProdId(), and m_descHek.

468  {
469  return m_descHek.getArmDesc()->getProdId();
470  }
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int getProdId()
Get this base description&#39;s base product id.
Definition: hekDescArm.h:135
std::string hekateros::HekRobot::getProdName ( )
inline

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

Returns
Returns product name. See HekProdName.

Definition at line 478 of file hekRobot.h.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDescArm::getProdName(), and m_descHek.

479  {
480  return m_descHek.getArmDesc()->getProdName();
481  }
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
std::string getProdName()
Get this base description&#39;s name.
Definition: hekDescArm.h:145
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int HekRobot::getRobotState ( HekRobotState robotState)

Get the robot current state.

Parameters
[in,out]robotStateRobot state.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

< stopped speed

Definition at line 904 of file hekRobot.cxx.

References hekateros::HekRobotState::clear(), hekateros::iabs(), hekateros::HekRobotState::m_eAreDrivesPowered, hekateros::HekRobotState::m_eIsCalibrated, hekateros::HekRobotState::m_eIsEStopped, hekateros::HekRobotState::m_eIsInError, hekateros::HekRobotState::m_eIsInMotion, hekateros::HekRobotState::m_eIsMotionPossible, hekateros::HekRobotState::m_eRobotMode, hekateros::HekServoHealth::m_fTemperature, hekateros::HekServoHealth::m_fVoltage, hekateros::HekRobotState::m_nErrorCode, hekateros::HekServoHealth::m_nServoId, hekateros::HekServoHealth::m_uAlarms, and hekateros::HekRobotState::m_vecServoHealth.

Referenced by resetEStop().

905 {
906  static int TuneStoppedSpeed = 9; ///< stopped speed
907 
908  int iter; // servo iterator
909  int nServoId; // servo id
910  DynaServo *pServo; // servo
911  bool bIsMoving; // robot is [not] moving
912  HekServoHealth health; // servo health
913  bool bOldAlarmState; // old alarm state
914 
915  robotState.clear();
916 
917  bOldAlarmState = m_bAlarmState;
919 
920  robotState.m_eRobotMode = m_eRobotMode;
921  robotState.m_eIsEStopped = m_bIsEStopped?
928  !m_bAlarmState && !m_bNoExec?
930 
931  robotState.m_eIsInError = HekTriStateFalse;
932  robotState.m_nErrorCode = HEK_OK;
933  bIsMoving = false;
934 
935  for(nServoId = m_pDynaChain->IterStart(&iter);
936  nServoId != DYNA_ID_NONE;
937  nServoId = m_pDynaChain->IterNext(&iter))
938  {
939  pServo = m_pDynaChain->GetServo(nServoId);
940 
941  health.m_nServoId = nServoId;
942  health.m_fTemperature = pServo->CvtRawTempToC(pServo->GetCurTemp());
943  health.m_fVoltage = pServo->CvtRawVoltToVolts(pServo->GetCurVolt());
944  health.m_uAlarms = pServo->GetAlarms();
945 
946  if( health.m_uAlarms != DYNA_ALARM_NONE )
947  {
948  robotState.m_eIsInError = HekTriStateTrue;
949  robotState.m_nErrorCode = -HEK_ECODE_ALARMED;
950  }
951 
952  if( iabs(pServo->GetCurSpeed()) > TuneStoppedSpeed )
953  {
954  bIsMoving = true;
955  }
956 
957  robotState.m_vecServoHealth.push_back(health);
958  }
959 
960  // estop overrides other alarms
961  if( m_bIsEStopped )
962  {
963  robotState.m_eIsInError = HekTriStateTrue;
964  robotState.m_nErrorCode = -HEK_ECODE_ESTOP;
965  }
966 
967  // new alarm state other than estop.
968  else if( m_bAlarmState && (m_bAlarmState != bOldAlarmState) )
969  {
970  robotState.m_eIsInError = HekTriStateTrue;
971  robotState.m_nErrorCode = -HEK_ECODE_ALARMED;
972  }
973 
974  robotState.m_eIsInMotion = bIsMoving? HekTriStateTrue: HekTriStateFalse;
975 
976  return HEK_OK;
977 }
HekRobotMode m_eRobotMode
robot operating mode
Definition: hekRobot.h:680
int m_nServoId
servo id
Definition: hekState.h:100
int m_nErrorCode
hekateros error code
Definition: hekState.h:160
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
bool m_bNoExec
do [not] execute physical movements
Definition: hekRobot.h:678
VecHealth m_vecServoHealth
servos&#39; health
Definition: hekState.h:161
void clear()
Clear data.
Definition: hekState.cxx:132
HekTriState m_eIsInError
robot is [not] in error condition
Definition: hekState.h:159
HekTriState m_eIsEStopped
robot is [not] emergency stopped
Definition: hekState.h:155
float m_fTemperature
servo temperature (Celsius)
Definition: hekState.h:101
uint_t m_uAlarms
servo alarms
Definition: hekState.h:103
float m_fVoltage
servo voltage (volts)
Definition: hekState.h:102
HekRobotMode m_eRobotMode
robot operating mode
Definition: hekState.h:153
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
int iabs(int a)
Integer absolute value.
Definition: hekUtils.h:149
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
static const int HEK_ECODE_ESTOP
robot emergency stopped
Definition: hekateros.h:95
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
static const int HEK_ECODE_ALARMED
robot is alarmed
Definition: hekateros.h:92
HekTriState m_eIsInMotion
robot is [not] moving
Definition: hekState.h:158
Robot servo health.
Definition: hekState.h:71
HekTriState m_eIsMotionPossible
motion is [not] possible
Definition: hekState.h:157
HekTriState m_eAreDrivesPowered
servos are [not] powered
Definition: hekState.h:156
int getAlarmCond()
Get monitoring alarm condition.
Definition: hekMonitor.h:371
HekTriState m_eIsCalibrated
robot is [not] calibrated
Definition: hekState.h:154
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682
void hekateros::HekRobot::getTrajectoryParams ( HekNorm eNorm,
double &  fEpsilon 
)
inline

Get trajectory parameters.

Parameters
[out]eNormDistance norm.
[out]fEpsilonWaypoint precision (radians)

Definition at line 581 of file hekRobot.h.

References hekateros::HekTunes::getTrajectoryParams(), and m_tunes.

582  {
583  m_tunes.getTrajectoryParams(eNorm, fEpsilon);
584  }
HekTunes m_tunes
tune parameters
Definition: hekRobot.h:689
void getTrajectoryParams(HekNorm &eNorm, double &fEpsilon) const
Get trajectory tune parameters.
Definition: hekTune.h:462
int HekRobot::getTrajectoryState ( HekJointTrajectoryFeedback trajectoryFeedback)

Get trajectory feedback.

Parameters
[in,out]trajectoryFeedbackJoint state point.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1035 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryFeedback::clear(), and hekateros::HekJointStatePoint::getNumPoints().

Referenced by resetEStop().

1036 {
1037  HekJointStatePoint jointStatePoint;
1038  int iActual;
1039  int i;
1040  int rc;
1041 
1042  trajectoryFeedback.clear();
1043 
1044  // last issued trajectory is the desired trajectory
1046 
1047  // retrieve joint state
1048  if( (rc = getJointState(jointStatePoint)) < 0 )
1049  {
1050  LOGERROR("Cannot retrieve joint state data.");
1051  return rc;
1052  }
1053 
1054  // copy joint state to actual trajectory
1056 
1057  for(i=0; i<jointStatePoint.getNumPoints(); ++i)
1058  {
1059  trajectoryFeedback[iActual].append(jointStatePoint[i].m_strName,
1060  jointStatePoint[i].m_fPosition,
1061  jointStatePoint[i].m_fVelocity);
1062  }
1063 
1064  return HEK_OK;
1065 }
int getJointState(HekJointStatePoint &jointStatePoint)
Get the joint states of a kinematic chain.
Definition: hekRobot.cxx:979
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
size_t getNumPoints()
Get the number of joint states in joint state point.
Definition: hekJoint.h:410
static const int TRAJ_DESIRED
desired trajectory
Definition: hekTraj.h:316
static const int TRAJ_ACTUAL
actual trajectory
Definition: hekTraj.h:317
HekJointTrajectoryPoint m_lastTrajArm
last trajectory point for arm
Definition: hekRobot.h:706
Joint state point class.
Definition: hekJoint.h:344
void hekateros::HekRobot::getVersion ( int &  nVerMajor,
int &  nVerMinor,
int &  nRevision 
)
inline

Get the Hekateros robotic arm hardware version numbers.

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

Definition at line 419 of file hekRobot.h.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDescArm::getProdHwVer(), HEK_VER_MAJOR, HEK_VER_MINOR, HEK_VER_REV, m_descHek, and hekateros::strToVersion().

420  {
421  uint_t uHwVer;
422 
424  nVerMajor = HEK_VER_MAJOR(uHwVer);
425  nVerMinor = HEK_VER_MINOR(uHwVer);
426  nRevision = HEK_VER_REV(uHwVer);
427  }
#define HEK_VER_REV(ver)
Get revision number from version.
Definition: hekateros.h:213
#define HEK_VER_MAJOR(ver)
Get version major number from version.
Definition: hekateros.h:195
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
std::string getProdHwVer()
Get this base description&#39;s hardware version.
Definition: hekDescArm.h:165
#define HEK_VER_MINOR(ver)
Get version minor number from version.
Definition: hekateros.h:204
uint_t strToVersion(const std::string &str)
Convert version dotted string to integer equivalent.
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
std::string hekateros::HekRobot::getVersion ( )
inline

Get the Hekateros robotic arm hardware version string.

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

Returns
Version string.

Definition at line 446 of file hekRobot.h.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDescArm::getProdHwVer(), and m_descHek.

447  {
448  return m_descHek.getArmDesc()->getProdHwVer();
449  }
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
std::string getProdHwVer()
Get this base description&#39;s hardware version.
Definition: hekDescArm.h:165
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
uint_t hekateros::HekRobot::getVersionNum ( )
inline

Get the Hekateros robotic arm hardware version compact number.

Returns
Return byte-packed comparable verion number.

Definition at line 434 of file hekRobot.h.

References hekateros::HekDesc::getArmDesc(), hekateros::HekDescArm::getProdHwVer(), m_descHek, and hekateros::strToVersion().

435  {
437  }
HekDescArm * getArmDesc()
Get the <b><i>Hekateros</i></b> base product description.
Definition: hekDesc.h:177
std::string getProdHwVer()
Get this base description&#39;s hardware version.
Definition: hekDescArm.h:165
uint_t strToVersion(const std::string &str)
Convert version dotted string to integer equivalent.
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int HekRobot::gotoBalancedPos ( )

Move robotic arm to its pre-defined balanced position.

Some Considerations:
This move assumes an unrestricted workspace save for an horizontal plane defined by the platform on which the Hekateros is mounted to. Strategy:
  • The shoulder movement is the most critical as it will lift away the horizontal plane, and hopefully away from any obstructions.
  • The elbow joint may swing out, possibly causing a collision before the shoulder has sufficiently moved to a safer position. Therefore the elbow joint's velocity is slower than the shoulder's velocity.
  • The rotating base, if present, swings left or right, possibly dragging the arm across the horizontal plane. Therefore, this joint also moves slower than the shoulder.
  • The other joints are of no consequence.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 513 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryPoint::append(), hekateros::degToRad(), HEK_TRY_CALIB, HEK_TRY_CONN, HEK_TRY_NOT_ESTOP, hekateros::HekRobotJoint::m_fBalPosRads, and hekateros::HekRobotJoint::m_strName.

514 {
515  HekJointTrajectoryPoint trajPoint;
516  MapRobotJoints::iterator iter;
517 
518  int nMasterServoId;
519  HekRobotJoint *pJoint;
520  int rc;
521 
522  HEK_TRY_CONN();
523  HEK_TRY_CALIB();
525 
526  //
527  // Build trajoectory point.
528  //
529  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
530  {
531  nMasterServoId = iter->first;
532  pJoint = &(iter->second);
533 
534  switch( nMasterServoId )
535  {
536  case HekServoIdBase:
537  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
538  degToRad(60.0));
539  break;
540  case HekServoIdShoulderL:
541  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
542  degToRad(40.0));
543  break;
544  case HekServoIdElbow:
545  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
546  degToRad(35.0));
547  break;
549  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
550  degToRad(50.0));
551  break;
552  case HekServoIdWristRot:
553  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
554  degToRad(60.0));
555  break;
556  case HekServoIdGraboid:
557  trajPoint.append(pJoint->m_strName, pJoint->m_fBalPosRads,
558  degToRad(20.0));
559  break;
560  default:
561  break;
562  }
563  }
564 
565  if( (rc = moveArm(trajPoint)) < 0 )
566  {
567  LOGERROR("Move to pre-defined balanced position failed.");
568  }
569  else
570  {
571  m_bAtBalancedPos = true;
572  LOGDIAG2("Hekateros at balanced position.");
573  }
574 
575  return rc;
576 }
static const int HekServoIdWristPitch
wrist pitch
Definition: hekateros.h:264
static const int HekServoIdElbow
elbow
Definition: hekateros.h:263
bool m_bAtBalancedPos
arm is [not] at balanced position
Definition: hekRobot.h:685
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
Joint trajectory point class.
Definition: hekTraj.h:180
Operational robotic joint description class.
Definition: hekJoint.h:80
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
std::string m_strName
joint name
Definition: hekJoint.h:149
static const int HekServoIdShoulderL
left shoulder
Definition: hekateros.h:261
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
static const int HekServoIdBase
continuous rotating base
Definition: hekateros.h:260
double m_fBalPosRads
joint balanced position (radians)
Definition: hekJoint.h:171
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
static const int HekServoIdWristRot
wrist continuous rotation
Definition: hekateros.h:265
void append(const std::string &strName, double fPosition, double fVelocity, double fAcceleration=0.0)
Append joint point to end of trajectory.
Definition: hekTraj.h:264
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
static const int HekServoIdGraboid
graboid
Definition: hekateros.h:272
int moveArm(HekJointTrajectoryPoint &trajectoryPoint)
Move arm through trajectory point.
Definition: hekRobot.cxx:880
int HekRobot::gotoParkedPos ( )

Move robotic arm to its pre-defined parked position.

See discussion at gotoBalancedPos about pre-defined movements.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 578 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryPoint::append(), hekateros::degToRad(), HEK_TRY_CALIB, HEK_TRY_CONN, HEK_TRY_NOT_ESTOP, hekateros::HekRobotJoint::m_fParkPosRads, and hekateros::HekRobotJoint::m_strName.

579 {
580  HekJointTrajectoryPoint trajPoint;
581  MapRobotJoints::iterator iter;
582 
583  int nMasterServoId;
584  HekRobotJoint *pJoint;
585  int rc;
586 
587  HEK_TRY_CONN();
588  HEK_TRY_CALIB();
590 
591  //
592  // Build trajoectory point.
593  //
594  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
595  {
596  nMasterServoId = iter->first;
597  pJoint = &(iter->second);
598 
599  switch( nMasterServoId )
600  {
601  case HekServoIdBase:
602  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
603  degToRad(60.0));
604  break;
605  case HekServoIdShoulderL:
606  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
607  degToRad(40.0));
608  break;
609  case HekServoIdElbow:
610  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
611  degToRad(35.0));
612  break;
614  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
615  degToRad(50.0));
616  break;
617  case HekServoIdWristRot:
618  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
619  degToRad(60.0));
620  break;
621  case HekServoIdGraboid:
622  trajPoint.append(pJoint->m_strName, pJoint->m_fParkPosRads,
623  degToRad(20.0));
624  break;
625  default:
626  break;
627  }
628  }
629 
630  if( (rc = moveArm(trajPoint)) < 0 )
631  {
632  LOGERROR("Move to pre-defined parked position failed.");
633  }
634  else
635  {
636  m_bAtParkedPos = true;
637  LOGDIAG2("Hekateros at parked position.");
638  }
639 
640  return rc;
641 }
static const int HekServoIdWristPitch
wrist pitch
Definition: hekateros.h:264
static const int HekServoIdElbow
elbow
Definition: hekateros.h:263
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
Joint trajectory point class.
Definition: hekTraj.h:180
Operational robotic joint description class.
Definition: hekJoint.h:80
bool m_bAtParkedPos
arm is [not] at parked position
Definition: hekRobot.h:686
double m_fParkPosRads
joint parked position (radians)
Definition: hekJoint.h:172
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
std::string m_strName
joint name
Definition: hekJoint.h:149
static const int HekServoIdShoulderL
left shoulder
Definition: hekateros.h:261
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
static const int HekServoIdBase
continuous rotating base
Definition: hekateros.h:260
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
static const int HekServoIdWristRot
wrist continuous rotation
Definition: hekateros.h:265
void append(const std::string &strName, double fPosition, double fVelocity, double fAcceleration=0.0)
Append joint point to end of trajectory.
Definition: hekTraj.h:264
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
static const int HekServoIdGraboid
graboid
Definition: hekateros.h:272
int moveArm(HekJointTrajectoryPoint &trajectoryPoint)
Move arm through trajectory point.
Definition: hekRobot.cxx:880
int HekRobot::gotoZeroPtPos ( )

Move robotic arm to its pre-defined calibrated zero point position.

See discussion at gotoBalancedPos about pre-defined movements.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 643 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryPoint::append(), hekateros::degToRad(), HEK_TRY_CALIB, HEK_TRY_CONN, HEK_TRY_NOT_ESTOP, hekateros::HekRobotJoint::m_fCalibPosRads, and hekateros::HekRobotJoint::m_strName.

644 {
645  HekJointTrajectoryPoint trajPoint;
646  MapRobotJoints::iterator iter;
647 
648  int nMasterServoId;
649  HekRobotJoint *pJoint;
650  int rc;
651 
652  HEK_TRY_CONN();
653  HEK_TRY_CALIB();
655 
656  //
657  // Build trajoectory point.
658  //
659  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
660  {
661  nMasterServoId = iter->first;
662  pJoint = &(iter->second);
663 
664  switch( nMasterServoId )
665  {
666  case HekServoIdBase:
667  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
668  degToRad(60.0));
669  break;
670  case HekServoIdShoulderL:
671  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
672  degToRad(30.0));
673  break;
674  case HekServoIdElbow:
675  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
676  degToRad(25.0));
677  break;
679  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
680  degToRad(50.0));
681  break;
682  case HekServoIdWristRot:
683  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
684  degToRad(60.0));
685  break;
686  case HekServoIdGraboid:
687  trajPoint.append(pJoint->m_strName, pJoint->m_fCalibPosRads,
688  degToRad(20.0));
689  break;
690  default:
691  break;
692  }
693  }
694 
695  if( (rc = moveArm(trajPoint)) < 0 )
696  {
697  LOGERROR("Move to pre-defined calibrated zero point position failed.");
698  }
699  else
700  {
701  LOGDIAG2("Hekateros at zero point position.");
702  }
703 
704  return rc;
705 }
static const int HekServoIdWristPitch
wrist pitch
Definition: hekateros.h:264
static const int HekServoIdElbow
elbow
Definition: hekateros.h:263
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
Joint trajectory point class.
Definition: hekTraj.h:180
Operational robotic joint description class.
Definition: hekJoint.h:80
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
double m_fCalibPosRads
joint calibrated position (radians)
Definition: hekJoint.h:170
std::string m_strName
joint name
Definition: hekJoint.h:149
static const int HekServoIdShoulderL
left shoulder
Definition: hekateros.h:261
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
static const int HekServoIdBase
continuous rotating base
Definition: hekateros.h:260
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
static const int HekServoIdWristRot
wrist continuous rotation
Definition: hekateros.h:265
void append(const std::string &strName, double fPosition, double fVelocity, double fAcceleration=0.0)
Append joint point to end of trajectory.
Definition: hekTraj.h:264
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
static const int HekServoIdGraboid
graboid
Definition: hekateros.h:272
int moveArm(HekJointTrajectoryPoint &trajectoryPoint)
Move arm through trajectory point.
Definition: hekRobot.cxx:880
int hekateros::HekRobot::isAlarmed ( )
inline

Test if robot is alarmed.

Returns
Returns true or false.

Definition at line 538 of file hekRobot.h.

References hekateros::HekMonitor::getAlarmCond(), m_bAlarmState, and m_monitor.

539  {
540  // monitor always has the latest alarm conditions. Robot simple shadows.
542  return m_bAlarmState;
543  }
bool m_bAlarmState
robot is [not] alarmed
Definition: hekRobot.h:683
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
int getAlarmCond()
Get monitoring alarm condition.
Definition: hekMonitor.h:371
int hekateros::HekRobot::isAtBalancedPos ( )
inline

Test if robot is as pre-defined balanced position.

Returns
Returns true or false.

Definition at line 550 of file hekRobot.h.

References m_bAtBalancedPos.

551  {
552  return m_bAtBalancedPos;
553  }
bool m_bAtBalancedPos
arm is [not] at balanced position
Definition: hekRobot.h:685
int hekateros::HekRobot::isAtParkedPos ( )
inline

Test if robot is as pre-defined parked position.

Returns
Returns true or false.

Definition at line 560 of file hekRobot.h.

References m_bAtParkedPos.

561  {
562  return m_bAtParkedPos;
563  }
bool m_bAtParkedPos
arm is [not] at parked position
Definition: hekRobot.h:686
int hekateros::HekRobot::isCalibrated ( )
inline

Test if robot is calibrated.

Returns
Returns true or false.

Definition at line 508 of file hekRobot.h.

References hekateros::HekOpStateCalibrated, and m_eOpState.

509  {
511  }
HekOpState m_eOpState
arm operational state
Definition: hekRobot.h:681
bool hekateros::HekRobot::isConnected ( )
inline

Test if connected to Hekateros hardware.

Returns
Returns true or false.

Definition at line 407 of file hekRobot.h.

References m_pDynaComm.

408  {
409  return (m_pDynaComm != NULL) && m_pDynaComm->IsOpen()? true: false;
410  }
DynaComm * m_pDynaComm
dynamixel communication
Definition: hekRobot.h:692
int hekateros::HekRobot::isDescribed ( )
inline

Test if robot is fully described via configuration XML.

Returns
Returns true or false.

Definition at line 498 of file hekRobot.h.

References hekateros::HekDesc::isDescribed(), and m_descHek.

499  {
500  return m_descHek.isDescribed();
501  }
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
bool isDescribed()
Test if required descriptions are described.
Definition: hekDesc.h:165
int hekateros::HekRobot::isEStopped ( )
inline

Test if robot is current emergency stopped.

Returns
Returns true or false.

Definition at line 518 of file hekRobot.h.

References m_bIsEStopped.

519  {
520  return m_bIsEStopped;
521  }
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682
bool HekRobot::isInMotion ( )

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

Returns
Returns true or false.

< stopped speed

Definition at line 1067 of file hekRobot.cxx.

References hekateros::iabs().

Referenced by setRobotMode().

1068 {
1069  static int TuneStoppedSpeed = 9; ///< stopped speed
1070 
1071  int iter; // servo iterator
1072  int nServoId; // servo id
1073  DynaServo *pServo; // servo
1074 
1075  for(nServoId = m_pDynaChain->IterStart(&iter);
1076  nServoId != DYNA_ID_NONE;
1077  nServoId = m_pDynaChain->IterNext(&iter))
1078  {
1079  pServo = m_pDynaChain->GetServo(nServoId);
1080 
1081  if( iabs(pServo->GetCurSpeed()) > TuneStoppedSpeed )
1082  {
1083  return true;
1084  }
1085  }
1086 
1087  return false;
1088 }
int iabs(int a)
Integer absolute value.
Definition: hekUtils.h:149
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
void hekateros::HekRobot::lock ( )
inlineprotected

Lock the robot mutex.

The lock()/unlock() primitives provide thread-safe access.

Context:
Any.

Definition at line 980 of file hekRobot.h.

981  {
982  pthread_mutex_lock(&m_mutex);
983  }
pthread_mutex_t m_mutex
synchronization mutex
Definition: hekRobot.h:717
int HekRobot::moveArm ( HekJointTrajectoryPoint trajectoryPoint)

Move arm through trajectory point.

Parameters
trajectoryPointTrajectory end point.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 880 of file hekRobot.cxx.

References HEK_TRY_CALIB, HEK_TRY_CONN, and HEK_TRY_NOT_ESTOP.

Referenced by resetEStop().

881 {
882  int rc;
883 
884  HEK_TRY_CONN();
885  HEK_TRY_CALIB();
887 
888  lock();
889 
890  if( !m_bAreServosPowered )
891  {
892  m_bAreServosPowered = true;
893 
895  }
896 
897  rc = m_pKin->move(trajectoryPoint);
898 
899  unlock();
900 
901  return rc >= 0? HEK_OK: rc;
902 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
void lock()
Lock the robot mutex.
Definition: hekRobot.h:980
void unlock()
Unlock the robot mutex.
Definition: hekRobot.h:991
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
void markPoweredCond(bool bPoweredCond)
Mark motors are powered condition.
Definition: hekMonitor.h:271
virtual int move(HekJointTrajectoryPoint &trajectoryPoint)
Move kinematic chain through a trajectory point.
Definition: hekKin.cxx:500
int hekateros::HekRobot::moveWait ( DynaServo *  pServo,
int  nOdGoalPos,
int  nSpeed 
)
protected

Move servo to position.

This call blocks until move is complete.

Parameters
pServoPointer to servo.
nOdGoalPosGoal position in raw odometer units.
nSpeedSpeed in raw units.
Returns
New odometer position.
void hekateros::HekRobot::moveWristRot ( )
protected

Move wrist rotation for any necessary final position adjustments.

The wrist coupled pitch and rotation joints can have their respective goal trajectories change by various actions.

int HekRobot::openGripper ( )

Open gripper to its maximum opened position.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 707 of file hekRobot.cxx.

References hekateros::HekJointTrajectoryPoint::append(), hekateros::degToRad(), HEK_TRY_CALIB, HEK_TRY_CONN, HEK_TRY_NOT_ESTOP, hekateros::HekRobotJoint::m_fMaxSoftLimitRads, and hekateros::HekRobotJoint::m_strName.

708 {
709  HekJointTrajectoryPoint trajPoint;
710 
711  HekRobotJoint *pJoint;
712  int rc;
713 
714  HEK_TRY_CONN();
715  HEK_TRY_CALIB();
717 
718  if( (pJoint = getArmJoint(HekServoIdGraboid)) == NULL )
719  {
720  LOGERROR("No gripper end effector found.");
721  return -HEK_ECODE_NO_RSRC;
722  }
723 
724  trajPoint.append(pJoint->m_strName, pJoint->m_fMaxSoftLimitRads,
725  degToRad(60.0));
726 
727  if( (rc = moveArm(trajPoint)) < 0 )
728  {
729  LOGERROR("Move to pre-defined gripper open position failed.");
730  }
731  else
732  {
733  LOGDIAG2("Hekateros gripper opened.");
734  }
735 
736  return rc;
737 }
HekRobotJoint * getArmJoint(const std::string &strName)
Get robotic joint in arm+ee kinematic chain.
Definition: hekRobot.h:610
Joint trajectory point class.
Definition: hekTraj.h:180
Operational robotic joint description class.
Definition: hekJoint.h:80
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
static const int HEK_ECODE_NO_RSRC
no resource available error
Definition: hekateros.h:82
std::string m_strName
joint name
Definition: hekJoint.h:149
double degToRad(double d)
Convert degrees to radians.
Definition: hekUtils.h:125
double m_fMaxSoftLimitRads
joint max soft limit (radians)
Definition: hekJoint.h:167
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
void append(const std::string &strName, double fPosition, double fVelocity, double fAcceleration=0.0)
Append joint point to end of trajectory.
Definition: hekTraj.h:264
#define HEK_TRY_CALIB()
Test for calibration.
Definition: hekRobot.cxx:161
static const int HekServoIdGraboid
graboid
Definition: hekateros.h:272
int moveArm(HekJointTrajectoryPoint &trajectoryPoint)
Move arm through trajectory point.
Definition: hekRobot.cxx:880
double hekateros::HekRobot::pctOfMaxJointVelocity ( HekRobotJoint joint,
double  fVelPct 
)
inline

Convert percent of maximum to joint velocity.

The maximum joint velocity is the theoretical maximum joint velocity based on joint servo specs of unloaded maximum RPMs and the Hekateros external gear ratios.

Parameters
jointJoint description.
fValPctJoint velocity (%).
Returns
Joint velocity (radians/second).

Definition at line 670 of file hekRobot.h.

References hekateros::HekRobotJoint::m_fMaxJointRadsPerSec.

671  {
672  return fVelPct < 100.0? fVelPct/100.0 * joint.m_fMaxJointRadsPerSec:
673  joint.m_fMaxJointRadsPerSec;
674  }
int HekRobot::release ( )

Release arm and accessories.

Servos will stop driving, so the arm may fall. This call is assumed to be under control, so recalibration is not required. Typically, the arm is released during manual repositioning or teaching.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 812 of file hekRobot.cxx.

References HEK_TRY_CONN, and HEK_TRY_NO_EXEC.

813 {
814  HEK_TRY_NO_EXEC();
815  HEK_TRY_CONN();
816 
817  m_bAreServosPowered = false;
818 
820 
822 
823  m_pKin->release();
824 
825  LOGDIAG2("Hekateros servo drives released.");
826 
827  return HEK_OK;
828 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
bool m_bAreServosPowered
arm servos are [not] driven
Definition: hekRobot.h:684
#define HEK_TRY_NO_EXEC()
Define if heketeros has RN system board.
Definition: hekRobot.cxx:100
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
void clear()
Clear data.
Definition: hekTraj.h:291
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
HekJointTrajectoryPoint m_lastTrajArm
last trajectory point for arm
Definition: hekRobot.h:706
void markPoweredCond(bool bPoweredCond)
Mark motors are powered condition.
Definition: hekMonitor.h:271
virtual void release()
Release kinematics chain.
Definition: hekKin.cxx:382
void HekRobot::reload ( )

Reload Hekateros's reloadable configuration and reset operational parameters.

The robot connection and calibration states are uneffected.

Definition at line 499 of file hekRobot.cxx.

References hekateros::HekXmlTune::load().

500 {
501  HekXmlTune xml;
502 
503  // parse user tune parameter overrides
505  {
506  LOGDIAG2("User specified tuning parameters reloaded from XML file %s.",
507  HekEtcTune);
508 
510  }
511 }
const char *const HekSysCfgPath
System configuration search path.
Definition: hekateros.h:322
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
HekTunes m_tunes
tune parameters
Definition: hekRobot.h:689
HekXmlTune <b><i>Hekateros</i></b> XML tuning class.
Definition: hekXmlTune.h:72
const char *const HekEtcTune
xml tune file
Definition: hekateros.h:343
virtual int load(HekTunes &tunes, const std::string &strSearchPath=HekSysCfgPath, const std::string &strXmlFileName=HekEtcTune, bool bAllInstances=false)
Load XML file into DOM and set the <b><i>Hekateros</i></b> tuning parameters.
Definition: hekXmlTune.cxx:72
virtual void reload(const HekTunes &tunes)
Reload configuration tuning parameters for all joints.
Definition: hekKin.cxx:208
void HekRobot::resetCalibStateForAllJoints ( bool  bForceRecalib)
protected

Mark all relevant joints for recalibration.

Parameters
bForceRecalibIf true, force recalibration all joints. Otherwise calibrate only the uncalibrated.

Definition at line 1607 of file hekRobot.cxx.

1608 {
1609  MapRobotJoints::iterator iter;
1610 
1611  for(iter = m_jointsArm.begin(); iter != m_jointsArm.end(); ++iter)
1612  {
1613  if( bForceRecalib || (iter->second.m_eOpState != HekOpStateCalibrated) )
1614  {
1615  iter->second.m_eOpState = HekOpStateUncalibrated;
1616  }
1617  }
1618 }
MapRobotJoints m_jointsArm
robot arm + end effector joints
Definition: hekRobot.h:697
void hekateros::HekRobot::resetEStop ( )
inline

Reset (clears) emergency stop condition.

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

Definition at line 309 of file hekRobot.h.

References getJointState(), getRobotState(), getTrajectoryState(), m_bIsEStopped, m_monitor, hekateros::HekMonitor::markEStopCond(), and moveArm().

310  {
311  m_bIsEStopped = false;
313  }
void markEStopCond(bool bEStopCond)
Mark emergency stop condition.
Definition: hekMonitor.cxx:403
HekMonitor m_monitor
power, health, and safety monitor
Definition: hekRobot.h:709
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: hekRobot.h:682
int HekRobot::scanDynaBus ( int  nMaxTries)
protected

Scan Hekateros dynamixel bus hardware and match against description.

Parameters
nMaxTriesMaximums number of scan attempts before failing.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Definition at line 1090 of file hekRobot.cxx.

1091 {
1092  static uint_t usecTry = 500000;
1093 
1094  int nNumServosExpected; // number of expected and required servos
1095  int nNumServosScanned; // number of scanned servos
1096  int nNumServosMatched; // number of scanned and matched servos
1097  int nTries; // scan attempts
1098  int nServoId; // servo id
1099  int iter; // servo iterator
1100  int rc; // return code
1101 
1102  nNumServosExpected = m_descHek.getNumServos();
1103 
1104  //
1105  // Scan hardware.
1106  //
1107  for(nTries=0; nTries<nMaxTries; ++nTries)
1108  {
1109  LOGDIAG3("Scanning Hekateros hardware - attempt %d of %d.",
1110  nTries+1, nMaxTries);
1111 
1112  // scan for servos
1113  nNumServosScanned = m_pDynaChain->AddNewServosByScan();
1114 
1115  //
1116  // Scanned at least the required number.
1117  //
1118  if( nNumServosScanned >= nNumServosExpected )
1119  {
1120  // check scanned ids against required
1121  for(nServoId = m_pDynaChain->IterStart(&iter), nNumServosMatched=0;
1122  nServoId != DYNA_ID_NONE;
1123  nServoId = m_pDynaChain->IterNext(&iter))
1124  {
1125  // matched
1126  if( m_descHek.hasServo(nServoId) )
1127  {
1128  ++nNumServosMatched;
1129  }
1130 
1131  // unmathced
1132  else
1133  {
1134  LOGWARN("Servo %d unexpected - uncontrolled.", nServoId);
1135  }
1136  }
1137 
1138  // servos matched
1139  if( nNumServosMatched == nNumServosExpected )
1140  {
1141  rc = HEK_OK;
1142  break;
1143  }
1144 
1145  // some required servos are missing
1146  else
1147  {
1148  LOGERROR("Match %d scanned servo ids, expected %d required matches.",
1149  nNumServosMatched, nNumServosExpected);
1150  rc = -HEK_ECODE_FORMAT;
1151  }
1152  }
1153 
1154  //
1155  // Scan failed to detect the minimum number of servos.
1156  //
1157  else
1158  {
1159  LOGERROR("Scanned %d servos, expected %d.",
1160  nNumServosScanned, nNumServosExpected);
1161  rc = -HEK_ECODE_NO_RSRC;
1162  }
1163 
1164  usleep(usecTry);
1165  }
1166 
1167  if( rc == HEK_OK )
1168  {
1169  LOGDIAG3("Hekateros dynamixel bus hardware scanned successfully.");
1170  }
1171 
1172  return rc;
1173 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
static const int HEK_ECODE_FORMAT
bad format
Definition: hekateros.h:88
bool hasServo(int nServoId)
Test if servo id is in the list of servos.
Definition: hekDesc.cxx:97
static const int HEK_ECODE_NO_RSRC
no resource available error
Definition: hekateros.h:82
DynaChain * m_pDynaChain
dynamixel chain
Definition: hekRobot.h:693
int getNumServos()
Get the number of expected and required servos.
Definition: hekDesc.h:238
HekDesc m_descHek
<b><i>Hekateros</i></b> description
Definition: hekRobot.h:679
int hekateros::HekRobot::scanHw ( )
protected

Scan Hekateros hardware and match against description.

Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.
void hekateros::HekRobot::setAllJointGoalsToNull ( )
protected

Set all joint goals to a null trajectory.

A null trajectory for a joint is the joint's current position and zero velocity.

void hekateros::HekRobot::setJointGoalsToNull ( const std::vector< std::string > &  vecNames)
protected

Set a set of joint goals to a null trajectory.

A null trajectory for a joint is the joint's current position and zero velocity.

Parameters
vecNamesVector of joint names.
void hekateros::HekRobot::setJointGoalToNull ( const std::string &  strName)
protected

Set joint goal to null a trajectory.

A null trajectory for a joint is the joint's current position and zero velocity.

Parameters
strNameJoint name.
void hekateros::HekRobot::setRobotMode ( HekRobotMode  eRobotMode)
inline

Set robot's operational mode.

Returns
eRobotMode Robot operation mode. See HekRobotMode.

Definition at line 361 of file hekRobot.h.

References cancelAsyncTask(), getAsyncRc(), getAsyncState(), isInMotion(), and m_eRobotMode.

362  {
363  m_eRobotMode = eRobotMode;
364  }
HekRobotMode m_eRobotMode
robot operating mode
Definition: hekRobot.h:680
int HekRobot::stop ( const std::vector< std::string > &  vecNames)

Stops specified joints at current position.

Servos are still being driven.

Parameters
vecNamesVector of joint names.

the number of joints stopped. the number of joints stopped.

Definition at line 830 of file hekRobot.cxx.

References HEK_TRY_CONN, HEK_TRY_NO_EXEC, and HEK_TRY_NOT_ESTOP.

831 {
832  int n;
833 
834  HEK_TRY_NO_EXEC();
835  HEK_TRY_CONN();
837 
839 
840  n = m_pKin->stop(vecNames);
841 
842  LOGDIAG3("%d joints stopped.", n);
843 
844  return n;
845 }
virtual int stop()
Stop kinematics chain at the current position.
Definition: hekKin.cxx:399
#define HEK_TRY_NO_EXEC()
Define if heketeros has RN system board.
Definition: hekRobot.cxx:100
HekKinematics * m_pKin
dynamics and kinematics
Definition: hekRobot.h:703
void clear()
Clear data.
Definition: hekTraj.h:291
#define HEK_TRY_NOT_ESTOP()
Test for not estop.
Definition: hekRobot.cxx:179
#define HEK_TRY_CONN()
Test for connection.
Definition: hekRobot.cxx:143
HekJointTrajectoryPoint m_lastTrajArm
last trajectory point for arm
Definition: hekRobot.h:706
void hekateros::HekRobot::stopWait ( const std::vector< std::string > &  vecNames,
int  nMaxTries = 10 
)
protected

Wait for the specified joints to stop moving.

A maximum number of wait-test tries is performed until either all of the joints haved stopped or the maximum number of tries has been reached. The between-test wait is 10 milliseconds.

Parameters
vecNamesVector of joint names.
nMaxTriesMaximum number of test-wait tries.
bool hekateros::HekRobot::trylock ( )
inlineprotected

Try to lock the robot mutex.

Context:
Any.
Returns
Returns true if lock acquired, else returns false.

Definition at line 1004 of file hekRobot.h.

1005  {
1006  return pthread_mutex_trylock(&m_mutex) == 0? true: false;
1007  }
pthread_mutex_t m_mutex
synchronization mutex
Definition: hekRobot.h:717
void hekateros::HekRobot::unlock ( )
inlineprotected

Unlock the robot mutex.

Context:
Any.

Definition at line 991 of file hekRobot.h.

992  {
993  pthread_mutex_unlock(&m_mutex);
994  }
pthread_mutex_t m_mutex
synchronization mutex
Definition: hekRobot.h:717

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