Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaServo Class Referenceabstract

Dynamixel Servo Abstract Base Class. More...

#include <DynaServo.h>

Inheritance diagram for DynaServo:
DynaServoGeneric DynaServoAX12 DynaServoEX106P DynaServoMX106 DynaServoMX12W DynaServoMX28 DynaServoMX64 DynaServoRX10 DynaServoRX24F DynaServoRX28 DynaServoRX64

Classes

struct  CrossLink_T
 

Public Member Functions

 DynaServo (DynaComm &comm, int nServoId, uint_t uModelNum, uint_t uFwVer)
 Default initialization constructor. More...
 
virtual ~DynaServo ()
 Destructor.
 
virtual uint_t GetModelNumber () const
 Get servo model number. More...
 
virtual uint_t GetFirmwareVersion () const
 Get servo firmware version. More...
 
virtual const char * GetModelName () const
 Get servo model name string. More...
 
virtual uint_t GetServoId () const
 Get servo id. More...
 
virtual uint_t GetServoMode () const
 Get the servo operational mode. More...
 
virtual uint_t Has360PosInfo () const
 Test if servo has 360 ° positioning information. More...
 
virtual const DynaServoSpec_TGetSpecification () const
 Get servo specification. More...
 
virtual const DynaServoCfg_TGetConfiguration () const
 Get servo configuration. More...
 
virtual const DynaServoState_TGetState () const
 Get servo state. More...
 
bool IsMaster () const
 Test if this servo is a master. More...
 
bool IsLinkedMaster () const
 Test if this servo is a linked master. More...
 
bool IsUnlinked () const
 Test if this servo is unlinked. More...
 
virtual const DynaServoLink_T GetLinkInfo () const
 Get linked information. More...
 
virtual void Link (uint_t uLinkType, DynaServo *pServoMate, bool bRotReversed)
 Link this servo to another. More...
 
virtual void Unlink ()
 Unlink this servo.
 
int GetOdometer ()
 Get the current virtual odometer value. More...
 
int IsOdometerEnabled ()
 Test if virtual odometer mapping is enabled. More...
 
int GetOdometerZeroPt ()
 Get the virtual odometer zero point. More...
 
bool IsOdometerReversed ()
 Test if the virtual odometer is reversed. More...
 
int CalcOdometerAtEncMin ()
 Calculate the odometer value at the minimum (zero) encoder value. More...
 
int CalcOdometerAtEncMax ()
 Calculate the odometer value at the maximum encoder value. More...
 
int OdometerToEncoder (int nOdPos)
 Convert virtual odometer units to servo encoder units. More...
 
int CalcSpeedDir (int nOdGoalPos)
 Calculate serve direction to goal odometer position. More...
 
virtual int ResetOdometer (int nEncZeroPt, bool bIsReverse)
 Reset the servo's virtual odometer. More...
 
virtual int UpdateOdometer (int nEncCurPos)
 Update the odometer from the current servo position and rotation direction. More...
 
virtual void DisableOdometer ()
 Disable odometer mapping. More...
 
virtual uint_t GetAlarms () const
 Get the current servo alarms. More...
 
virtual uint_t GetCurPos () const
 Get the current servo position. More...
 
virtual int GetCurSpeed () const
 Get the current servo speed. More...
 
virtual int GetGoalSpeed () const
 Get the goal servo speed. More...
 
virtual int GetCurLoad () const
 Get the current servo load. More...
 
virtual uint_t GetCurTemp () const
 Get the current temperature. More...
 
virtual float CvtRawTempToC (uint uTemp)=0
 Convert raw temperature coding to degrees Celsius. More...
 
virtual uint_t GetCurVolt () const
 Get the current voltage. More...
 
virtual float CvtRawVoltToVolts (uint uVolts)=0
 Convert raw volts coding to volts. More...
 
virtual void SetSoftTorqueThresholds (uint_t uOverTorqueTh, uint_t uClearTorqueTh)
 Set soft torque thresholds. More...
 
virtual void GetSoftTorqueThresholds (uint_t &uOverTorqueTh, uint_t &uClearTorqueTh)
 Get soft torque thresholds. More...
 
virtual void SetSoftTorqueOverCond (bool bNewCond)
 Set or clear servo in soft over torque condition. More...
 
virtual bool HasSoftTorqueOverCond ()
 Test if servo is in a soft over torque condition. More...
 
virtual void RegisterAgent (DynaAgent_T *pAgent, void *pAgentArg)
 Register servo proxy agent. More...
 
virtual void UnregisterAgent ()
 Unregister servo proxy agent.
 
virtual bool HasAgent ()
 Tests if servo has a registered agent. More...
 
virtual int AgentWriteGoalPos (int nGoalPos)=0
 
virtual int AgentWriteGoalSpeed (int nGoalSpeed)=0
 
virtual int AgentWriteGoalSpeedPos (int nGoalSpeed, int nGoalPos)=0
 
virtual int MoveTo (int nGoalPos)=0
 
virtual int MoveAtSpeedTo (int nGoalSpeed, int nGoalPos)=0
 
virtual int MoveAtSpeed (int nGoalSpeed)=0
 
virtual int EStop ()=0
 
virtual int Stop ()=0
 
virtual int Freeze ()=0
 
virtual int Release ()=0
 
virtual int CfgReadRotationLimits (uint_t *pCwLim, uint_t *pCcwLim)=0
 
virtual int CfgWriteRotationLimits (uint_t uCwLim, uint_t uCcwLim)=0
 
virtual int CfgReadTemperatureLimit (uint_t *pTempLim)=0
 
virtual int CfgWriteTemperatureLimit (uint_t uTempLim)=0
 
virtual int CfgReadVoltageLimits (uint_t *pMinVoltLim, uint_t *pMaxVoltLim)=0
 
virtual int CfgWriteVoltageLimits (uint_t uMinVoltLim, uint_t uMaxVoltLim)=0
 
virtual int CfgReadMaxTorqueLimit (uint_t *pMaxTorqueLim)=0
 
virtual int CfgWriteMaxTorqueLimit (uint_t uMaxTorqueLim)=0
 
virtual int CfgReadAlarmShutdownMask (uint_t *pAlarmMask)=0
 
virtual int CfgWriteAlarmShutdownMask (uint_t uAlarmMask)=0
 
virtual int CfgReadServoMode (uint_t *pServoMode)=0
 
virtual int CfgWriteServoMode (uint_t uCwLim, uint_t uCcwLim)=0
 
virtual int CfgWriteServoModeContinuous ()=0
 
virtual int ReadTorqueEnable (bool *pState)=0
 
virtual int WriteTorqueEnable (bool bState)=0
 
virtual int ReadLed (bool *pState)=0
 
virtual int WriteLed (bool bState)=0
 
virtual int ReadControlMethod (DynaServoCtlMethod_T *pCtlMethod)=0
 
virtual int WriteControlMethod (DynaServoCtlMethod_T &ctlMethod)=0
 
virtual int ReadGoalPos (int *pGoalPos)=0
 
virtual int WriteGoalPos (int nGoalPos)=0
 
virtual int ReadGoalSpeed (int *pGoalSpeed)=0
 
virtual int WriteGoalSpeed (int nGoalSpeed)=0
 
virtual int ReadMaxTorqueLimit (uint_t *pMaxTorqueLim)=0
 
virtual int WriteMaxTorqueLimit (uint_t uMaxTorqueLim)=0
 
virtual int ReloadMaxTorqueLimit ()=0
 
