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

Special wrist rotation joint kinematics and dynamics class. More...

#include <hekKinJoint.h>

Inheritance diagram for hekateros::HekKinJointWristRot:
hekateros::HekKinJoint

Public Member Functions

 HekKinJointWristRot ()
 Default constructor.
 
 HekKinJointWristRot (HekRobotJoint *pJoint, DynaServo *pServo, const HekTunes &tunes)
 Initialization constructor. More...
 
virtual ~HekKinJointWristRot ()
 Destructor.
 
HekKinJointWristRotoperator= (const HekKinJointWristRot &rhs)
 Assignment operator. More...
 
virtual void coupleJoint (HekKinJoint *pKinJointWristPitch)
 Couple joint. More...
 
virtual int react (bool bIsControlling, SyncMoveMsgs &msgs)
 React to recently read sensor data. More...
 
virtual MoveState planMotion (bool bIsControlling, SyncMoveMsgs &msgs)
 Plan motion. More...
 
virtual int act ()
 Act (write) to effect the servo dynamics for torque and motion control. More...
 
virtual int jointPosToServoPos (double fPos)
 Convert joint position to the equivalent servo position. More...
 
virtual double servoPosToJointPos (int nOdPos)
 Convert servo position to the equivalent joint position. More...
 
- Public Member Functions inherited from hekateros::HekKinJoint
 HekKinJoint ()
 Default constructor.
 
 HekKinJoint (HekRobotJoint *pJoint, DynaServo *pServo, const HekTunes &tunes)
 Initialization constructor. More...
 
virtual ~HekKinJoint ()
 Copy constructor. More...
 
HekKinJointoperator= (const HekKinJoint &rhs)
 Assignment operator. More...
 
virtual void reload (const HekTunes &tunes)
 Reload configuration tuning parameters. More...
 
MoveState getMoveState ()
 Get move control state for this joint. More...
 
bool isMovingToGoal ()
 Test if actively moving joint to goal. More...
 
bool isStopping ()
 Test if actively stopping joint. More...
 
bool isMoving ()
 Test if actively moving joint. More...
 
virtual bool isStopped ()
 Test if joint is stopped (i.e. control is not active). More...
 
bool canStopNow ()
 Test if can stop now without slowing down. More...
 
void getPidKParams (double &fKp, double &fKi, double &fKd) const
 Get the joint's position and velocity PID K parameters. More...
 
void setPidKParams (const double fKp, const double fKi, const double fKd)
 Set the joint's position and velocity PID K parameters. More...
 
double getPidMaxDeltaVParam () const
 Get joint PID maximum delta v (radians/second) parameter. More...
 
void setPidMaxDeltaVParam (const double fMaxDeltaV)
 Set joint PID maximum delta v (radians/second) parameter. More...
 
void getToleranceParams (double &fTolPos, double &fTolVel) const
 Get the position and velocity tolerance parameters. More...
 
void setToleranceParams (const double fTolPos, const double fTolVel)
 Set the position and velocity tolerance parameters. More...
 
void getJointCurPosVel (double &fCurPos, double &fCurVel) const
 Get the instantaneous current joint position and velocity. More...
 
void getFilteredJointCurPosVel (double &fCurPos, double &fCurVel) const
 Get the smoothed (filtered) current joint position and velocity. More...
 
void getServoCurPosSpeed (int &nServoCurPos, int &nServoCurSpeed) const
 Get the instantaneous current servo position and speed. More...
 
void getTgtVelSpeed (double &fTgtVel, int &nTgtSpeed) const
 Get the PID output target joint velocity and the corresponding servo speed estemate. More...
 
virtual bool hasOverTorqueCondition ()
 Test if joint is in an over torque condition. More...
 
virtual int resetServoOdometer ()
 Reset servo odometer zero point to the current encoder position. More...
 
int specifyMove (const double fGoalPos, const double fGoalVel)
 Specify a new joint goal position and velocity move. More...
 
virtual int senseDynamics (bool bIsControlling)
 Sense (read) the current servo dynamics and transform to useful state. More...
 
virtual int applyTorqueControl ()
 Apply torque limit control. More...
 
virtual MoveState move ()
 Move joint using joint PID controller. More...
 
virtual int stop ()
 Stop movement and move control of the joint. More...
 

Protected Member Functions

virtual void updateAssoc (double fJointVel, int nServoSpeed)
 Update joint velocity - servo speed association. More...
 
MoveState getCoupledJointState ()
 Get coupled joint's move state. More...
 
virtual bool isCoupledJointStopped ()
 Test if coupled joint is stopped. More...
 
virtual bool isCoupledJointMoving ()
 Test if coupled joint is moving. More...
 
virtual MoveState nlmove ()
 Move joint using joint PID controller (no lock version). More...
 
virtual int nlslowToStop (SyncMoveMsgs &msg)
 Slow to stop (no lock version). More...
 
- Protected Member Functions inherited from hekateros::HekKinJoint
void lock ()
 Lock the joint kinematics. More...
 
void unlock ()
 Unlock the joint kinematics. More...
 
double delta_t ()
 Calculate the delta time between calls to this. More...
 
