48 #ifndef _HEK_KIN_JOINT_H 49 #define _HEK_KIN_JOINT_H 58 #include "rnr/rnrconfig.h" 61 #include "Dynamixel/Dynamixel.h" 62 #include "Dynamixel/DynaError.h" 63 #include "Dynamixel/DynaTypes.h" 64 #include "Dynamixel/DynaPid.h" 65 #include "Dynamixel/DynaServo.h" 75 #define HEK_KIN_EXEC_ALG_SYNC 77 #ifdef HEK_KIN_EXEC_ALG_SYNC 78 #undef HEK_KIN_EXEC_ALG_INDIV 80 #define HEK_KIN_EXEC_ALG_INDIV 81 #endif // HEK_KIN_EXEC_ALG_SYNC
123 int addSpeed(
int nServoId,
int nServoSpeed);
135 int addOdPos(
int nServoId,
int nServoPos);
209 VelSpeedTuple(
const double fJointVel,
const int nServoSpeed);
256 static const int NO_ENTRY = -1;
259 static const int MIN_NON_ZERO_SPEED = 10;
288 void create(
double fJointMaxVel,
double fBucketSize);
297 int hash(
double fJointVel);
305 void update(
double fJointVel,
int nServoSpeed);
317 int estimate(
double fJointGoalVel);
326 return (
int)m_tbl.size();
336 return m_nNumEntries;
346 void enableDebugging(
const std::string &strId);
351 void disableDebugging();
360 void dumpTable(
const std::string &strId);
394 static const size_t POS_WIN_SIZE = 6;
400 static const size_t DT_WIN_SIZE = 10;
406 static const size_t VEL_WIN_SIZE = 6;
417 static const size_t TORQUE_WIN_SIZE = 4;
422 static const int TORQUE_CTL_BACKOFF_SPEED = 100;
427 static const int TORQUE_CTL_BACKOFF_POS = 5;
472 pthread_mutex_destroy(&m_mutexSync);
499 virtual void reload(
const HekTunes &tunes);
523 return m_eState == MoveStateNewMove || m_eState == MoveStateMoving;
533 return m_eState == MoveStateStopping;
543 return isMovingToGoal() || isStopping();
553 return m_eState == MoveStateIdle;
565 (fabs(m_fJointCurVel) <= m_fStopVelTh);
577 m_pid.getKParams(fKp, fKi, fKd);
591 m_pid.setKParams(fKp, fKi, fKd);
601 return m_pid.getMaxDeltaVParam();
611 m_pid.setMaxDeltaVParam(fMaxDeltaV);
652 fCurPos = m_fJointCurPos;
653 fCurVel = m_fJointCurVel;
664 fCurPos = m_fJointPosOut;
665 fCurVel = m_fJointVelOut;
676 nServoCurPos = m_nServoCurPos;
677 nServoCurSpeed = m_nServoCurSpeed;
689 fTgtVel = m_fJointTgtVel;
690 nTgtSpeed = m_nServoTgtSpeed;
700 return m_bOverTorqueCond;
710 virtual int jointPosToServoPos(
const double fPos);
719 virtual double servoPosToJointPos(
const int nOdPos);
731 virtual int resetServoOdometer();
744 int specifyMove(
const double fGoalPos,
const double fGoalVel);
754 virtual int senseDynamics(
bool bIsControlling);
765 virtual int react(
bool bIsControlling,
SyncMoveMsgs &msgs);
791 virtual int applyTorqueControl();
836 struct timespec m_tsPrev;
876 pthread_mutex_lock(&m_mutexSync);
890 pthread_mutex_unlock(&m_mutexSync);
911 double averageDt(
double fDtAvg,
double fDt);
923 int dejitterServoPos(
int nServoCurPos,
int nServoPrevPos);
936 double filterPositions(
double fPosAvg,
double fJointPos);
950 double filterVelocities(
double fVelAvg,
double fJointVel);
966 double filterTorques(
double fTorqueAvg,
int nServoLoad);
994 int getPlannedDir(
int nServoTgtSpeed);
1004 bool canMoveInGoalDir();
1016 bool canMoveInPlannedDir(
int nServoTgtSpeed);
1027 virtual double jointVelocity(
double fPos1,
double fPos0,
double fDt);
1035 virtual void updateAssoc(
double fJointVel,
int nServoSpeed);
1048 virtual int estimateServoTgtSpeed(
double fJointTgtVel);
1061 virtual int estimateServoTgtSpeedSimple(
double fJointTgtVel);
1070 void moveServo(
int nServoGoalSpeed,
int nServoGoalPos);
1081 int nServoGoalSpeed,
1096 virtual int nlspecifyMove(
const double fGoalPos,
const double fGoalVel);
1103 virtual int nlapplyTorqueControl();
1120 virtual int nlstop();
1151 m_pKinJointWristPitch = NULL;
1152 m_eStateWristPitch = MoveStateIdle;
1167 m_pKinJointWristPitch = NULL;
1168 m_eStateWristPitch = MoveStateIdle;
1200 m_pKinJointWristPitch = pKinJointWristPitch;
1201 if( m_pKinJointWristPitch != NULL )
1203 m_eStateWristPitch = m_pKinJointWristPitch->
getMoveState();
1216 virtual int react(
bool bIsControlling,
SyncMoveMsgs &msgs);
1227 virtual MoveState planMotion(
bool bIsControlling,
SyncMoveMsgs &msgs);
1249 virtual int jointPosToServoPos(
double fPos);
1260 virtual double servoPosToJointPos(
int nOdPos);
1274 virtual void updateAssoc(
double fJointVel,
int nServoSpeed);
1281 MoveState getCoupledJointState();
1290 return getCoupledJointState() == MoveStateIdle;
1300 return !isCoupledJointStopped();
1314 virtual MoveState nlmove();
1332 #endif // _HEK_KIN_JOINT_H int addSpeed(int nServoId, int nServoSpeed)
Add servo speed to speed tuple array.
int getNumLookupTableEntries()
Get the number of populated entries in lookup table.
double m_fOverTorqueTh
set over torque condition threshold
int getLookupTableSize()
Get the lookup table fixed size.
DynaPosTuple_T m_tupOdPos[DYNA_ID_NUMOF]
position tuple array
double getPidMaxDeltaVParam() const
Get joint PID maximum delta v (radians/second) parameter.
VelSpeedTbl m_tbl
dynamic interpolation table
DynaSpeedTuple_T * getSpeedTuples()
Get the speed tuple array.
bool isMoving()
Test if actively moving joint.
double m_fVelDerate
joint velocity derate (normalized)
int m_nServoCurLoad
servo current load (raw unitless)
DynaPosTuple_T * getOdPosTuples()
Get the position tuple array.
static const double HekTunePidDeltaVNoMax
No maximum PID delta V output special value.
std::deque< double > m_histPosIn
recent history of joint positions
double m_fStopVelTh
joint velocity threshold to safely stop move
uint_t getSpeedTupleCount()
Get the number of added speed tuples to speed tuple array.
HekRobotJoint * m_pJoint
joint description
~VelSpeedLookupTbl()
Destructor.
int m_nServoCurPos
servo current position (odometer ticks)
Operational robotic joint description class.
static const double SLOW_DERATE_DELTA_V
Stop delta v as a fraction of max_delta_v tune parameter.
DynaServo * m_pServo
joint master servo control
int m_nNumEntries
number of populated table entries.
double m_fJointVelOut
low-pass filtered joint cur velocity
int m_nServoCurSpeed
current motor speed (raw unitless)
int m_nServoGoalPos
servo goal position (odometer ticks)
std::deque< double > m_histTorqueIn
recent history of joint torques
HekKinJointWristRot()
Default constructor.
double m_fTolPos
joint position ± tolerance (rads)
int m_nMaxIndex
maximum index into table
void lock()
Lock the joint kinematics.
int addOdPos(int nServoId, int nServoPos)
Add servo position to position tuple array.
std::string m_strDbgId
debugging id
pthread_mutex_t m_mutexSync
synchonization mutex
void unlock()
Unlock the joint kinematics.
Hekateros tuning data class.
MoveState m_eState
joint control state
uint_t getOdPosTupleCount()
Get the number of added position tuples to position tuple array.
void getServoCurPosSpeed(int &nServoCurPos, int &nServoCurSpeed) const
Get the instantaneous current servo position and speed.
Container class to hold Dynamixel synchronous messages data.
int m_nServoTgtSpeed
target motor speed (raw unitless)
void setPidKParams(const double fKp, const double fKi, const double fKd)
Set the joint's position and velocity PID K parameters.
Hekateros powered joint dynamics and kinematics control class.
double m_fDt
delta time between positions reads
~VelSpeedTuple()
Destructor.
double m_fJointGoalPos
joint goal position (radians)
void getToleranceParams(double &fTolPos, double &fTolVel) const
Get the position and velocity tolerance parameters.
virtual ~HekKinJointWristRot()
Destructor.
HekKinJoint * m_pKinJointWristPitch
wrist pitch joint description
double m_fBucketSize
table entry size (degrees/second)
Joint velocity/ servo speed lookup table class.
SyncMoveMsgs()
Default constructor.
Hekateros joint classes interfaces.
double m_fJointPrevPos
joint current position (radians)
double m_fJointPosOut
low-pass filtered joint cur position
MoveState m_eStateWristPitch
joint control state
void getTgtVelSpeed(double &fTgtVel, int &nTgtSpeed) const
Get the PID output target joint velocity and the corresponding servo speed estemate.
virtual bool isCoupledJointStopped()
Test if coupled joint is stopped.
virtual void coupleJoint(HekKinJoint *pKinJointWristPitch)
Couple joint.
double m_fTorqueOut
low-pass filtered torque
std::deque< double > m_histDtIn
sliding window of delta t's
int m_nServoPrevPos
servo previous pos (odometer ticks)
double m_fJointRadPerTick
joint radians / odometer tick
void clear()
Clear sync messages.
void getPidKParams(double &fKp, double &fKi, double &fKd) const
Get the joint's position and velocity PID K parameters.
double m_fJointCurPos
joint current position (radians)
std::deque< double > m_histVelIn
sliding window of current velocities
double m_fJointVel
joint velocity (radians/second)
The Hekateros joint position and velocity PID class interface.
Top-level package include file.
bool isMovingToGoal()
Test if actively moving joint to goal.
no active goal or stopping control
virtual ~HekKinJoint()
Copy constructor.
void setPidMaxDeltaVParam(const double fMaxDeltaV)
Set joint PID maximum delta v (radians/second) parameter.
virtual void coupleJoint(HekKinJoint *)
Couple joint.
HekPid m_pid
joint position and velocity PID
virtual bool isStopped()
Test if joint is stopped (i.e. control is not active).
int m_nServoSpeed
associated servo speed (raw unitless)
double m_fJointCurVel
joint current velocity (radians/second)
VelSpeedLookupTbl m_tblVelSpeed
dynamic velocity/speed lookup table
double m_fJointGoalVel
joint goal velocity (radians/second)
virtual bool hasOverTorqueCondition()
Test if joint is in an over torque condition.
virtual ~SyncMoveMsgs()
Destructor.
uint_t m_uOdPosTupCount
positon tuple count
double m_fJointTgtVel
joint target velocity (radians/second)
void getJointCurPosVel(double &fCurPos, double &fCurVel) const
Get the instantaneous current joint position and velocity.
DynaSpeedTuple_T m_tupSpeed[DYNA_ID_NUMOF]
speed tuple array
Hekateros common utilities.
virtual bool isCoupledJointMoving()
Test if coupled joint is moving.
uint_t m_uSpeedTupCount
speed tuple count
void getFilteredJointCurPosVel(double &fCurPos, double &fCurVel) const
Get the smoothed (filtered) current joint position and velocity.
void setToleranceParams(const double fTolPos, const double fTolVel)
Set the position and velocity tolerance parameters.
double m_fDtAvg
average delta t
bool m_bDbg
enable [disable] debugging
double m_fTolVel
joint velocity ± tolerance (rads/s)
MoveState getMoveState()
Get move control state for this joint.
Joint velocity to servo speed tuple class.
bool canStopNow()
Test if can stop now without slowing down.
bool isStopping()
Test if actively stopping joint.
HekKinJointWristRot(HekRobotJoint *pJoint, DynaServo *pServo, const HekTunes &tunes)
Initialization constructor.
bool m_bOverTorqueCond
is [not] in torque overload condition
double m_fClearTorqueTh
clear over torque condition threshold
MoveState
Kinedynamics joint position and velocity control states.
Special wrist rotation joint kinematics and dynamics class.
std::vector< VelSpeedTuple > VelSpeedTbl
Velocity-speed table type.
HekKinJointWristRot & operator=(const HekKinJointWristRot &rhs)
Assignment operator.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...