virtual int ReadCurPos (int *pCurPos)=0
 
virtual int ReadCurSpeed (int *pCurSpeed)=0
 
virtual int ReadCurLoad (int *pCurLoad)=0
 
virtual int ReadDynamics (int *pCurPos, int *pCurSpeed, int *pCurLoad)=0
 
virtual int ReadHealth (uint_t *pAlarms, int *pCurLoad, uint_t *pCurVolt, uint_t *pCurTemp)=0
 
virtual int ReadIsMoving (bool *pState)=0
 
virtual int Read (uint_t uAddr, uint_t *pVal)=0
 
virtual int Write (uint_t uAddr, uint_t uVal)=0
 
virtual bool Ping ()=0
 
virtual int Reset ()=0
 
virtual int SyncData ()=0
 
virtual int SyncCfg ()=0
 
virtual int SyncState ()=0
 
virtual void Dump ()=0
 

Static Public Member Functions

static DynaServoNew (DynaComm &comm, int nServoId)
 Archetype constructor to create a new Dynamixel servo instance. More...
 
static int ReadModelNumber (DynaComm &comm, int nServoId, uint_t *pModelNum)
 Read the servo model number from the servo's EEPROM. More...
 
static int ReadFirmwareVersion (DynaComm &comm, int nServoId, uint_t *pFwVer)
 Read the servo's firmware version from the servo's EEPROM. More...
 
static int ReadServoId (DynaComm &comm, int nServoId, int *pServoId)
 Read the servo's id from the servo's EEPROM. More...
 
static int WriteServoId (DynaComm &comm, int nServoId, int nNewServoId)
 Write the new servo id to the servo's EEPROM. More...
 
static int ReadBaudRate (DynaComm &comm, int nServoId, int *pBaudRate)
 Read the servo's baud rate from the servo's EEPROM. More...
 
static int WriteBaudRate (DynaComm &comm, int nServoId, int nNewBaudRate)
 Write the new baud rate to the servo's EEPROM. More...
 
static bool Ping (DynaComm &comm, int nServoId)
 Ping the given servo. More...
 
static int Reset (DynaComm &comm, int nServoId)
 Reset the given servo back to default values. More...
 

Protected Member Functions

void Init (int nServoId, uint_t uModelNum, uint_t uFwVer)
 Initialize servo class instance. More...
 
virtual int CalcMatesGoalPos (int nGoalPos, int *pGoalPosMate)=0
 
virtual int CalcMatesGoalSpeed (int nGoalSpeed)=0
 
virtual uint_t PackGoalSpeed (int nGoalSpeed)=0
 
virtual int UnpackGoalSpeed (uint_t uVal)=0
 
virtual int UnpackCurSpeed (uint_t uVal)=0
 
virtual int UnpackCurLoad (uint_t uVal)=0
 
void DumpCtlTbl (const char *sTblName, const DynaCtlTblEntry_T tblInfo[], size_t uSize)
 Dump the servo control tabl values to stdout. More...
 

Protected Attributes

DynaCommm_comm
 attached Dynamixel bus comm. object
 
int m_nServoId
 servo id
 
DynaServoSpec_T m_spec
 servo specification
 
DynaServoCfg_T m_cfg
 servo shadowed EEPROM configuration
 
DynaServoState_T m_state
 servo shadowed RAM state
 
CrossLink_T m_link
 servo cross linkage
 
DynaAgent_Tm_pAgent
 servo agent
 
void * m_pAgentArg
 servo agent callback argument
 
int m_nErrorCode
 class instance errored state
 

Friends

class DynaServoGeneric
 
class DynaServoAX12
 
class DynaServoEX106P
 
class DynaServoMX28
 
class DynaServoMX64
 
class DynaServoMX106
 
class DynaServoRX10
 
class DynaServoRX24F
 
class DynaServoRX28
 
class DynaServoRX64
 
class DynaChain
 

Detailed Description

Dynamixel Servo Abstract Base Class.

The DynaServo abstract class provides the archetype functions to bootstrap into a specific DynaServo class object.

Definition at line 78 of file DynaServo.h.

Constructor & Destructor Documentation

DynaServo::DynaServo ( DynaComm comm,
int  nServoId,
uint_t  uModelNum,
uint_t  uFwVer 
)
inline

Default initialization constructor.

Parameters
commDynamixel bus communication instance.
nServoIdServo Id.
uModelNumServo model number.
uFwVerServo firmware version.

Definition at line 89 of file DynaServo.h.

References Init(), New(), and ~DynaServo().

89  :
90  m_comm(comm)
91  {
92  Init(nServoId, uModelNum, uFwVer);
93  }
void Init(int nServoId, uint_t uModelNum, uint_t uFwVer)
Initialize servo class instance.
Definition: DynaServo.cxx:406
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835

Member Function Documentation

int DynaServo::CalcOdometerAtEncMax ( )
inline

Calculate the odometer value at the maximum encoder value.

Returns
Odometer value.

Definition at line 354 of file DynaServo.h.

References DynaServoOdometer_T::m_nEncZeroPt, DynaServoOdometer_T::m_nOdDir, DynaServoState_T::m_od, m_spec, m_state, and DynaServoSpec_T::m_uRawPosMax.

355  {
358  }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
int DynaServo::CalcOdometerAtEncMin ( )
inline

Calculate the odometer value at the minimum (zero) encoder value.

Returns
Odometer value.

Definition at line 344 of file DynaServo.h.

References DynaServoOdometer_T::m_nEncZeroPt, DynaServoOdometer_T::m_nOdDir, DynaServoState_T::m_od, and m_state.

345  {
347  }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
int DynaServo::CalcSpeedDir ( int  nOdGoalPos)
inline

Calculate serve direction to goal odometer position.

Parameters
nOdGoalPosOdometer goal position.
Returns
1 or -1

Definition at line 380 of file DynaServo.h.

References DisableOdometer(), DYNA_MODE_CONTINUOUS, GetServoMode(), DynaServoOdometer_T::m_nOdDir, DynaServoOdometer_T::m_nOdometer, DynaServoState_T::m_od, m_state, ResetOdometer(), and UpdateOdometer().

381  {
383  {
384  return nOdGoalPos >= m_state.m_od.m_nOdometer?
387  }
388  else
389  {
390  return 1;
391  }
392  }
virtual uint_t GetServoMode() const
Get the servo operational mode.
Definition: DynaServo.h:165
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
int m_nOdometer
current odometer reading (accumulator)
Definition: DynaTypes.h:179
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual float DynaServo::CvtRawTempToC ( uint  uTemp)
pure virtual

Convert raw temperature coding to degrees Celsius.

Parameters
uTempRaw temperature value.
Returns
Celsius.

Implemented in DynaServoGeneric.

Referenced by GetCurTemp().

virtual float DynaServo::CvtRawVoltToVolts ( uint  uVolts)
pure virtual

Convert raw volts coding to volts.

Parameters
uTempRaw volts value.
Returns
Volatage.

Implemented in DynaServoGeneric.

Referenced by GetCurVolt().

void DynaServo::DisableOdometer ( )
virtual

Disable odometer mapping.

The odometer will always equal the encoder value.

Definition at line 242 of file DynaServo.cxx.

References DynaServoOdometer_T::m_bOdEnabled, DynaServoOdometer_T::m_nEncLastPos, DynaServoOdometer_T::m_nEncZeroPt, DynaServoOdometer_T::m_nOdDir, DynaServoOdometer_T::m_nOdometer, DynaServoState_T::m_od, m_state, and DynaServoState_T::m_uCurPos.