double averageDt (double fDtAvg, double fDt)
 Apply a running average for the delta times (seconds). More...
 
int dejitterServoPos (int nServoCurPos, int nServoPrevPos)
 De-jitter servo odometer position. More...
 
double filterPositions (double fPosAvg, double fJointPos)
 Apply a low-pass band filter on the joint positions (radians). More...
 
double filterVelocities (double fVelAvg, double fJointVel)
 Apply a low-pass band filter on the joint velocities (radians/second). More...
 
double filterTorques (double fTorqueAvg, int nServoLoad)
 Apply a low-pass band filter on the sensed torques (loads). More...
 
int getGoalDir ()
 Get the current goal rotation direction. More...
 
int getPlannedDir (int nServoTgtSpeed)
 Get the planned target rotation direction. More...
 
bool canMoveInGoalDir ()
 Test if joint can move in direction of goal position. More...
 
bool canMoveInPlannedDir (int nServoTgtSpeed)
 Test if joint can move in planned direction. More...
 
virtual double jointVelocity (double fPos1, double fPos0, double fDt)
 Calculate the joint velocity from delta servo positions. More...
 
virtual int estimateServoTgtSpeed (double fJointTgtVel)
 Estimate of target servo speed from target joint velocity. More...
 
virtual int estimateServoTgtSpeedSimple (double fJointTgtVel)
 Simple estimate of target servo speed from target joint velocity. More...
 
void moveServo (int nServoGoalSpeed, int nServoGoalPos)
 Move servo. More...
 
void addServoMsgEntries (SyncMoveMsgs &msg, int nServoGoalSpeed, int nServoGoalPos)
 Add servo to synchronous move message(s). More...
 
virtual int nlspecifyMove (const double fGoalPos, const double fGoalVel)
 Specify a new joint goal position and velocity move (no lock version). More...
 
virtual int nlapplyTorqueControl ()
 Apply torque limit control (no lock version). More...
 
virtual int nlstop ()
 Stop movement and move control of the joint (no lock version). More...
 

Protected Attributes

HekKinJointm_pKinJointWristPitch
 wrist pitch joint description
 
MoveState m_eStateWristPitch
 joint control state
 
- Protected Attributes inherited from hekateros::HekKinJoint
MoveState m_eState
 joint control state
 
pthread_mutex_t m_mutexSync
 synchonization mutex
 
HekRobotJointm_pJoint
 joint description
 
DynaServo * m_pServo
 joint master servo control
 
double m_fTolPos
 joint position ± tolerance (rads)
 
double m_fTolVel
 joint velocity ± tolerance (rads/s)
 
double m_fStopVelTh
 joint velocity threshold to safely stop move
 
HekPid m_pid
 joint position and velocity PID
 
double m_fJointRadPerTick
 joint radians / odometer tick
 
double m_fJointGoalPos
 joint goal position (radians)
 
int m_nServoGoalPos
 servo goal position (odometer ticks)
 
double m_fJointCurPos
 joint current position (radians)
 
int m_nServoCurPos
 servo current position (odometer ticks)
 
double m_fJointPrevPos
 joint current position (radians)
 
int m_nServoPrevPos
 servo previous pos (odometer ticks)
 
double m_fJointPosOut
 low-pass filtered joint cur position
 
std::deque< double > m_histPosIn
 recent history of joint positions
 
double m_fDt
 delta time between positions reads
 
struct timespec m_tsPrev
 previous time mark
 
double m_fDtAvg
 average delta t
 
std::deque< double > m_histDtIn
 sliding window of delta t's
 
double m_fJointGoalVel
 joint goal velocity (radians/second)
 
double m_fJointCurVel
 joint current velocity (radians/second)
 
int m_nServoCurSpeed
 current motor speed (raw unitless)
 
double m_fVelDerate
 joint velocity derate (normalized)
 
VelSpeedLookupTbl m_tblVelSpeed
 dynamic velocity/speed lookup table
 
double m_fJointVelOut
 low-pass filtered joint cur velocity
 
std::deque< double > m_histVelIn
 sliding window of current velocities
 
double m_fJointTgtVel
 joint target velocity (radians/second)
 
int m_nServoTgtSpeed
 target motor speed (raw unitless)
 
bool m_bOverTorqueCond
 is [not] in torque overload condition
 
double m_fOverTorqueTh
 set over torque condition threshold
 
double m_fClearTorqueTh
 clear over torque condition threshold
 
int m_nServoCurLoad
 servo current load (raw unitless)
 
double m_fTorqueOut
 low-pass filtered torque
 
std::deque< double > m_histTorqueIn
 recent history of joint torques
 

Additional Inherited Members

- Public Types inherited from hekateros::HekKinJoint
enum  MoveState {
  MoveStateIdle,
  MoveStateNewMove,
  MoveStateMoving,
  MoveStateStopping
}
 Kinedynamics joint position and velocity control states. More...
 
- Static Public Attributes inherited from hekateros::HekKinJoint
static const size_t POS_WIN_SIZE = 6
 Position sliding window size for low-pass band filtering of input positions.
 
static const size_t DT_WIN_SIZE = 10
 Delta t sliding window size for low-pass band filtering of input delta times.
 