Referenced by CalcSpeedDir().

243 {
245  m_state.m_od.m_nOdDir = 1;
247  m_state.m_od.m_bOdEnabled = false;
249 }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
int m_nEncLastPos
last encoder position read from servo
Definition: DynaTypes.h:184
int m_nOdometer
current odometer reading (accumulator)
Definition: DynaTypes.h:179
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
bool m_bOdEnabled
odometer mapping [not] enabled
Definition: DynaTypes.h:181
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
uint_t m_uCurPos
current position (encoder ticks)
Definition: DynaTypes.h:206
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
void DynaServo::DumpCtlTbl ( const char *  sTblName,
const DynaCtlTblEntry_T  tblInfo[],
size_t  uSize 
)
protected

Dump the servo control tabl values to stdout.

Parameters
sTblNameName of the control table.
tblInfoControl table info.
uSizeControl table info size (number of entries).

Definition at line 422 of file DynaServo.cxx.

References DYNA_ECODE_BAD_VAL, DYNA_OK, DynaCtlTblEntry_T::m_bSigned, m_comm, m_nServoId, DynaCtlTblEntry_T::m_sFmt, DynaCtlTblEntry_T::m_sName, DynaCtlTblEntry_T::m_uAddr, DynaCtlTblEntry_T::m_uMask, DynaCtlTblEntry_T::m_uSize, DynaComm::Read16(), and DynaComm::Read8().

Referenced by DynaServoMX106::Dump(), DynaServoMX12W::Dump(), DynaServoMX28::Dump(), DynaServoMX64::Dump(), DynaServoEX106P::Dump(), and DynaServoGeneric::Dump().

425 {
426  const DynaCtlTblEntry_T *p;
427 
428  size_t i;
429  uint_t uVal;
430  uint_t uMask;
431  int iVal;
432  int rc;
433 
434  // table name
435  printf(" %s Control Table\n", sTblName);
436  printf("Address Name Raw Value\n");
437  printf("------- ---- --- -----\n");
438 
439  //
440  // Loop through control table information and print.
441  //
442  for(i=0; i<uSize; ++i)
443  {
444  p = &tblInfo[i];
445 
446  printf("%2u (0x%02x) %-26s ", p->m_uAddr, p->m_uAddr, p->m_sName);
447 
448  //
449  // Control table entry size in bytes.
450  //
451  switch( p->m_uSize )
452  {
453  case 1:
454  rc = m_comm.Read8(m_nServoId, p->m_uAddr, &uVal);
455  break;
456  case 2:
457  rc = m_comm.Read16(m_nServoId, p->m_uAddr, &uVal);
458  break;
459  default:
460  rc = -DYNA_ECODE_BAD_VAL;
461  break;
462  }
463 
464  if( rc != DYNA_OK )
465  {
466  printf("Failed To Read\n");
467  continue;
468  }
469 
470  //
471  // Print the raw value before masking to display the exact contents of
472  // the control table entry.
473  //
474  switch( p->m_uSize )
475  {
476  case 1:
477  printf("0x%02x ", uVal);
478  break;
479  case 2:
480  default:
481  printf("0x%04x ", uVal);
482  break;
483  break;
484  }
485 
486  //
487  // Signed entry value. Upper most mask bit is the sign.
488  //
489  if( p->m_bSigned )
490  {
491  uMask = p->m_uMask >> 1;
492  iVal = (int)(uVal & uMask);
493  if( uVal & ~uMask )
494  {
495  iVal = -iVal;
496  }
497  }
498 
499  //
500  // Unsigned entry value.
501  //
502  else
503  {
504  iVal = (int)(uVal & p->m_uMask);
505  }
506 
507  //
508  // Print interpreted value.
509  //
510  if( p->m_sFmt != NULL )
511  {
512  printf(p->m_sFmt, iVal);
513  }
514 
515  printf("\n");
516  }
517 }
uint_t m_uAddr
control table entry address
Definition: DynaTypes.h:371
bool_t m_bSigned
entry is [not] signed integer
Definition: DynaTypes.h:375
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
uint_t m_uSize
entry size 1 or 2 bytes
Definition: DynaTypes.h:373
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
const char * m_sFmt
alternal output format
Definition: DynaTypes.h:376
const char * m_sName
entry name
Definition: DynaTypes.h:372
Servo Control Table Entry.
Definition: DynaTypes.h:369
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
uint_t m_uMask
mask of entry
Definition: DynaTypes.h:374
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
virtual uint_t DynaServo::GetAlarms ( ) const
inlinevirtual

Get the current servo alarms.

Returns
Alarm bits.

Definition at line 435 of file DynaServo.h.

References m_state, and DynaServoState_T::m_uAlarms.

Referenced by DynaShellCmdClearAlarms::doExec().

436  {
437  return m_state.m_uAlarms;
438  }
uint_t m_uAlarms
current servo alarms and errors
Definition: DynaTypes.h:196
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual const DynaServoCfg_T& DynaServo::GetConfiguration ( ) const
inlinevirtual

Get servo configuration.

Returns
Reference to shadowed configuration data.

Definition at line 195 of file DynaServo.h.

References m_cfg.

196  {
197  return m_cfg;
198  }
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int DynaServo::GetCurLoad ( ) const
inlinevirtual

Get the current servo load.

Returns
Current speed.

Definition at line 475 of file DynaServo.h.

References DynaServoState_T::m_nCurLoad, and m_state.

476  {
477  return m_state.m_nCurLoad;
478  }
int m_nCurLoad
current load
Definition: DynaTypes.h:208
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual uint_t DynaServo::GetCurPos ( ) const
inlinevirtual

Get the current servo position.

Returns
Current position.

Definition at line 445 of file DynaServo.h.

References m_state, and DynaServoState_T::m_uCurPos.

446  {
447  return m_state.m_uCurPos;
448  }
uint_t m_uCurPos
current position (encoder ticks)
Definition: DynaTypes.h:206
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual int DynaServo::GetCurSpeed ( ) const
inlinevirtual

Get the current servo speed.

Returns
Current speed.

Definition at line 455 of file DynaServo.h.

References DynaServoState_T::m_nCurSpeed, and m_state.

Referenced by DynaBgThread::WriteGoalPos().

456  {
457  return m_state.m_nCurSpeed;
458  }
int m_nCurSpeed
current speed (raw)
Definition: DynaTypes.h:207
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual uint_t DynaServo::GetCurTemp ( ) const
inlinevirtual

Get the current temperature.

Returns
Current temperature in raw units.

Definition at line 485 of file DynaServo.h.

References CvtRawTempToC(), m_state, and DynaServoState_T::m_uCurTemp.

486  {
487  return m_state.m_uCurTemp;
488  }
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
uint_t m_uCurTemp
current temperature
Definition: DynaTypes.h:210
virtual uint_t DynaServo::GetCurVolt ( ) const
inlinevirtual

Get the current voltage.

Returns
Current voltage in raw units.

Definition at line 504 of file DynaServo.h.

References CvtRawVoltToVolts(), m_state, and DynaServoState_T::m_uCurVolt.

505  {
506  return m_state.m_uCurVolt;
507  }
uint_t m_uCurVolt
current voltage
Definition: DynaTypes.h:209
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual uint_t DynaServo::GetFirmwareVersion ( ) const
inlinevirtual

Get servo firmware version.