static const size_t VEL_WIN_SIZE = 6
 Velocity sliding window size for low-pass band filtering of input Velocities.
 
static const double SLOW_DERATE_DELTA_V = 1.0
 Stop delta v as a fraction of max_delta_v tune parameter.
 
static const size_t TORQUE_WIN_SIZE = 4
 Torque sliding window size for low-pass band filtering of input torques.
 
static const int TORQUE_CTL_BACKOFF_SPEED = 100
 Torque control backoff speed (raw unitless)
 
static const int TORQUE_CTL_BACKOFF_POS = 5
 Torque control backoff positon (odometer ticks)
 

Detailed Description

Special wrist rotation joint kinematics and dynamics class.

The Hekateros wrist joints are coupled in that wrist pitch effect wrist rotation. This class "decouples" these joints in software.

Definition at line 1143 of file hekKinJoint.h.

Constructor & Destructor Documentation

hekateros::HekKinJointWristRot::HekKinJointWristRot ( HekRobotJoint pJoint,
DynaServo *  pServo,
const HekTunes tunes 
)
inline

Initialization constructor.

Parameters
pJointPointer to joint description.
pServoPointer to master servo controller.
tunesHekateros tuning parameters.

Definition at line 1162 of file hekKinJoint.h.

1164  :
1165  HekKinJoint(pJoint, pServo, tunes)
1166  {
1167  m_pKinJointWristPitch = NULL;
1169  }
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
no active goal or stopping control
Definition: hekKinJoint.h:437
HekKinJoint()
Default constructor.

Member Function Documentation

int HekKinJointWristRot::act ( )
virtual

Act (write) to effect the servo dynamics for torque and motion control.

Since the wrist rotation is coupled to wrist pitch, if the pitch is moving, so must the rotation.

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

Reimplemented from hekateros::HekKinJoint.

Definition at line 1519 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::canMoveInGoalDir(), hekateros::HEK_OK, hekateros::HekKinJoint::isMovingToGoal(), hekateros::HekKinJoint::isStopped(), hekateros::HekKinJoint::lock(), hekateros::HekKinJoint::m_bOverTorqueCond, hekateros::HekKinJoint::m_fJointGoalPos, hekateros::HekKinJoint::m_fJointGoalVel, hekateros::HekKinJoint::MoveStateIdle, hekateros::HekKinJoint::nlapplyTorqueControl(), hekateros::HekKinJoint::nlmove(), hekateros::HekKinJoint::nlspecifyMove(), and hekateros::HekKinJoint::unlock().

1520 {
1521  lock();
1522 
1524 
1526 
1527  if( isStopped() && isCoupledJointStopped() &&
1528  (eStatePrev != MoveStateIdle) )
1529  {
1531  }
1532 
1533  //
1534  // Actively moving wrist rotation and/or wrist pitch and there is no over
1535  // torque condition or the goal direction will naturally ease the torque.
1536  //
1538  {
1539  nlmove();
1540  }
1541 
1542  //
1543  // In over torque condition, apply torque control.
1544  //
1545  else if( m_bOverTorqueCond )
1546  {
1548  }
1549 
1550  unlock();
1551 
1552  return HEK_OK;
1553 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
virtual int nlapplyTorqueControl()
Apply torque limit control (no lock version).
void lock()
Lock the joint kinematics.
Definition: hekKinJoint.h:874
void unlock()
Unlock the joint kinematics.
Definition: hekKinJoint.h:888
double m_fJointGoalPos
joint goal position (radians)
Definition: hekKinJoint.h:825
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
virtual bool isCoupledJointStopped()
Test if coupled joint is stopped.
Definition: hekKinJoint.h:1288
bool isMovingToGoal()
Test if actively moving joint to goal.
Definition: hekKinJoint.h:521
no active goal or stopping control
Definition: hekKinJoint.h:437
virtual int nlspecifyMove(const double fGoalPos, const double fGoalVel)
Specify a new joint goal position and velocity move (no lock version).
virtual bool isStopped()
Test if joint is stopped (i.e. control is not active).
Definition: hekKinJoint.h:551
virtual MoveState nlmove()
Move joint using joint PID controller (no lock version).
double m_fJointGoalVel
joint goal velocity (radians/second)
Definition: hekKinJoint.h:841
bool canMoveInGoalDir()
Test if joint can move in direction of goal position.
virtual bool isCoupledJointMoving()
Test if coupled joint is moving.
Definition: hekKinJoint.h:1298
MoveState getCoupledJointState()
Get coupled joint&#39;s move state.
bool m_bOverTorqueCond
is [not] in torque overload condition
Definition: hekKinJoint.h:854
MoveState
Kinedynamics joint position and velocity control states.
Definition: hekKinJoint.h:435
virtual void hekateros::HekKinJointWristRot::coupleJoint ( HekKinJoint pKinJointWristPitch)
inlinevirtual

Couple joint.

Parameters
pKinJointWristPitchWrist pitch joint kinematics.

Reimplemented from hekateros::HekKinJoint.

Definition at line 1198 of file hekKinJoint.h.

References hekateros::HekKinJoint::getMoveState().

1199  {
1200  m_pKinJointWristPitch = pKinJointWristPitch;
1201  if( m_pKinJointWristPitch != NULL )
1202  {
1204  }
1205  }
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
MoveState getMoveState()
Get move control state for this joint.
Definition: hekKinJoint.h:511
HekKinJoint::MoveState HekKinJointWristRot::getCoupledJointState ( )
protected

Get coupled joint's move state.

Returns
State.

Definition at line 1712 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::MoveStateIdle.

1713 {
1714  if( m_pKinJointWristPitch != NULL )
1715  {
1717  }
1718  else
1719  {
1720  return MoveStateIdle;
1721  }
1722 }
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
no active goal or stopping control
Definition: hekKinJoint.h:437
MoveState getMoveState()
Get move control state for this joint.
Definition: hekKinJoint.h:511
virtual bool hekateros::HekKinJointWristRot::isCoupledJointMoving ( )
inlineprotectedvirtual

Test if coupled joint is moving.

Returns
Returns true if moving, false otherwise.

Definition at line 1298 of file hekKinJoint.h.

1299  {
1300  return !isCoupledJointStopped();
1301  }
virtual bool isCoupledJointStopped()
Test if coupled joint is stopped.
Definition: hekKinJoint.h:1288
virtual bool hekateros::HekKinJointWristRot::isCoupledJointStopped ( )
inlineprotectedvirtual

Test if coupled joint is stopped.

Returns
Returns true if stopped, false otherwise.

Definition at line 1288 of file hekKinJoint.h.

1289  {
1290  return getCoupledJointState() == MoveStateIdle;
1291  }
no active goal or stopping control
Definition: hekKinJoint.h:437
MoveState getCoupledJointState()
Get coupled joint&#39;s move state.
int HekKinJointWristRot::jointPosToServoPos ( double  fPos)
virtual

Convert joint position to the equivalent servo position.

Adjust for wrist pitch.

Parameters
fPosJoint position (radians).
Returns
Equivalent servo position (odometer ticks).

Reimplemented from hekateros::HekKinJoint.

Definition at line 1666 of file hekKinJoint.cxx.

References hekateros::HekRobotJoint::m_fTicksPerJointRad, and hekateros::HekKinJoint::m_pJoint.

1667 {
1668  int nAdjustPos = 0, nAdjustSpeed = 0;
1669  int nServoPos;
1670 
1671  if( m_pKinJointWristPitch != NULL )
1672  {
1673  m_pKinJointWristPitch->getServoCurPosSpeed(nAdjustPos, nAdjustSpeed);
1674  }
1675 
1676  nServoPos = (int)(fPos * m_pJoint->m_fTicksPerJointRad);
1677 
1678  return nServoPos + nAdjustPos;
1679 }
HekRobotJoint * m_pJoint
joint description
Definition: hekKinJoint.h:814
double m_fTicksPerJointRad
encoder/odom. ticks per joint radian
Definition: hekJoint.h:157
void getServoCurPosSpeed(int &nServoCurPos, int &nServoCurSpeed) const
Get the instantaneous current servo position and speed.
Definition: hekKinJoint.h:674
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
HekKinJoint::MoveState HekKinJointWristRot::nlmove ( )
protectedvirtual

Move joint using joint PID controller (no lock version).

Once the move has reached the goal joint position, within tolerence, the move will automatically stop.

Since the wrist rotation is coupled to wrist pitch, if the pitch is moving, so must the rotation.

Returns
Move control state after call.

Reimplemented from hekateros::HekKinJoint.

Definition at line 1555 of file hekKinJoint.cxx.

References hekateros::HekPid::control(), hekateros::HekKinJoint::estimateServoTgtSpeed(), hekateros::HekKinJoint::isMovingToGoal(), hekateros::HekKinJoint::jointPosToServoPos(), hekateros::HekKinJoint::m_eState, hekateros::HekKinJoint::m_fDt, hekateros::HekKinJoint::m_fJointCurPos, hekateros::HekKinJoint::m_fJointCurVel, hekateros::HekKinJoint::m_fJointGoalPos, hekateros::HekKinJoint::m_fJointTgtVel, hekateros::HekKinJoint::m_fTolPos, hekateros::HekKinJoint::m_fTolVel, hekateros::HekKinJoint::m_nServoGoalPos, hekateros::HekKinJoint::m_nServoTgtSpeed, hekateros::HekKinJoint::m_pid, hekateros::HekKinJoint::moveServo(), hekateros::HekKinJoint::MoveStateIdle, hekateros::HekKinJoint::MoveStateNewMove, and hekateros::HekKinJoint::nlstop().

1556 {
1557  double fAdjustVel;
1558  int fAdjustSpeed;
1559 
1561  {
1562  m_pKinJointWristPitch->getTgtVelSpeed(fAdjustVel, fAdjustSpeed);
1563  }
1564  else
1565  {
1566  fAdjustVel = 0.0;
1567  fAdjustSpeed = 0;
1568  }
1569 
1571  {
1572  // still away from goal position
1573  if( (fabs(m_fJointGoalPos-m_fJointCurPos) > m_fTolPos) ||
1575  {
1576  // servo goal od position can change with coupled joints - recalculate
1578 
1579  if( isMovingToGoal() )
1580  {
1581  // PID target velocity
1583 
1584  // estimate corresponding target servo speed
1586  }
1587  else
1588  {
1589  m_fJointTgtVel = 0.0;
1590  m_nServoTgtSpeed = 0;
1591  }
1592 
1593  m_nServoTgtSpeed -= fAdjustSpeed;
1594 
1595  // new move - make it happen
1596  if( m_eState == MoveStateNewMove )
1597  {
1599  }
1600 
1601  // subsequent changes of servo speed - only if sufficently different
1602  else if( fabs(m_fJointTgtVel-m_fJointCurVel) > m_fTolVel )
1603  {
1605  }
1606  }
1607 
1608  // at goal position
1609  else
1610  {
1611  nlstop();
1612  }
1613  }
1614 
1615  return m_eState;
1616 }
virtual int jointPosToServoPos(double fPos)
Convert joint position to the equivalent servo position.
virtual int estimateServoTgtSpeed(double fJointTgtVel)
Estimate of target servo speed from target joint velocity.
virtual int nlstop()
Stop movement and move control of the joint (no lock version).
int m_nServoGoalPos
servo goal position (odometer ticks)
Definition: hekKinJoint.h:826
double m_fTolPos
joint position &plusmn; tolerance (rads)
Definition: hekKinJoint.h:818
MoveState m_eState
joint control state
Definition: hekKinJoint.h:812
int m_nServoTgtSpeed
target motor speed (raw unitless)
Definition: hekKinJoint.h:851
double m_fDt
delta time between positions reads
Definition: hekKinJoint.h:835
double m_fJointGoalPos
joint goal position (radians)
Definition: hekKinJoint.h:825
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
virtual double control(double fJointCurPos, double fJointCurVel, double fDt)
Apply PID control.
Definition: hekPid.h:203
void moveServo(int nServoGoalSpeed, int nServoGoalPos)
Move servo.
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
void getTgtVelSpeed(double &fTgtVel, int &nTgtSpeed) const
Get the PID output target joint velocity and the corresponding servo speed estemate.
Definition: hekKinJoint.h:687
double m_fJointCurPos
joint current position (radians)
Definition: hekKinJoint.h:827
bool isMovingToGoal()
Test if actively moving joint to goal.
Definition: hekKinJoint.h:521
no active goal or stopping control
Definition: hekKinJoint.h:437
HekPid m_pid
joint position and velocity PID
Definition: hekKinJoint.h:821
double m_fJointCurVel
joint current velocity (radians/second)
Definition: hekKinJoint.h:842
double m_fJointTgtVel
joint target velocity (radians/second)
Definition: hekKinJoint.h:850
virtual bool isCoupledJointMoving()
Test if coupled joint is moving.
Definition: hekKinJoint.h:1298
double m_fTolVel
joint velocity &plusmn; tolerance (rads/s)
Definition: hekKinJoint.h:819
int HekKinJointWristRot::nlslowToStop ( SyncMoveMsgs msg)
protectedvirtual

Slow to stop (no lock version).

Since the wrist rotation is coupled to wrist pitch, if the pitch is moving, so must the rotation. Slowing down must take this coupled action into account.

Parameters
msgsSynchronous move messages container object.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Reimplemented from hekateros::HekKinJoint.

Definition at line 1618 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::addServoMsgEntries(), hekateros::HekKinJoint::estimateServoTgtSpeed(), hekateros::HEK_OK, hekateros::HekKinJoint::m_fJointCurVel, hekateros::HekKinJoint::m_fStopVelTh, hekateros::HekKinJoint::m_nServoGoalPos, and hekateros::HekKinJoint::nlstop().

1619 {
1620  double fAdjustVel;
1621  int fAdjustSpeed;
1622  double fJointStopVel;
1623  int nServoStopSpeed;
1624 
1625  if( (fabs(m_fJointCurVel) <= m_fStopVelTh) )
1626  {
1627  //fprintf(stderr, "DBG: %s() SLOWED ENOUGH: curvel=%lf\n",
1628  // LOGFUNCNAME, radToDeg(m_fJointCurVel));
1629 
1630  return nlstop();
1631  }
1632  else
1633  {
1634  if( m_fJointCurVel > 0.0 )
1635  {
1636  fJointStopVel = m_fJointCurVel - m_fStopVelTh;
1637  }
1638  else
1639  {
1640  fJointStopVel = m_fJointCurVel + m_fStopVelTh;
1641  }
1642 
1643  nServoStopSpeed = estimateServoTgtSpeed(fJointStopVel);
1644 
1645  if( isCoupledJointMoving() )
1646  {
1647  m_pKinJointWristPitch->getTgtVelSpeed(fAdjustVel, fAdjustSpeed);
1648  }
1649  else
1650  {
1651  fAdjustVel = 0.0;
1652  fAdjustSpeed = 0;
1653  }
1654 
1655  nServoStopSpeed -= fAdjustSpeed;
1656 
1657  addServoMsgEntries(msgs, nServoStopSpeed, m_nServoGoalPos);
1658 
1659  //fprintf(stderr, "DBG: %s() SLOWING TO: curvel=%lf, stopvel=%lf\n",
1660  // LOGFUNCNAME, radToDeg(m_fJointCurVel), radToDeg(fJointStopVel));
1661 
1662  return HEK_OK;
1663  }
1664 }
virtual int estimateServoTgtSpeed(double fJointTgtVel)
Estimate of target servo speed from target joint velocity.
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
double m_fStopVelTh
joint velocity threshold to safely stop move
Definition: hekKinJoint.h:820
virtual int nlstop()
Stop movement and move control of the joint (no lock version).
int m_nServoGoalPos
servo goal position (odometer ticks)
Definition: hekKinJoint.h:826
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
void getTgtVelSpeed(double &fTgtVel, int &nTgtSpeed) const
Get the PID output target joint velocity and the corresponding servo speed estemate.
Definition: hekKinJoint.h:687
void addServoMsgEntries(SyncMoveMsgs &msg, int nServoGoalSpeed, int nServoGoalPos)
Add servo to synchronous move message(s).
double m_fJointCurVel
joint current velocity (radians/second)
Definition: hekKinJoint.h:842
virtual bool isCoupledJointMoving()
Test if coupled joint is moving.
Definition: hekKinJoint.h:1298
HekKinJointWristRot& hekateros::HekKinJointWristRot::operator= ( const HekKinJointWristRot rhs)
inline

Assignment operator.

Parameters
rhsRight hand side object.
Returns
*this

Definition at line 1185 of file hekKinJoint.h.

References m_eStateWristPitch, and m_pKinJointWristPitch.

1186  {
1187  m_pKinJointWristPitch = rhs.m_pKinJointWristPitch;
1188  m_eStateWristPitch = rhs.m_eStateWristPitch;
1189 
1190  return *this;
1191  }
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
HekKinJoint::MoveState HekKinJointWristRot::planMotion ( bool  bIsControlling,
SyncMoveMsgs msgs 
)
virtual

Plan motion.

Parameters
bIsControllingJoint is [not] being actively controlled. However, planning may still be desired.
msgsSynchronous move messages container object.
Returns
Move control state after call.

Reimplemented from hekateros::HekKinJoint.

Definition at line 1444 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::addServoMsgEntries(), hekateros::HekKinJoint::canMoveInPlannedDir(), hekateros::HekPid::control(), hekateros::HekKinJoint::estimateServoTgtSpeed(), hekateros::HekKinJoint::isMovingToGoal(), hekateros::HekKinJoint::jointPosToServoPos(), hekateros::HekKinJoint::lock(), hekateros::HekKinJoint::m_eState, hekateros::HekKinJoint::m_fDt, hekateros::HekKinJoint::m_fJointCurPos, hekateros::HekKinJoint::m_fJointCurVel, hekateros::HekKinJoint::m_fJointGoalPos, hekateros::HekKinJoint::m_fJointTgtVel, hekateros::HekKinJoint::m_fTolPos, hekateros::HekKinJoint::m_fTolVel, hekateros::HekKinJoint::m_nServoGoalPos, hekateros::HekKinJoint::m_nServoTgtSpeed, hekateros::HekKinJoint::m_pid, hekateros::HekKinJoint::m_pServo, hekateros::HekKinJoint::MoveStateIdle, hekateros::HekKinJoint::MoveStateNewMove, and hekateros::HekKinJoint::unlock().

1446 {
1447  double fAdjustVel;
1448  int fAdjustSpeed;
1449 
1450  if( m_pServo == NULL )
1451  {
1452  return MoveStateIdle;
1453  }
1454  else if( !bIsControlling )
1455  {
1456  return m_eState;
1457  }
1458 
1459  lock();
1460 
1462 
1463  if( isCoupledJointMoving() )
1464  {
1465  m_pKinJointWristPitch->getTgtVelSpeed(fAdjustVel, fAdjustSpeed);
1466  }
1467  else
1468  {
1469  fAdjustVel = 0.0;
1470  fAdjustSpeed = 0;
1471  }
1472 
1474  {
1475  // servo goal od position can change with coupled joints - recalculate
1477 
1478  if( isMovingToGoal() )
1479  {
1480  // PID target velocity
1482 
1483  // estimate corresponding target servo speed
1485  }
1486  else
1487  {
1488  m_fJointTgtVel = 0.0;
1489  m_nServoTgtSpeed = 0;
1490  }
1491 
1492  m_nServoTgtSpeed -= fAdjustSpeed;
1493 
1494  // still away from goal position
1495  if( ( (fabs(m_fJointGoalPos-m_fJointCurPos) > m_fTolPos) ||
1496  isCoupledJointMoving() ) &&
1498  {
1499  // new move - make it happen
1500  if( (m_eState == MoveStateNewMove) ||
1502  {
1504  }
1505 
1506  // subsequent changes of servo speed - only if sufficently different
1507  else if( fabs(m_fJointTgtVel-m_fJointCurVel) > m_fTolVel )
1508  {
1510  }
1511  }
1512  }
1513 
1514  unlock();
1515 
1516  return m_eState;
1517 }
virtual int jointPosToServoPos(double fPos)
Convert joint position to the equivalent servo position.
virtual int estimateServoTgtSpeed(double fJointTgtVel)
Estimate of target servo speed from target joint velocity.
DynaServo * m_pServo
joint master servo control
Definition: hekKinJoint.h:815
int m_nServoGoalPos
servo goal position (odometer ticks)
Definition: hekKinJoint.h:826
bool canMoveInPlannedDir(int nServoTgtSpeed)
Test if joint can move in planned direction.
double m_fTolPos
joint position &plusmn; tolerance (rads)
Definition: hekKinJoint.h:818
void lock()
Lock the joint kinematics.
Definition: hekKinJoint.h:874
void unlock()
Unlock the joint kinematics.
Definition: hekKinJoint.h:888
MoveState m_eState
joint control state
Definition: hekKinJoint.h:812
int m_nServoTgtSpeed
target motor speed (raw unitless)
Definition: hekKinJoint.h:851
double m_fDt
delta time between positions reads
Definition: hekKinJoint.h:835
double m_fJointGoalPos
joint goal position (radians)
Definition: hekKinJoint.h:825
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
virtual double control(double fJointCurPos, double fJointCurVel, double fDt)
Apply PID control.
Definition: hekPid.h:203
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
void getTgtVelSpeed(double &fTgtVel, int &nTgtSpeed) const
Get the PID output target joint velocity and the corresponding servo speed estemate.
Definition: hekKinJoint.h:687
double m_fJointCurPos
joint current position (radians)
Definition: hekKinJoint.h:827
void addServoMsgEntries(SyncMoveMsgs &msg, int nServoGoalSpeed, int nServoGoalPos)
Add servo to synchronous move message(s).
bool isMovingToGoal()
Test if actively moving joint to goal.
Definition: hekKinJoint.h:521
no active goal or stopping control
Definition: hekKinJoint.h:437
HekPid m_pid
joint position and velocity PID
Definition: hekKinJoint.h:821
double m_fJointCurVel
joint current velocity (radians/second)
Definition: hekKinJoint.h:842
double m_fJointTgtVel
joint target velocity (radians/second)
Definition: hekKinJoint.h:850
virtual bool isCoupledJointMoving()
Test if coupled joint is moving.
Definition: hekKinJoint.h:1298
double m_fTolVel
joint velocity &plusmn; tolerance (rads/s)
Definition: hekKinJoint.h:819
MoveState getCoupledJointState()
Get coupled joint&#39;s move state.
int HekKinJointWristRot::react ( bool  bIsControlling,
SyncMoveMsgs msgs 
)
virtual

React to recently read sensor data.

Parameters
bIsControllingJoint is [not] being actively controlled. However, reaction may still be desired.
msgsSynchronous move messages container object.
Returns
On success, HEK_OK is returned.
On error, the appropriate < 0 negated Hekateros Error Code is returned.

Reimplemented from hekateros::HekKinJoint.

Definition at line 1383 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::canStopNow(), hekateros::HEK_OK, hekateros::HekKinJoint::isMovingToGoal(), hekateros::HekKinJoint::isStopped(), hekateros::HekKinJoint::isStopping(), hekateros::HekKinJoint::lock(), hekateros::HekKinJoint::m_bOverTorqueCond, hekateros::HekKinJoint::m_fJointCurPos, hekateros::HekKinJoint::m_fJointGoalPos, hekateros::HekKinJoint::m_fJointGoalVel, hekateros::HekKinJoint::m_fTolPos, hekateros::HekKinJoint::MoveStateIdle, hekateros::HekKinJoint::nlapplyTorqueControl(), hekateros::HekKinJoint::nlslowToStop(), hekateros::HekKinJoint::nlspecifyMove(), hekateros::HekKinJoint::nlstop(), and hekateros::HekKinJoint::unlock().

1384 {
1385  if( !bIsControlling )
1386  {
1387  return HEK_OK;
1388  }
1389 
1390  lock();
1391 
1393 
1395 
1396  //
1397  // Wrist rotation is not moving and wrist pitch has transitioned from moving
1398  // to stop. Respecify wrist rotation goal move to avoid minor wrist rotation
1399  // drift.
1400  //
1401  if( isStopped() )
1402  {
1403  if( isCoupledJointStopped() && (eStatePrev != MoveStateIdle) )
1404  {
1405  //fprintf(stderr, "DBG: %s() isStopped - respecify move\n", LOGFUNCNAME);
1407  }
1408  }
1409 
1410  //
1411  // Joint is slowing to a stop.
1412  //
1413  else if( isStopping() )
1414  {
1415  //fprintf(stderr, "DBG: %s() isStopping\n", LOGFUNCNAME);
1416  nlslowToStop(msgs);
1417  }
1418 
1419  //
1420  // Joint has moved close enough to goal position, and is slow enough to stop.
1421  // Otherwise let the PID do its thing.
1422  //
1423  else if( isMovingToGoal() &&
1425  canStopNow() )
1426  {
1427  nlstop();
1428  //fprintf(stderr, "DBG: %s() stop\n", LOGFUNCNAME);
1429  }
1430 
1431  //
1432  // In over torque condition, apply torque control.
1433  //
1434  if( m_bOverTorqueCond )
1435  {
1437  }
1438 
1439  unlock();
1440 
1441  return HEK_OK;
1442 }
static const int HEK_OK
not an error, success
Definition: hekateros.h:70
virtual int nlapplyTorqueControl()
Apply torque limit control (no lock version).
virtual int nlstop()
Stop movement and move control of the joint (no lock version).
virtual int nlslowToStop(SyncMoveMsgs &msg)
Slow to stop (no lock version).
double m_fTolPos
joint position &plusmn; tolerance (rads)
Definition: hekKinJoint.h:818
void lock()
Lock the joint kinematics.
Definition: hekKinJoint.h:874
void unlock()
Unlock the joint kinematics.
Definition: hekKinJoint.h:888
double m_fJointGoalPos
joint goal position (radians)
Definition: hekKinJoint.h:825
MoveState m_eStateWristPitch
joint control state
Definition: hekKinJoint.h:1264
virtual bool isCoupledJointStopped()
Test if coupled joint is stopped.
Definition: hekKinJoint.h:1288
double m_fJointCurPos
joint current position (radians)
Definition: hekKinJoint.h:827
bool isMovingToGoal()
Test if actively moving joint to goal.
Definition: hekKinJoint.h:521
no active goal or stopping control
Definition: hekKinJoint.h:437
virtual int nlspecifyMove(const double fGoalPos, const double fGoalVel)
Specify a new joint goal position and velocity move (no lock version).
virtual bool isStopped()
Test if joint is stopped (i.e. control is not active).
Definition: hekKinJoint.h:551
double m_fJointGoalVel
joint goal velocity (radians/second)
Definition: hekKinJoint.h:841
bool canStopNow()
Test if can stop now without slowing down.
Definition: hekKinJoint.h:561
bool isStopping()
Test if actively stopping joint.
Definition: hekKinJoint.h:531
MoveState getCoupledJointState()
Get coupled joint&#39;s move state.
bool m_bOverTorqueCond
is [not] in torque overload condition
Definition: hekKinJoint.h:854
MoveState
Kinedynamics joint position and velocity control states.
Definition: hekKinJoint.h:435
double HekKinJointWristRot::servoPosToJointPos ( int  nOdPos)
virtual

Convert servo position to the equivalent joint position.

Adjust for wrist pitch.

Parameters
nOdPosServo position (odometer ticks).
Returns
Equivalent joint position (radian).

Reimplemented from hekateros::HekKinJoint.

Definition at line 1681 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::m_fJointRadPerTick.

1682 {
1683  double fAdjustPos = 0, fAdjustVel = 0;
1684  double fJointPos;
1685 
1686  if( m_pKinJointWristPitch != NULL )
1687  {
1688  m_pKinJointWristPitch->getJointCurPosVel(fAdjustPos, fAdjustVel);
1689  }
1690 
1691  fJointPos = (double)nOdPos * m_fJointRadPerTick;
1692 
1693  return fJointPos - fAdjustPos;
1694 }
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
double m_fJointRadPerTick
joint radians / odometer tick
Definition: hekKinJoint.h:824
void getJointCurPosVel(double &fCurPos, double &fCurVel) const
Get the instantaneous current joint position and velocity.
Definition: hekKinJoint.h:650
void HekKinJointWristRot::updateAssoc ( double  fJointVel,
int  nServoSpeed 
)
protectedvirtual

Update joint velocity - servo speed association.

Adjustment is made for wrist pitch current velocity.

Parameters
fJointVelJoint velocity (radians/second).
nServoSpeedServo speed (raw unitless).

Reimplemented from hekateros::HekKinJoint.

Definition at line 1696 of file hekKinJoint.cxx.

References hekateros::HekKinJoint::m_tblVelSpeed, hekateros::HekKinJoint::MoveStateIdle, and hekateros::VelSpeedLookupTbl::update().

1697 {
1698  double fAdjustPos = 0.0, fAdjustVel = 0.0;
1699 
1700  if( m_pKinJointWristPitch != NULL )
1701  {
1702  m_pKinJointWristPitch->getJointCurPosVel(fAdjustPos, fAdjustVel);
1703  }
1704 
1705  // pure wrist rotation move only
1706  if( (fAdjustVel == 0.0) && (getCoupledJointState() == MoveStateIdle) )
1707  {
1708  m_tblVelSpeed.update(fJointVel, nServoSpeed);
1709  }
1710 }
void update(double fJointVel, int nServoSpeed)
Update lookup table entry.
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
Definition: hekKinJoint.h:1263
no active goal or stopping control
Definition: hekKinJoint.h:437
VelSpeedLookupTbl m_tblVelSpeed
dynamic velocity/speed lookup table
Definition: hekKinJoint.h:845
void getJointCurPosVel(double &fCurPos, double &fCurVel) const
Get the instantaneous current joint position and velocity.
Definition: hekKinJoint.h:650
MoveState getCoupledJointState()
Get coupled joint&#39;s move state.

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