Returns
Model number.

Definition at line 135 of file DynaServo.h.

References m_cfg, and DynaServoCfg_T::m_uFwVer.

Referenced by DynaShellCmdList::Exec().

136  {
137  return m_cfg.m_uFwVer;
138  }
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uFwVer
firmware version
Definition: DynaTypes.h:123
virtual int DynaServo::GetGoalSpeed ( ) const
inlinevirtual

Get the goal servo speed.

Returns
Goal speed.

Definition at line 465 of file DynaServo.h.

References DynaServoState_T::m_nGoalSpeed, and m_state.

466  {
467  return m_state.m_nGoalSpeed;
468  }
int m_nGoalSpeed
goal speed (raw)
Definition: DynaTypes.h:201
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual const DynaServoLink_T DynaServo::GetLinkInfo ( ) const
inlinevirtual

Get linked information.

Returns
Reference to linked data.

Definition at line 256 of file DynaServo.h.

References DYNA_ID_NONE, GetServoId(), DynaServoLink_T::m_bRotReversed, DynaServo::CrossLink_T::m_bRotReversed, m_link, DynaServoLink_T::m_nServoIdMate, DynaServo::CrossLink_T::m_pServoMate, DynaServoLink_T::m_uLinkType, and DynaServo::CrossLink_T::m_uLinkType.

257  {
258  DynaServoLink_T link;
259 
261  link.m_nServoIdMate = m_link.m_pServoMate != NULL?
264 
265  return link;
266  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
virtual const char* DynaServo::GetModelName ( ) const
inlinevirtual

Get servo model name string.

Returns
Model name.

Definition at line 145 of file DynaServo.h.

References DynaServoSpec_T::m_sModelName, and m_spec.

Referenced by DynaChain::ChainEntryDelete(), DynaChain::ChainEntryNew(), DynaShellCmdList::Exec(), and DynaChain::LinkServos().

146  {
147  return m_spec.m_sModelName;
148  }
char * m_sModelName
model name
Definition: DynaTypes.h:83
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
virtual uint_t DynaServo::GetModelNumber ( ) const
inlinevirtual

Get servo model number.

Returns
Model number.

Definition at line 125 of file DynaServo.h.

References m_cfg, and DynaServoCfg_T::m_uModelNum.

Referenced by DynaChain::AuditLinks(), DynaChain::ChainEntryDelete(), DynaChain::ChainEntryNew(), DynaShellCmdList::Exec(), DynaShellCmdTrain::Exec(), DynaShellCmdPlay::Exec(), and DynaChain::LinkServos().

126  {
127  return m_cfg.m_uModelNum;
128  }
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uModelNum
servo model number
Definition: DynaTypes.h:122
int DynaServo::GetOdometer ( )
inline

Get the current virtual odometer value.

Returns
Odometer value.

Definition at line 304 of file DynaServo.h.

References DynaServoOdometer_T::m_nOdometer, DynaServoState_T::m_od, and m_state.

Referenced by DynaServoGeneric::CalcMatesGoalPos(), DynaShellCmdGetOdometer::doExec(), DynaBgThread::execPosCtl(), DynaBgThread::execTorqueCtl(), DynaVServo::getGoalDir(), DynaServoGeneric::ReadCurPos(), DynaBgThread::stopPosCtl(), and DynaBgThread::WriteGoalPos().

305  {
306  return m_state.m_od.m_nOdometer;
307  }
int m_nOdometer
current odometer reading (accumulator)
Definition: DynaTypes.h:179
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
int DynaServo::GetOdometerZeroPt ( )
inline

Get the virtual odometer zero point.

Returns
Servo zero point.

Definition at line 324 of file DynaServo.h.

References DynaServoOdometer_T::m_nEncZeroPt, DynaServoState_T::m_od, and m_state.

Referenced by DynaShellCmdGetOdometer::doExec().

325  {
326  return m_state.m_od.m_nEncZeroPt;
327  }
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual uint_t DynaServo::GetServoId ( ) const
inlinevirtual

Get servo id.

Returns
Servo id.

Definition at line 155 of file DynaServo.h.

References m_nServoId.

Referenced by DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaShellCmdGetPid::doExec(), DynaShellCmdGetOdometer::doExec(), DynaShellCmdCfgWriteServoMode::doExec(), DynaShellCmdReadTorqueEnable::doExec(), DynaShellCmdWriteTorqueEnable::doExec(), DynaShellCmdReadGoalPos::doExec(), DynaShellCmdReadGoalSpeed::doExec(), DynaShellCmdWriteGoalSpeed::doExec(), DynaShellCmdGetSoftTorqueTh::doExec(), DynaShellCmdReadCurPos::doExec(), DynaShellCmdReadCurSpeed::doExec(), DynaShellCmdReadDynamics::doExec(), DynaShellCmdReadHealth::doExec(), DynaShellCmdReadIsMoving::doExec(), DynaShellCmdClearAlarms::doExec(), DynaShellCmdDump::doExec(), DynaBgThread::execPosCtl(), DynaBgThread::execTorqueCtl(), GetLinkInfo(), DynaBgThread::getRegisteredServo(), DynaBgThread::monitorDynamics(), DynaBgThread::monitorHealth(), DynaBgThread::RegisterServoAgent(), DynaBgThread::stopPosCtl(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), and DynaServoGeneric::WriteTorqueEnable().

156  {
157  return m_nServoId;
158  }
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t DynaServo::GetServoMode ( ) const
inlinevirtual
virtual void DynaServo::GetSoftTorqueThresholds ( uint_t &  uOverTorqueTh,
uint_t &  uClearTorqueTh 
)
inlinevirtual

Get soft torque thresholds.

The thresholds are used as a hystersis to software control servo torque.

Parameters
[out]uOverTorqueThHigh threshold where the servo is set in an over torque condition.
[out]uClearTorqueThLow threshold where the servo is cleared of an over torque condition.

Definition at line 546 of file DynaServo.h.

References m_state, DynaServoState_T::m_uClearTorqueTh, and DynaServoState_T::m_uOverTorqueTh.

Referenced by DynaShellCmdGetSoftTorqueTh::doExec(), DynaBgThread::execTorqueCtl(), and DynaBgThread::monitorDynamics().

548  {
549  uOverTorqueTh = m_state.m_uOverTorqueTh;
550  uClearTorqueTh = m_state.m_uClearTorqueTh;
551  }
uint_t m_uClearTorqueTh
clear over torque cond. threshold
Definition: DynaTypes.h:204
uint_t m_uOverTorqueTh
set over torque cond. threshold
Definition: DynaTypes.h:203
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual const DynaServoSpec_T& DynaServo::GetSpecification ( ) const
inlinevirtual

Get servo specification.

Returns
Reference to shadowed specification data.

Definition at line 185 of file DynaServo.h.

References m_spec.

Referenced by DynaShellCmdCfgWriteServoMode::doExec(), and DynaVServo::setToleranceInTicks().

186  {
187  return m_spec;
188  }
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
virtual const DynaServoState_T& DynaServo::GetState ( ) const
inlinevirtual

Get servo state.

Returns
Reference to shadowed state data.

Definition at line 205 of file DynaServo.h.

References m_state.

Referenced by DynaBgThread::execDynamics().

206  {
207  return m_state;
208  }
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual uint_t DynaServo::Has360PosInfo ( ) const
inlinevirtual

Test if servo has 360 ° positioning information.

Returns
Returns true or false.

Definition at line 175 of file DynaServo.h.

References DynaServoSpec_T::m_bHas360Pos, and m_spec.

176  {
177  return m_spec.m_bHas360Pos;
178  }
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
bool m_bHas360Pos
does [not] have full 360 position info
Definition: DynaTypes.h:95
virtual bool DynaServo::HasAgent ( )
inlinevirtual

Tests if servo has a registered agent.

Returns
Returns true or false.

Definition at line 604 of file DynaServo.h.

References m_pAgent, Ping(), ReadBaudRate(), ReadFirmwareVersion(), ReadModelNumber(), ReadServoId(), Reset(), WriteBaudRate(), and WriteServoId().

Referenced by DynaServoGeneric::MoveAtSpeedTo(), DynaServoGeneric::MoveTo(), DynaServoGeneric::Stop(), and DynaChain::SyncMoveAtSpeedTo().

605  {
606  return m_pAgent != NULL? true: false;
607  }
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
virtual bool DynaServo::HasSoftTorqueOverCond ( )
inlinevirtual

Test if servo is in a soft over torque condition.

Returns
Returns current in over torque condition.

Definition at line 568 of file DynaServo.h.

References DynaServoState_T::m_bOverTorqueCond, and m_state.

Referenced by DynaBgThread::monitorDynamics().

569  {
570  return m_state.m_bOverTorqueCond;
571  }
bool m_bOverTorqueCond
over torque condition state
Definition: DynaTypes.h:205
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
void DynaServo::Init ( int  nServoId,
uint_t  uModelNum,
uint_t  uFwVer 
)
protected

Initialize servo class instance.

Parameters
commDynamixel bus communication instance.
nServoIdServo Id.
uModelNumServo model number.
uFwVerServo firmware version.

Definition at line 406 of file DynaServo.cxx.

References m_cfg, DynaServoCfg_T::m_nServoId, m_nServoId, m_pAgent, m_pAgentArg, DynaServoSpec_T::m_sModelName, m_spec, DynaServoCfg_T::m_uFwVer, DynaServoCfg_T::m_uModelNum, newstr(), and Unlink().

Referenced by DynaServo(), DynaServoAX12::Init(), DynaServoRX64::Init(), DynaServoRX10::Init(), DynaServoRX24F::Init(), DynaServoRX28::Init(), DynaServoMX64::Init(), DynaServoMX12W::Init(), DynaServoMX28::Init(), DynaServoMX106::Init(), and DynaServoEX106P::Init().

407 {
408  m_spec.m_sModelName = newstr("abstract class");
409 
410  m_cfg.m_uModelNum = uModelNum;
411  m_cfg.m_uFwVer = uFwVer;
412  m_cfg.m_nServoId = nServoId;
413 
414  m_nServoId = nServoId; // for ease of use
415 
416  m_pAgent = NULL;
417  m_pAgentArg = NULL;
418 
419  Unlink();
420 }
char * newstr(const char *s)
Allocate new duplicated string.
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uFwVer
firmware version
Definition: DynaTypes.h:123
void * m_pAgentArg
servo agent callback argument
Definition: DynaServo.h:842
int m_nServoId
servo id
Definition: DynaTypes.h:124
uint_t m_uModelNum
servo model number
Definition: DynaTypes.h:122
char * m_sModelName
model name
Definition: DynaTypes.h:83
virtual void Unlink()
Unlink this servo.
Definition: DynaServo.h:287
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
bool DynaServo::IsLinkedMaster ( ) const
inline

Test if this servo is a linked master.

A linked master is the master servo in a linked master-slave configuration.

Returns
Returns true if a linked master, false otherwise.

Definition at line 236 of file DynaServo.h.

References DYNA_LINK_MASTER, m_link, and DynaServo::CrossLink_T::m_uLinkType.

Referenced by DynaServoGeneric::CfgReadAlarmShutdownMask(), DynaServoEX106P::CfgReadDriveMode(), DynaServoGeneric::CfgReadMaxTorqueLimit(), DynaServoGeneric::CfgReadRotationLimits(), DynaServoGeneric::CfgReadServoMode(), DynaServoGeneric::CfgReadTemperatureLimit(), DynaServoGeneric::CfgReadVoltageLimits(), DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaServoGeneric::ReadCtlMethodCompliance(), DynaServoGeneric::ReadCtlMethodPid(), DynaServoGeneric::ReadCurLoad(), DynaServoGeneric::ReadCurPos(), DynaServoGeneric::ReadCurSpeed(), DynaServoGeneric::ReadGoalPos(), DynaServoGeneric::ReadGoalSpeed(), DynaServoGeneric::ReadHealth(), DynaServoGeneric::ReadIsMoving(), DynaServoGeneric::ReadLed(), DynaServoGeneric::ReadMaxTorqueLimit(), DynaServoEX106P::ReadSensedCurrent(), DynaServoGeneric::ReadTorqueEnable(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), and DynaServoGeneric::WriteTorqueEnable().

237  {
238  return (m_link.m_uLinkType == DYNA_LINK_MASTER)? true: false;
239  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
bool DynaServo::IsMaster ( ) const
inline

Test if this servo is a master.

A master is either the master servo in a linked master-slave configuration, or an unlinked servo (a master unto thyself).

Returns
Returns true if a master, false otherwise.

Definition at line 223 of file DynaServo.h.

References DYNA_LINK_MASTER, DYNA_LINK_NONE, m_link, and DynaServo::CrossLink_T::m_uLinkType.

Referenced by DynaShellCmd::ChkChainIsMasterServo().

224  {
225  return ((m_link.m_uLinkType == DYNA_LINK_NONE) ||
226  (m_link.m_uLinkType == DYNA_LINK_MASTER))? true: false;
227  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int DynaServo::IsOdometerEnabled ( )
inline

Test if virtual odometer mapping is enabled.

Returns
Returns true or false.

Definition at line 314 of file DynaServo.h.

References DynaServoOdometer_T::m_bOdEnabled, DynaServoState_T::m_od, and m_state.

315  {
316  return m_state.m_od.m_bOdEnabled;
317  }
bool m_bOdEnabled
odometer mapping [not] enabled
Definition: DynaTypes.h:181
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
bool DynaServo::IsOdometerReversed ( )
inline

Test if the virtual odometer is reversed.

Returns
Returns true if reversed, false otherwise.

Definition at line 334 of file DynaServo.h.

References DynaServoOdometer_T::m_nOdDir, DynaServoState_T::m_od, and m_state.

Referenced by DynaShellCmdGetOdometer::doExec(), DynaVServo::getGoalDir(), and DynaBgThread::WriteGoalPos().

335  {
336  return m_state.m_od.m_nOdDir == -1? true: false;
337  }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
bool DynaServo::IsUnlinked ( ) const
inline

Test if this servo is unlinked.

Returns
Returns true if unlinked, false otherwise.

Definition at line 246 of file DynaServo.h.

References DYNA_LINK_NONE, m_link, and DynaServo::CrossLink_T::m_uLinkType.

247  {
248  return (m_link.m_uLinkType == DYNA_LINK_NONE)? true: false;
249  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
virtual void DynaServo::Link ( uint_t  uLinkType,
DynaServo pServoMate,
bool  bRotReversed 
)
inlinevirtual

Link this servo to another.

Parameters
uLinkTypeThis servo's linked type. See Dynamixel Servo Link Types.
pServoMateThis servo's linked mate.
bRotReversedThe linked servos do [not] rotate in opposite directions.

Definition at line 277 of file DynaServo.h.

References DynaServo::CrossLink_T::m_bRotReversed, m_link, DynaServo::CrossLink_T::m_pServoMate, and DynaServo::CrossLink_T::m_uLinkType.

Referenced by DynaChain::AuditLinks(), and DynaChain::LinkServos().

278  {
279  m_link.m_uLinkType = uLinkType;
280  m_link.m_pServoMate = pServoMate;
281  m_link.m_bRotReversed = bRotReversed;
282  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
DynaServo * DynaServo::New ( DynaComm comm,
int  nServoId 
)
static

Archetype constructor to create a new Dynamixel servo instance.

The specific DynaServo object created depends on both the servo's model number and firmware version stored in the servo's EEPROM.

Parameters
commDynamixel bus communication instance.
nServoIdServo id.
Returns
On succes, returns pointer to the allocated DynaServo derived object.
On failure, NULL is returned.
Todo:
TODO Add checks here, if object not errored (or exception thrown). If error, delete object and return null.

Definition at line 102 of file DynaServo.cxx.

References DYNA_LOG_ERROR, DynaServoGeneric::DYNA_MODEL_NUM, DynaServoMX12W::DYNA_MODEL_NUM, DynaServoRX28::DYNA_MODEL_NUM, DynaServoMX106::DYNA_MODEL_NUM, DynaServoRX10::DYNA_MODEL_NUM, DynaServoRX24F::DYNA_MODEL_NUM, DynaServoMX64::DYNA_MODEL_NUM, DynaServoMX28::DYNA_MODEL_NUM, DynaServoRX64::DYNA_MODEL_NUM, DynaServoEX106P::DYNA_MODEL_NUM, ReadFirmwareVersion(), and ReadModelNumber().

Referenced by DynaChain::ChainEntryNew(), and DynaServo().

103 {
104  uint_t uModelNum;
105  uint_t uFwVer;
106  DynaServo *pDynaServo;
107  int rc;
108 
109  // read the servo's model number
110  if( (rc = ReadModelNumber(comm, nServoId, &uModelNum)) < 0 )
111  {
112  DYNA_LOG_ERROR(rc, "Servo %d: Failed to get the model number.", nServoId);
113  return NULL;
114  }
115 
116  // read the servo's firmware version
117  if( (rc = ReadFirmwareVersion(comm, nServoId, &uFwVer)) < 0 )
118  {
119  DYNA_LOG_ERROR(rc, "Servo %d: Failed to get the firmware verions.",
120  nServoId);
121  return NULL;
122  }
123 
124  //
125  // Instantiate the specific derived DynaServo object.
126  //
127  switch( uModelNum )
128  {
129  case DynaServoAX12::DYNA_MODEL_NUM:
130  pDynaServo = new DynaServoAX12(comm, nServoId, uModelNum, uFwVer);
131  break;
132 
134  pDynaServo = new DynaServoEX106P(comm, nServoId, uModelNum, uFwVer);
135  break;
136 
138  pDynaServo = new DynaServoMX12W(comm, nServoId, uModelNum, uFwVer);
139  break;
140 
142  pDynaServo = new DynaServoMX28(comm, nServoId, uModelNum, uFwVer);
143  break;
144 
146  pDynaServo = new DynaServoMX64(comm, nServoId, uModelNum, uFwVer);
147  break;
148 
150  pDynaServo = new DynaServoMX106(comm, nServoId, uModelNum, uFwVer);
151  break;
152 
154  pDynaServo = new DynaServoRX10(comm, nServoId, uModelNum, uFwVer);
155  break;
156 
158  pDynaServo = new DynaServoRX24F(comm, nServoId, uModelNum, uFwVer);
159  break;
160 
162  pDynaServo = new DynaServoRX28(comm, nServoId, uModelNum, uFwVer);
163  break;
164 
166  pDynaServo = new DynaServoRX64(comm, nServoId, uModelNum, uFwVer);
167  break;
168 
170  default:
171  pDynaServo = new DynaServoGeneric(comm, nServoId, uModelNum, uFwVer);
172  break;
173  }
174 
175  /*!
176  * \todo TODO Add checks here, if object not errored (or exception thrown).
177  * If error, delete object and return null.
178  */
179 
180  return pDynaServo;
181 }
static const int DYNA_MODEL_NUM
MX-28 Dynamixel Servo Class.
Definition: DynaServoMX28.h:77
static const int DYNA_MODEL_NUM
static const int DYNA_MODEL_NUM
Definition: DynaServoRX64.h:81
RX-64 Dynamixel Servo Class.
Definition: DynaServoRX64.h:77
AX-12, AX-12+, AX-12A Dynamixel Servo Class.
Definition: DynaServoAX12.h:77
static int ReadModelNumber(DynaComm &comm, int nServoId, uint_t *pModelNum)
Read the servo model number from the servo&#39;s EEPROM.
Definition: DynaServo.cxx:256
static const int DYNA_MODEL_NUM
Definition: DynaServoMX64.h:81
static const int DYNA_MODEL_NUM
Definition: DynaServoMX28.h:81
EX-106+ Dynamixel Servo Class.
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
static int ReadFirmwareVersion(DynaComm &comm, int nServoId, uint_t *pFwVer)
Read the servo&#39;s firmware version from the servo&#39;s EEPROM.
Definition: DynaServo.cxx:276
Generic Dynamixel Servo Base Class.
MX-106 Dynamixel Servo Class.
RX-28 Dynamixel Servo Class.
Definition: DynaServoRX28.h:77
MX-64 Dynamixel Servo Class.
Definition: DynaServoMX64.h:77
static const int DYNA_MODEL_NUM
static const int DYNA_MODEL_NUM
static const int DYNA_MODEL_NUM
Definition: DynaServoRX10.h:81
RX-24F Dynamixel Servo Class.
static const int DYNA_MODEL_NUM
Definition: DynaServoRX28.h:81
static const int DYNA_MODEL_NUM
MX-12W Dynamixel Servo Class.
RX-10 Dynamixel Servo Class.
Definition: DynaServoRX10.h:77
int DynaServo::OdometerToEncoder ( int  nOdPos)
inline

Convert virtual odometer units to servo encoder units.

Parameters
nOdPosOdometer position.
Returns
Encoder ticks.

Definition at line 367 of file DynaServo.h.

References imod(), DynaServoOdometer_T::m_nEncZeroPt, DynaServoOdometer_T::m_nOdDir, DynaServoState_T::m_od, m_spec, m_state, and DynaServoSpec_T::m_uRawPosModulo.

Referenced by DynaServoGeneric::CalcMatesGoalPos(), DynaChain::SyncWriteGoalPos(), and DynaServoGeneric::WriteGoalPos().

368  {
369  return imod(m_state.m_od.m_nEncZeroPt + nOdPos * m_state.m_od.m_nOdDir,
371  }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
uint_t m_uRawPosModulo
raw position modulo
Definition: DynaTypes.h:103
INLINE_IN_H int imod(int a, int b)
a mod b, &ge; 0.
Definition: DynaOlio.h:119
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
bool DynaServo::Ping ( DynaComm comm,
int  nServoId 
)
static

Ping the given servo.

Parameters
commDynamixel bus communication instance.
nServoIdServo id.
Returns
Returns true if the servo responded, else false.

Definition at line 383 of file DynaServo.cxx.

References DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, DynaComm::Ping(), and Ping().

Referenced by HasAgent(), and Ping().

384 {
385  DYNA_TRY_COMM(comm);
386  DYNA_TRY_SERVO_ID(nServoId);
387 
388  return comm.Ping(nServoId);
389 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
virtual bool Ping(int nServoId)=0
Ping the servo.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::ReadBaudRate ( DynaComm comm,
int  nServoId,
int *  pBaudRate 
)
static

Read the servo's baud rate from the servo's EEPROM.

Control Table:
dyna_servo_memmap_baud_rate
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
[out]pBaudRateBaud rate.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 327 of file DynaServo.cxx.

References DynaComm::BaudNumToRate(), DYNA_ADDR_BAUD_RATE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Read8().

Referenced by HasAgent().

328 {
329  uint_t uBaudNum;
330  int nBaudRate;
331  int rc;
332 
333  DYNA_TRY_COMM(comm);
334  DYNA_TRY_SERVO_ID(nServoId);
335 
336  rc = comm.Read8(nServoId, DYNA_ADDR_BAUD_RATE, &uBaudNum);
337 
338  if( rc == DYNA_OK )
339  {
340  // convert to baudrate
341  if( (nBaudRate = comm.BaudNumToRate((int)uBaudNum)) < 0 )
342  {
343  rc = nBaudRate;
344  DYNA_LOG_ERROR(rc, "Servo %d: Unexpected baud number %u read.",
345  nServoId, uBaudNum);
346  }
347  else
348  {
349  *pBaudRate = nBaudRate;
350  rc = DYNA_OK;
351  }
352  }
353 
354  return rc;
355 }
static int BaudNumToRate(int nBaudRate)
Map baud number to Dynamixel baud rate.
Definition: DynaComm.cxx:382
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_ADDR_BAUD_RATE
baud rate enumeration (RW)
Definition: Dynamixel.h:396
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::ReadFirmwareVersion ( DynaComm comm,
int  nServoId,
uint_t *  pFwVer 
)
static

Read the servo's firmware version from the servo's EEPROM.

Control Table:
dyna_servo_memmap_fwver
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
[out]pFwVerPointer to read servo firmware version.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 276 of file DynaServo.cxx.

References DYNA_ADDR_FWVER, DYNA_ADDR_FWVER_MASK, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Read8().

Referenced by HasAgent(), and New().

279 {
280  byte_t val = 0;
281  int rc;
282 
283  DYNA_TRY_COMM(comm);
284  DYNA_TRY_SERVO_ID(nServoId);
285 
286  rc = comm.Read8(nServoId, DYNA_ADDR_FWVER, &val);
287 
288  if( rc == DYNA_OK )
289  {
290  *pFwVer = (uint_t)(val & DYNA_ADDR_FWVER_MASK);
291  }
292 
293  return rc;
294 }
#define DYNA_ADDR_FWVER_MASK
valid data mask
Definition: Dynamixel.h:369
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_ADDR_FWVER
firmware version (R)
Definition: Dynamixel.h:367
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::ReadModelNumber ( DynaComm comm,
int  nServoId,
uint_t *  pModelNum 
)
static

Read the servo model number from the servo's EEPROM.

Control Table:
dyna_servo_memmap_model_num
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
[out]pModelNumPointer to read servo model number.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 256 of file DynaServo.cxx.

References DYNA_ADDR_MODEL_NUM_LSB, DYNA_ADDR_MODEL_NUM_MASK, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Read16().

Referenced by DynaShellCmdMegaScan::Exec(), HasAgent(), and New().

259 {
260  ushort_t val = 0;
261  int rc;
262 
263  DYNA_TRY_COMM(comm);
264  DYNA_TRY_SERVO_ID(nServoId);
265 
266  rc = comm.Read16(nServoId, DYNA_ADDR_MODEL_NUM_LSB, &val);
267 
268  if( rc == DYNA_OK )
269  {
270  *pModelNum = (uint_t)(val & DYNA_ADDR_MODEL_NUM_MASK);
271  }
272 
273  return rc;
274 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_MODEL_NUM_LSB
model number lsb (R)
Definition: Dynamixel.h:353
#define DYNA_ADDR_MODEL_NUM_MASK
valid data mask
Definition: Dynamixel.h:356
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::ReadServoId ( DynaComm comm,
int  nServoId,
int *  pServoId 
)
static

Read the servo's id from the servo's EEPROM.

Control Table:
dyna_servo_memmap_id
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
[out]pServoIdPointer to read servo servo id.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 296 of file DynaServo.cxx.

References DYNA_ADDR_ID, DYNA_ADDR_ID_MASK, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Read8().

Referenced by HasAgent().

299 {
300  uint_t val = 0;
301  int rc;
302 
303  DYNA_TRY_COMM(comm);
304  DYNA_TRY_SERVO_ID(nServoId);
305 
306  rc = comm.Read8(nServoId, DYNA_ADDR_ID, &val);
307 
308  if( rc == DYNA_OK )
309  {
310  *pServoId = (int)(val & DYNA_ADDR_ID_MASK);
311  }
312 
313  return rc;
314 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_ADDR_ID_MASK
valid data mask
Definition: Dynamixel.h:382
#define DYNA_ADDR_ID
dynamixel id (RW)
Definition: Dynamixel.h:380
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
virtual void DynaServo::RegisterAgent ( DynaAgent_T pAgent,
void *  pAgentArg 
)
inlinevirtual

Register servo proxy agent.

Parameters
pAgentPointer to agent calls.
pAgentArgAgent supplied Argument passed back to calls.

Definition at line 584 of file DynaServo.h.

References m_pAgent, and m_pAgentArg.

Referenced by DynaBgThread::RegisterChainAgent(), and DynaBgThread::RegisterServoAgent().

586  {
587  m_pAgent = pAgent;
588  m_pAgentArg = pAgentArg;
589  }
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
void * m_pAgentArg
servo agent callback argument
Definition: DynaServo.h:842
int DynaServo::Reset ( DynaComm comm,
int  nServoId 
)
static

Reset the given servo back to default values.

Warning
All configuration data are lost.
Parameters
commDynamixel bus communication instance.
nServoIdServo id.

Definition at line 391 of file DynaServo.cxx.

References DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, DynaComm::Reset(), and Reset().

Referenced by HasAgent(), and Reset().

392 {
393  int rc;
394 
395  DYNA_TRY_COMM(comm);
396  DYNA_TRY_SERVO_ID(nServoId);
397 
398  return comm.Reset(nServoId);
399 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
virtual int Reset(int nServoId)=0
Reset a servo back to default values.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::ResetOdometer ( int  nEncZeroPt,
bool  bIsReverse 
)
virtual

Reset the servo's virtual odometer.

The odometer mapping is enabled.

Parameters
nEncZeroPtZero point position in servo raw encoder position units.
bIsReverseDo [not] reverse rotation sense.
Returns
Returns the new, odometer position [-OdModulo+1, OdModulo-1] in virtual raw position units.

Definition at line 188 of file DynaServo.cxx.

References DynaServoOdometer_T::m_bOdEnabled, DynaServoOdometer_T::m_nEncLastPos, DynaServoOdometer_T::m_nEncZeroPt, DynaServoOdometer_T::m_nOdDir, DynaServoOdometer_T::m_nOdometer, DynaServoState_T::m_od, m_state, and DynaServoState_T::m_uCurPos.

Referenced by CalcSpeedDir(), DynaShellCmdSetOdometer::Exec(), and DynaServoGeneric::SyncState().

189 {
190  int nEncCurPos;
191  int nOdPos;
192 
193  nEncCurPos = (int)m_state.m_uCurPos;
194 
195  m_state.m_od.m_nEncZeroPt = nEncZeroPt;
196  m_state.m_od.m_nOdDir = bIsReverse? -1: 1;
197  m_state.m_od.m_nEncLastPos = nEncCurPos;
198 
199  nOdPos = m_state.m_od.m_nOdDir * (nEncCurPos - nEncZeroPt);
200 
201  m_state.m_od.m_bOdEnabled = true;
202  m_state.m_od.m_nOdometer = nOdPos;
203 
204  return m_state.m_od.m_nOdometer;
205 }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
int m_nEncLastPos
last encoder position read from servo
Definition: DynaTypes.h:184
int m_nOdometer
current odometer reading (accumulator)
Definition: DynaTypes.h:179
int m_nEncZeroPt
servo encoder zero point position
Definition: DynaTypes.h:185
bool m_bOdEnabled
odometer mapping [not] enabled
Definition: DynaTypes.h:181
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
uint_t m_uCurPos
current position (encoder ticks)
Definition: DynaTypes.h:206
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual void DynaServo::SetSoftTorqueOverCond ( bool  bNewCond)
inlinevirtual

Set or clear servo in soft over torque condition.

Parameters
bNewCondServo [not] in over torque condition.

Definition at line 558 of file DynaServo.h.

References DynaServoState_T::m_bOverTorqueCond, and m_state.

Referenced by DynaBgThread::monitorDynamics().

559  {
560  m_state.m_bOverTorqueCond = bNewCond;
561  }
bool m_bOverTorqueCond
over torque condition state
Definition: DynaTypes.h:205
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual void DynaServo::SetSoftTorqueThresholds ( uint_t  uOverTorqueTh,
uint_t  uClearTorqueTh 
)
inlinevirtual

Set soft torque thresholds.

The thresholds are used as a hystersis to software control servo torque.

Parameters
uOverTorqueThHigh threshold where the servo is set in an over torque condition.
uClearTorqueThLow threshold where the servo is cleared of an over torque condition.

Definition at line 528 of file DynaServo.h.

References DynaServoState_T::m_bOverTorqueCond, m_state, DynaServoState_T::m_uClearTorqueTh, and DynaServoState_T::m_uOverTorqueTh.

Referenced by DynaShellCmdSetSoftTorqueTh::Exec().

530  {
531  m_state.m_uOverTorqueTh = uOverTorqueTh;
532  m_state.m_uClearTorqueTh = uClearTorqueTh;
533  m_state.m_bOverTorqueCond = false;
534  }
bool m_bOverTorqueCond
over torque condition state
Definition: DynaTypes.h:205
uint_t m_uClearTorqueTh
clear over torque cond. threshold
Definition: DynaTypes.h:204
uint_t m_uOverTorqueTh
set over torque cond. threshold
Definition: DynaTypes.h:203
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
int DynaServo::UpdateOdometer ( int  nEncCurPos)
virtual

Update the odometer from the current servo position and rotation direction.

Parameters
nEncCurPosServo encoder current position in raw ticks.
Returns
Returns the new, odometer position [-OdModulo+1, OdModulo-1] in virtual raw position units.

Definition at line 207 of file DynaServo.cxx.

References iabs(), DynaServoOdometer_T::m_bOdEnabled, DynaServoOdometer_T::m_nEncLastPos, DynaServoOdometer_T::m_nOdDir, DynaServoOdometer_T::m_nOdometer, DynaServoState_T::m_od, m_spec, m_state, and DynaServoSpec_T::m_uRawPosMax.

Referenced by CalcSpeedDir(), and DynaServoGeneric::ReadCurPos().

208 {
209  int dp; // minimum delta position
210  int nOdPos; // new odometer position
211 
213  {
214  dp = nEncCurPos - m_state.m_od.m_nEncLastPos;
215 
216  if( iabs(dp) > m_spec.m_uRawPosMax/2 )
217  {
218  if( dp > 0 )
219  {
220  dp = dp - (int)m_spec.m_uRawPosMax;
221  }
222  else // dp < 0
223  {
224  dp = dp + (int)m_spec.m_uRawPosMax;
225  }
226  }
227 
228  nOdPos = m_state.m_od.m_nOdometer + dp * m_state.m_od.m_nOdDir;
229 
230  m_state.m_od.m_nOdometer = nOdPos;
231  m_state.m_od.m_nEncLastPos = nEncCurPos;
232 
233  }
234  else
235  {
236  m_state.m_od.m_nOdometer = nEncCurPos;
237  }
238 
239  return m_state.m_od.m_nOdometer;
240 }
int m_nOdDir
odometer direction: normal or reverse
Definition: DynaTypes.h:182
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
int m_nEncLastPos
last encoder position read from servo
Definition: DynaTypes.h:184
int m_nOdometer
current odometer reading (accumulator)
Definition: DynaTypes.h:179
bool m_bOdEnabled
odometer mapping [not] enabled
Definition: DynaTypes.h:181
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
int DynaServo::WriteBaudRate ( DynaComm comm,
int  nServoId,
int  nNewBaudRate 
)
static

Write the new baud rate to the servo's EEPROM.

Control Table:
dyna_servo_memmap_baud_rate
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
nNewBaudRateNew baud rate.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 357 of file DynaServo.cxx.

References DynaComm::BaudRateToNum(), DYNA_ADDR_BAUD_RATE, DYNA_LOG_ERROR, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Write8().

Referenced by HasAgent().

360 {
361  int nBaudNum;
362  int rc;
363 
364  DYNA_TRY_COMM(comm);
365  DYNA_TRY_SERVO_ID(nServoId);
366 
367  // convert to baudrate
368  if( (nBaudNum = comm.BaudRateToNum(nNewBaudRate)) < 0 )
369  {
370  rc = nBaudNum;
371  DYNA_LOG_ERROR(rc, "Servo %d: Unsupported baud rate %d.",
372  nServoId, nNewBaudRate);
373  }
374 
375  else
376  {
377  rc = comm.Write8(nServoId, DYNA_ADDR_BAUD_RATE, (uint_t)nBaudNum);
378  }
379 
380  return rc;
381 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
#define DYNA_ADDR_BAUD_RATE
baud rate enumeration (RW)
Definition: Dynamixel.h:396
static int BaudRateToNum(int nBaudRate)
Map baud rate to Dynamixel baud number.
Definition: DynaComm.cxx:368
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServo::WriteServoId ( DynaComm comm,
int  nServoId,
int  nNewServoId 
)
static

Write the new servo id to the servo's EEPROM.

Control Table:
dyna_servo_memmap_id
Parameters
commDynamixel bus communication instance.
nServoIdServo id.
nNewServoIdNew servo id.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 316 of file DynaServo.cxx.

References DYNA_ADDR_ID, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and DynaComm::Write8().

Referenced by HasAgent().

319 {
320  DYNA_TRY_COMM(comm);
321  DYNA_TRY_SERVO_ID(nServoId);
322  DYNA_TRY_SERVO_ID(nNewServoId);
323 
324  return comm.Write8(nServoId, DYNA_ADDR_ID, (uint_t)nNewServoId);
325 }
#define DYNA_TRY_SERVO_ID(id)
Testing if the servo id is in range exception macro.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
#define DYNA_ADDR_ID
dynamixel id (RW)
Definition: Dynamixel.h:380
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.

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