Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaChain Class Reference

Dynamixel Chain Container Base Class. More...

#include <DynaChain.h>

Public Member Functions

 DynaChain (DynaComm &comm)
 Default initialization constructor. More...
 
virtual ~DynaChain ()
 Destructor.
 
virtual bool HasServo (int nServoId) const
 
virtual DynaServoGetServo (int nServoId)
 
virtual uint_t GetNumberInChain () const
 Get the number of servos currently in chain. More...
 
virtual int LinkServos (int nServoIdMaster, int nServoIdSlave, bool bIsReversed)
 Software link two unlinked servos in a master-slave configuration. More...
 
virtual int UnlinkServos (int nServoIdMaster)
 Unlink two software linked servos. More...
 
virtual bool IsMaster (int nServoId) const
 Test if the servo is a master. More...
 
bool IsLinkedMaster (int nServoId) const
 Test if this servo is a linked master. More...
 
bool IsLinkedSlave (int nServoId) const
 Test if this servo is a linked slave. More...
 
bool IsUnlinked (int nServoId) const
 Test if this servo is unlinked. More...
 
int GetLinkedMateId (int nServoId) const
 Get linked mate. More...
 
virtual uint_t GetNumberOfMastersInChain ()
 Get the number of servos currently in chain. More...
 
virtual int AddNewServo (int nServoId)
 Create a new servo and add it to the Dynamixel chain. More...
 
virtual int AddNewServosByScan ()
 Scan and add all discovered and created servos to the Dynamixel chain. More...
 
virtual int AddNewServoForced (int nServoId, uint_t uModelNum)
 Force create and add a servo to the Dynamixel chain. More...
 
virtual int RemoveServo (int nServoId)
 Remove from chain and delete. More...
 
virtual int RemoveAllServos ()
 Remove all servos from chain and delete. More...
 
virtual int MoveTo (int nServoId, int nGoalOdPos)
 Move to the goal postition. More...
 
virtual int vSyncMoveTo (uint_t uCount,...)
 Synchronous move servos to new goal positions. More...
 
virtual int SyncMoveTo (DynaPosTuple_T tuplesPos[], uint_t uCount)
 Synchronous move servos to new goal positions in tuple list. More...
 
virtual int MoveAtSpeedTo (int nServoId, int nGoalSpeed, int nGoalOdPos)
 Move at speed to the goal postition. More...
 
virtual int vSyncMoveAtSpeedTo (uint_t uCount,...)
 Synchronous move servos to new goal positions at the given speeds. More...
 
virtual int SyncMoveAtSpeedTo (DynaSpeedPosTuple_T tuplesSpeedPos[], uint_t uCount)
 Synchronous move servos to new goal positions at the given speeds. More...
 
virtual int MoveAtSpeed (int nServoId, int nGoalSpeed)
 Move at speed. More...
 
virtual int vSyncMoveAtSpeed (uint_t uCount,...)
 Synchronous move servos at the given speeds. More...
 
virtual int SyncMoveAtSpeed (DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
 Synchronous move servos at the given speeds. More...
 
virtual int EStop ()
 Emergency stop all servos. More...
 
virtual int Stop ()
 Stop all servos. More...
 
virtual int Freeze ()
 Freeze all servos at current position. More...
 
virtual int Release ()
 Release all servos from any applied torque. More...
 
virtual int SyncWriteTorqueEnable (bool bState)
 Synchronous write to all of the servos in the chain to enable/disable applied torque. More...
 
virtual int vSyncWriteGoalPos (uint_t uCount,...)
 Synchronous write new goal positions for servos. More...
 
virtual int SyncWriteGoalPos (DynaPosTuple_T tuplesPos[], uint_t uCount)
 Synchronous write new goal positions for servos. More...
 
virtual int vSyncWriteGoalSpeed (uint_t uCount,...)
 Synchronous write new goal speed for for servos. More...
 
virtual int SyncWriteGoalSpeed (DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
 Synchronous write new goal speed for servos. More...
 
virtual int IterStart (int *pIter)
 Start iteration over of entire servo chain. More...
 
virtual int IterNext (int *pIter)
 Next iteration over of entire servo chain. More...
 
virtual int IterStartMaster (int *pIter)
 Start iteration master servos over of entire servo chain. More...
 
virtual int IterNextMaster (int *pIter)
 Next iteration of master servos over of entire servo chain. More...
 
const DynaServooperator[] (int nServoId)
 Subscript operator. More...
 

Protected Member Functions

void Init ()
 Initialize chain class instance.
 
virtual int ChainEntryNew (int nServoId)
 Create new dervied DyanServo object and insert into chain. More...
 
virtual int ChainEntryDelete (int nServoId)
 Remove servo from chain and delete. More...
 
virtual void AuditLinks ()
 Audit servo links and repair or delete. More...
 
virtual void SetLinkData (int nServoId, uint_t uLinkType, int nServoIdMate, bool bRotReversed)
 Set local link data for the given servo. More...
 
virtual void ClearLinkData (int nServoId)
 Clear local link data for the given servo.
 

Protected Attributes

DynaCommm_comm
 bus communication instance
 
DynaServom_pChain [DYNA_ID_NUMOF]
 chain of servos
 
int m_nIIdx [DYNA_ID_NUMOF]
 indirect index
 
DynaServoLink_T m_links [DYNA_ID_NUMOF]
 servo linked info
 
uint_t m_uNumInChain
 number of servos in chain
 
uint_t m_uNumMastersInChain
 num of master servos in chain
 

Detailed Description

Dynamixel Chain Container Base Class.

The DynaChain base class provides a coherent and synchronized interface to a set of servos communicating on the same Dynamixel bus.

Definition at line 75 of file DynaChain.h.

Constructor & Destructor Documentation

DynaChain::DynaChain ( DynaComm comm)

Default initialization constructor.

The chain is bound to the given Dynamixel bus communication object. No servos are present in the chain until explicitly added.

A background thread may be automatically started (default) to:

  • control the positioning of servos configured in continuous mode.
  • monitor the dynamics of the servos in the chain.
  • monitor the health of the servos in the chain.

It is recommended that if any of the servos in the chain are in continuous (wheel) mode and have 360 ° positioning data, that the background thread be started.

Parameters
commDynamixel bus communication instance.

Definition at line 82 of file DynaChain.cxx.

References Init().

82  : m_comm(comm)
83 {
84  Init();
85 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
void Init()
Initialize chain class instance.
Definition: DynaChain.cxx:297

Member Function Documentation

int DynaChain::AddNewServo ( int  nServoId)
virtual

Create a new servo and add it to the Dynamixel chain.

Communication with servo is checked prior to adding the servo.

Note
Any existing servo with the same servo id will be replaced by this servo.
Any existing linked servo configuration will be preserved if possible.
Parameters
nServoIdServo id to add.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 206 of file DynaChain.cxx.

References AuditLinks(), ChainEntryNew(), DYNA_ECODE_NO_SERVO, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, and m_comm.

Referenced by GetLinkedMateId().

207 {
208  int rc;
209 
211  DYNA_TRY_SERVO_ID(nServoId);
212 
213  // Ping the servo
214  if( !DynaServo::Ping(m_comm, nServoId) )
215  {
216  rc = -DYNA_ECODE_NO_SERVO;
217  DYNA_LOG_ERROR(rc, "Pinging servo %d failed. Cannot add.", nServoId);
218  }
219 
220  // create and insert chain entry
221  else if( (rc = ChainEntryNew(nServoId)) == DYNA_OK )
222  {
223  AuditLinks();
224  }
225 
226  return rc;
227 }
#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
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ECODE_NO_SERVO
no servo found
Definition: Dynamixel.h:86
virtual int ChainEntryNew(int nServoId)
Create new dervied DyanServo object and insert into chain.
Definition: DynaChain.cxx:312
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
virtual void AuditLinks()
Audit servo links and repair or delete.
Definition: DynaChain.cxx:388
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::AddNewServoForced ( int  nServoId,
uint_t  uModelNum 
)
virtual

Force create and add a servo to the Dynamixel chain.

No communication with servo is attempted, nor any data validation performed.

Note
Any existing servo with the same servo id will be replaced by this servo.
Any existing linked servo configuration will be preserved if possible.
Parameters
nServoIdServo id to add.
uModelNumServo model number.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.
Todo:
TODO force add servo to chain

Definition at line 259 of file DynaChain.cxx.

References DYNA_ECODE_NOT_SUPP.

Referenced by GetLinkedMateId().

260 {
261  /*! \todo TODO force add servo to chain */
262  return -DYNA_ECODE_NOT_SUPP;
263 }
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
int DynaChain::AddNewServosByScan ( )
virtual

Scan and add all discovered and created servos to the Dynamixel chain.

Note
All existing servos in the chain are removed and deleted prior to the scan.
Any existing linked servo configuration will be preserved if possible.
Returns
Returns the number of servos added.

Definition at line 229 of file DynaChain.cxx.

References AuditLinks(), ChainEntryDelete(), ChainEntryNew(), DYNA_ID_MIN, DYNA_ID_NUMOF, DYNA_OK, DYNA_TRY_COMM, and m_comm.

Referenced by DynaShellCmdScan::Exec(), and GetLinkedMateId().

230 {
231  int nServoId;
232  int nNumAdded;
233 
235 
236  // remove and delete all servos
237  for(nServoId=DYNA_ID_MIN; nServoId<DYNA_ID_NUMOF; ++nServoId)
238  {
239  ChainEntryDelete(nServoId);
240  }
241 
242  // add all by scan
243  for(nServoId=DYNA_ID_MIN, nNumAdded=0; nServoId<DYNA_ID_NUMOF; ++nServoId)
244  {
245  if( DynaServo::Ping(m_comm, nServoId) )
246  {
247  if( ChainEntryNew(nServoId) == DYNA_OK )
248  {
249  ++nNumAdded;
250  }
251  }
252  }
253 
254  AuditLinks();
255 
256  return nNumAdded;
257 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual int ChainEntryDelete(int nServoId)
Remove servo from chain and delete.
Definition: DynaChain.cxx:346
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
virtual int ChainEntryNew(int nServoId)
Create new dervied DyanServo object and insert into chain.
Definition: DynaChain.cxx:312
virtual void AuditLinks()
Audit servo links and repair or delete.
Definition: DynaChain.cxx:388
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
void DynaChain::AuditLinks ( )
protectedvirtual

Audit servo links and repair or delete.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 388 of file DynaChain.cxx.

References ClearLinkData(), DYNA_ID_MAX, DYNA_ID_MIN, DYNA_ID_NUMOF, DYNA_LINK_MASTER, DYNA_LINK_SLAVE, DynaServo::GetModelNumber(), GetNumberOfMastersInChain(), DynaServo::Link(), DynaServoLink_T::m_bRotReversed, m_links, DynaServoLink_T::m_nServoIdMate, m_pChain, DynaServoLink_T::m_uLinkType, SetLinkData(), and DynaServo::Unlink().

Referenced by AddNewServo(), AddNewServosByScan(), RemoveAllServos(), and RemoveServo().

389 {
390  int nServoIdThis;
391  uint_t uLinkType;
392  int nServoIdMate;
393  bool bRotReversed;
394  DynaServo *pServoThis;
395  DynaServo *pServoMate;
396 
397  for(nServoIdThis=DYNA_ID_MIN; nServoIdThis<DYNA_ID_NUMOF; ++nServoIdThis)
398  {
399  uLinkType = m_links[nServoIdThis].m_uLinkType;
400  nServoIdMate = m_links[nServoIdThis].m_nServoIdMate;
401  bRotReversed = m_links[nServoIdThis].m_bRotReversed;
402  pServoThis = m_pChain[nServoIdThis];
403 
404  // this servo is not present in the chain
405  if( pServoThis == NULL )
406  {
407  ClearLinkData(nServoIdThis);
408  }
409 
410  // this link is either the master or slave servo
411  else if( (uLinkType == DYNA_LINK_MASTER) || (uLinkType == DYNA_LINK_SLAVE) )
412  {
413  // no linked mate
414  if( (nServoIdMate < DYNA_ID_MIN) ||
415  (nServoIdMate > DYNA_ID_MAX) ||
416  ((pServoMate = m_pChain[nServoIdMate]) == NULL) )
417  {
418  pServoThis->Unlink();
419  ClearLinkData(nServoIdThis);
420  }
421 
422  // linked servos mismatch
423  else if(pServoThis->GetModelNumber() != pServoMate->GetModelNumber())
424  {
425  pServoThis->Unlink();
426  pServoMate->Unlink();
427  ClearLinkData(nServoIdThis);
428  }
429 
430  // this link is the master servo
431  else if( uLinkType == DYNA_LINK_MASTER )
432  {
433  pServoThis->Link(DYNA_LINK_MASTER, pServoMate, bRotReversed);
434  pServoMate->Link(DYNA_LINK_SLAVE, pServoThis, bRotReversed);
435  SetLinkData(nServoIdMate, DYNA_LINK_SLAVE, nServoIdThis, bRotReversed);
436  }
437 
438  // this link is the slave servo
439  else
440  {
441  pServoThis->Link(DYNA_LINK_SLAVE, pServoMate, bRotReversed);
442  pServoMate->Link(DYNA_LINK_MASTER, pServoThis, bRotReversed);
443  SetLinkData(nServoIdMate, DYNA_LINK_MASTER, nServoIdThis, bRotReversed);
444  }
445  }
446 
447  // this servo has no link
448  else // DYNA_LINK_NONE
449  {
450  pServoThis->Unlink();
451  ClearLinkData(nServoIdThis);
452  }
453  }
454 
456 }
virtual uint_t GetNumberOfMastersInChain()
Get the number of servos currently in chain.
Definition: DynaChain.cxx:182
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual void ClearLinkData(int nServoId)
Clear local link data for the given servo.
Definition: DynaChain.cxx:468
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
virtual void Link(uint_t uLinkType, DynaServo *pServoMate, bool bRotReversed)
Link this servo to another.
Definition: DynaServo.h:277
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual void Unlink()
Unlink this servo.
Definition: DynaServo.h:287
virtual uint_t GetModelNumber() const
Get servo model number.
Definition: DynaServo.h:125
virtual void SetLinkData(int nServoId, uint_t uLinkType, int nServoIdMate, bool bRotReversed)
Set local link data for the given servo.
Definition: DynaChain.cxx:458
int DynaChain::ChainEntryDelete ( int  nServoId)
protectedvirtual

Remove servo from chain and delete.

Parameters
nServoIdServo Id to delete.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 346 of file DynaChain.cxx.

References DYNA_ID_NONE, DYNA_OK, DYNA_TRY_SERVO_ID, DynaServo::GetModelName(), DynaServo::GetModelNumber(), m_nIIdx, m_pChain, and m_uNumInChain.

Referenced by AddNewServosByScan(), ChainEntryNew(), RemoveAllServos(), and RemoveServo().

347 {
348  DynaServo *pServo;
349  uint_t i, j;
350 
351  DYNA_TRY_SERVO_ID(nServoId);
352 
353  // okay not to be in chain
354  if( (pServo = m_pChain[nServoId]) == NULL )
355  {
356  return DYNA_OK;
357  }
358 
359  // remove from indirect index list
360  for(i=0; i<m_uNumInChain; ++i)
361  {
362  if( m_nIIdx[i] == nServoId )
363  {
364  m_nIIdx[i] = DYNA_ID_NONE;
365  m_uNumInChain--;
366  break;
367  }
368  }
369 
370  // compress indirect index list
371  for(j=i; j<m_uNumInChain; ++j)
372  {
373  m_nIIdx[j] = m_nIIdx[j+1];
374  m_nIIdx[j+1] = DYNA_ID_NONE;
375  }
376 
377  LOGDIAG3("%s servo %d (model number 0x%04x) removed from chain.",
378  pServo->GetModelName(), nServoId, pServo->GetModelNumber());
379 
380  // delete from chain
381  delete m_pChain[nServoId];
382 
383  m_pChain[nServoId] = NULL;
384 
385  return DYNA_OK;
386 }
#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
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual uint_t GetModelNumber() const
Get servo model number.
Definition: DynaServo.h:125
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
virtual const char * GetModelName() const
Get servo model name string.
Definition: DynaServo.h:145
int DynaChain::ChainEntryNew ( int  nServoId)
protectedvirtual

Create new dervied DyanServo object and insert into chain.

Parameters
nServoIdServo Id to delete.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 312 of file DynaChain.cxx.

References ChainEntryDelete(), DYNA_ECODE_NO_SERVO, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_ID, DynaServo::GetModelName(), DynaServo::GetModelNumber(), m_comm, m_nIIdx, m_pChain, m_uNumInChain, and DynaServo::New().

Referenced by AddNewServo(), and AddNewServosByScan().

313 {
314  DynaServo *pServo;
315  int rc;
316 
318  DYNA_TRY_SERVO_ID(nServoId);
319 
320  // create derived servo object
321  pServo = DynaServo::New(m_comm, nServoId);
322 
323  if( pServo == NULL )
324  {
325  rc = -DYNA_ECODE_NO_SERVO;
326  DYNA_LOG_ERROR(rc, "Failed to create servo %d. Cannot add.", nServoId);
327  return rc;
328  }
329 
330  // remove any existing servo with the same id
331  if( m_pChain[nServoId] != NULL )
332  {
333  ChainEntryDelete(nServoId);
334  }
335 
336  // insert into chain
337  m_pChain[nServoId] = pServo;
338  m_nIIdx[m_uNumInChain++] = nServoId;
339 
340  LOGDIAG3("%s servo %d (model number 0x%04x) added to chain.",
341  pServo->GetModelName(), nServoId, pServo->GetModelNumber());
342 
343  return DYNA_OK;
344 }
#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
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ECODE_NO_SERVO
no servo found
Definition: Dynamixel.h:86
virtual int ChainEntryDelete(int nServoId)
Remove servo from chain and delete.
Definition: DynaChain.cxx:346
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
static DynaServo * New(DynaComm &comm, int nServoId)
Archetype constructor to create a new Dynamixel servo instance.
Definition: DynaServo.cxx:102
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual uint_t GetModelNumber() const
Get servo model number.
Definition: DynaServo.h:125
virtual const char * GetModelName() const
Get servo model name string.
Definition: DynaServo.h:145
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::EStop ( )
virtual

Emergency stop all servos.

All torque is removed.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 714 of file DynaChain.cxx.

References DYNA_OK, DYNA_TRY_COMM, m_comm, and SyncWriteTorqueEnable().

Referenced by DynaShellCmdEStop::Exec(), and GetLinkedMateId().

715 {
716  int nMaxTries = 3;
717  int nTries;
718  int rc;
719 
721 
722  for(nTries=0; nTries<nMaxTries; ++nTries)
723  {
724  if( (rc = SyncWriteTorqueEnable(false)) == DYNA_OK )
725  {
726  break;
727  }
728  }
729 
730  return rc;
731 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual int SyncWriteTorqueEnable(bool bState)
Synchronous write to all of the servos in the chain to enable/disable applied torque.
Definition: DynaChain.cxx:782
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::Freeze ( )
virtual

Freeze all servos at current position.

Torque is applied.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 751 of file DynaChain.cxx.

References DYNA_OK, DYNA_TRY_COMM, m_comm, Stop(), and SyncWriteTorqueEnable().

Referenced by DynaShellCmdFreeze::Exec(), GetLinkedMateId(), and DynaShellCmdPlay::SecureArm().

752 {
753  int rc_tmp; // temporary return code
754  int rc; // return code
755 
757 
758  rc = SyncWriteTorqueEnable(true);
759 
760  rc_tmp = Stop();
761 
762  if( rc == DYNA_OK )
763  {
764  rc = rc_tmp;
765  }
766 
767  return rc;
768 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual int SyncWriteTorqueEnable(bool bState)
Synchronous write to all of the servos in the chain to enable/disable applied torque.
Definition: DynaChain.cxx:782
virtual int Stop()
Stop all servos.
Definition: DynaChain.cxx:733
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::GetLinkedMateId ( int  nServoId) const
inline

Get linked mate.

Parameters
nServoIdServo id.
Returns
If the servo is linked, returns its linked mate's servo id.
Else returns DYNA_ID_NONE.

Definition at line 238 of file DynaChain.h.

References AddNewServo(), AddNewServoForced(), AddNewServosByScan(), DYNA_ID_MAX, DYNA_ID_MIN, DYNA_ID_NONE, EStop(), Freeze(), GetNumberOfMastersInChain(), IterNext(), IterNextMaster(), IterStart(), IterStartMaster(), m_links, DynaServoLink_T::m_nServoIdMate, MoveAtSpeed(), MoveAtSpeedTo(), MoveTo(), operator[](), Release(), RemoveAllServos(), RemoveServo(), Stop(), SyncMoveAtSpeed(), SyncMoveAtSpeedTo(), SyncMoveTo(), SyncWriteGoalPos(), SyncWriteGoalSpeed(), SyncWriteTorqueEnable(), vSyncMoveAtSpeed(), vSyncMoveAtSpeedTo(), vSyncMoveTo(), vSyncWriteGoalPos(), and vSyncWriteGoalSpeed().

Referenced by DynaShellCmdList::Exec().

239  {
240  return ((nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX))?
242  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
uint_t DynaChain::GetNumberOfMastersInChain ( )
virtual

Get the number of servos currently in chain.

Returns
Number of masters in chain.

Definition at line 182 of file DynaChain.cxx.

References DYNA_ID_NONE, IsMaster(), m_nIIdx, m_uNumInChain, and m_uNumMastersInChain.

Referenced by AuditLinks(), DynaShellCmdPlay::Exec(), GetLinkedMateId(), LinkServos(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), and UnlinkServos().

183 {
184  int i;
185  int nServoId;
186 
188 
189  for(i=0; i<(int)m_uNumInChain; ++i)
190  {
191  nServoId = m_nIIdx[i];
192 
193  if( (nServoId != DYNA_ID_NONE) && IsMaster(nServoId) )
194  {
196  }
197  }
198 
199  return m_uNumMastersInChain;
200 }
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
virtual bool IsMaster(int nServoId) const
Test if the servo is a master.
Definition: DynaChain.h:180
uint_t m_uNumMastersInChain
num of master servos in chain
Definition: DynaChain.h:717
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
virtual DynaServo* DynaChain::GetServo ( int  nServoId)
inlinevirtual

Get the servo in the chain

Parameters
nServoIdServo id.
Returns
Returns pointer to the servo if servo is the chain.
Returns NULL otherwise.

Definition at line 129 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, and m_pChain.

Referenced by DynaShellCmd::ChkChainIsMasterServo(), DynaShellCmdPlay::ControlToGoals(), DynaShellCmdCfgWriteServoMode::doExec(), DynaShellCmdWriteTorqueEnable::doExec(), DynaShellCmdWriteGoalSpeed::doExec(), DynaShellCmdSetPid::Exec(), DynaShellCmdList::Exec(), DynaShellCmdChainIn::Exec(), DynaShellCmdSetOdometer::Exec(), DynaShellCmdTrain::Exec(), DynaShellCmdPlay::Exec(), DynaShellCmdSetSoftTorqueTh::Exec(), DynaShellCmdPlay::PidInit(), DynaShellCmdPlay::PidSetPoint(), DynaShellCmdPlay::PlotWriteData(), DynaShellCmdTrain::RecordTraining(), and DynaShellCmdPlay::WaitStop().

130  {
131  return ((nServoId < DYNA_ID_MIN) || (nServoId > DYNA_ID_MAX))?
132  NULL: m_pChain[nServoId];
133  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual bool DynaChain::HasServo ( int  nServoId) const
inlinevirtual

Test if servo is in the chain.

Parameters
nServoIdServo id.
Returns
Returns true if servo is the chain, false otherwise.

Definition at line 113 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, and m_pChain.

Referenced by DynaShellCmd::ChkChainHasServo().

114  {
115  return ((nServoId >= DYNA_ID_MIN) &&
116  (nServoId <= DYNA_ID_MAX) &&
117  (m_pChain[nServoId] != NULL))? true: false;
118  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
bool DynaChain::IsLinkedMaster ( int  nServoId) const
inline

Test if this servo is a linked master.

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

Parameters
nServoIdServo id.
Returns
Returns true if a linked master, false otherwise.

Definition at line 196 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, DYNA_LINK_MASTER, and m_links.

Referenced by DynaShellCmdList::Exec(), and DynaShellCmdUnlink::TabCompletion().

197  {
198  return ((nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX) &&
199  (m_links[nServoId].m_uLinkType == DYNA_LINK_MASTER))? true: false;
200  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
bool DynaChain::IsLinkedSlave ( int  nServoId) const
inline

Test if this servo is a linked slave.

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

Parameters
nServoIdServo id.
Returns
Returns true if a linked slave, false otherwise.

Definition at line 211 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, DYNA_LINK_SLAVE, and m_links.

Referenced by DynaShellCmdList::Exec().

212  {
213  return ((nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX) &&
214  (m_links[nServoId].m_uLinkType == DYNA_LINK_SLAVE))? true: false;
215  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
virtual bool DynaChain::IsMaster ( int  nServoId) const
inlinevirtual

Test if the 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).

Parameters
nServoIdServo id.
Returns
Returns true if a master, false otherwise.

Definition at line 180 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, DYNA_LINK_MASTER, DYNA_LINK_NONE, and m_links.

Referenced by GetNumberOfMastersInChain(), IterNextMaster(), and IterStartMaster().

181  {
182  return ((nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX) &&
183  ((m_links[nServoId].m_uLinkType == DYNA_LINK_MASTER) ||
184  (m_links[nServoId].m_uLinkType == DYNA_LINK_NONE)))? true: false;
185  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
bool DynaChain::IsUnlinked ( int  nServoId) const
inline

Test if this servo is unlinked.

Parameters
nServoIdServo id.
Returns
Returns true if unlinked (or non-existent), false otherwise.

Definition at line 224 of file DynaChain.h.

References DYNA_ID_MAX, DYNA_ID_MIN, DYNA_LINK_NONE, and m_links.

Referenced by DynaShellCmdLink::TabCompletion().

225  {
226  return ((nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX) &&
227  (m_links[nServoId].m_uLinkType == DYNA_LINK_NONE))? true: false;
228  }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
int DynaChain::IterNext ( int *  pIter)
virtual

Next iteration over of entire servo chain.

Parameters
pIterPointer to iterator.
Returns
On success, returns the next servo id.
On end of chain or error, DYNA_ID_NONE is returned.

Definition at line 1020 of file DynaChain.cxx.

References DYNA_ID_NONE, m_nIIdx, and m_uNumInChain.

Referenced by DynaShellCmdSetPid::Exec(), DynaShellCmdList::Exec(), DynaShellCmdChainIn::Exec(), DynaShellCmdChainOut::Exec(), DynaShellCmdReadMaxTorqueLimit::Exec(), DynaShellCmdWriteMaxTorqueLimit::Exec(), DynaShellCmdReadByte::Exec(), DynaShellCmdWriteByte::Exec(), GetLinkedMateId(), SyncWriteTorqueEnable(), DynaShellCmdSetPid::TabCompletion(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdLink::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), DynaShellCmdReadMaxTorqueLimit::TabCompletion(), DynaShellCmdWriteMaxTorqueLimit::TabCompletion(), DynaShellCmdReadByte::TabCompletion(), DynaShellCmdWriteByte::TabCompletion(), and DynaShellCmdPlay::WaitStop().

1021 {
1022  int i;
1023 
1024  i = *pIter;
1025 
1026  if( (i >= (int)m_uNumInChain) || (m_nIIdx[i] == DYNA_ID_NONE) )
1027  {
1028  return DYNA_ID_NONE;
1029  }
1030 
1031  *pIter = i + 1;
1032 
1033  return m_nIIdx[i];
1034 }
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
int DynaChain::IterNextMaster ( int *  pIter)
virtual

Next iteration of master servos over of entire servo chain.

Parameters
pIterPointer to iterator.
Returns
On success, returns the next servo id.
On end of chain or error, DYNA_ID_NONE is returned.

Definition at line 1058 of file DynaChain.cxx.

References DYNA_ID_NONE, IsMaster(), m_nIIdx, m_pChain, and m_uNumInChain.

Referenced by DynaShellCmdMoveAtSpeedTo::Exec(), DynaShellCmdChainIn::Exec(), DynaShellCmdChainOut::Exec(), DynaShellCmdTrain::Exec(), DynaShellCmdPlay::Exec(), GetLinkedMateId(), DynaShellCmdPlay::PidInit(), DynaShellCmdTrain::RecordTraining(), Stop(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), and DynaShellCmdUnlink::TabCompletion().

1059 {
1060  int i;
1061  int nServoId;
1062 
1063  for(i = *pIter; i<(int)m_uNumInChain; ++i)
1064  {
1065  nServoId = m_nIIdx[i];
1066  if( nServoId == DYNA_ID_NONE )
1067  {
1068  return DYNA_ID_NONE;
1069  }
1070  else if( m_pChain[nServoId]->IsMaster() )
1071  {
1072  *pIter = i + 1;
1073  return nServoId;
1074  }
1075  }
1076 
1077  return DYNA_ID_NONE;
1078 }
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual bool IsMaster(int nServoId) const
Test if the servo is a master.
Definition: DynaChain.h:180
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
int DynaChain::IterStart ( int *  pIter)
virtual

Start iteration over of entire servo chain.

Parameters
pIterPointer to iterator.
Returns
On success, returns the starting servo id.
On end of chain or error, DYNA_ID_NONE is returned.

Definition at line 1008 of file DynaChain.cxx.

References DYNA_ID_NONE, m_nIIdx, and m_uNumInChain.

Referenced by DynaShellCmdSetPid::Exec(), DynaShellCmdList::Exec(), DynaShellCmdChainIn::Exec(), DynaShellCmdChainOut::Exec(), DynaShellCmdReadMaxTorqueLimit::Exec(), DynaShellCmdWriteMaxTorqueLimit::Exec(), DynaShellCmdReadByte::Exec(), DynaShellCmdWriteByte::Exec(), GetLinkedMateId(), SyncWriteTorqueEnable(), DynaShellCmdSetPid::TabCompletion(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdLink::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), DynaShellCmdReadMaxTorqueLimit::TabCompletion(), DynaShellCmdWriteMaxTorqueLimit::TabCompletion(), DynaShellCmdReadByte::TabCompletion(), DynaShellCmdWriteByte::TabCompletion(), and DynaShellCmdPlay::WaitStop().

1009 {
1010  if( m_uNumInChain == 0 )
1011  {
1012  return DYNA_ID_NONE;
1013  }
1014 
1015  *pIter = 1;
1016 
1017  return m_nIIdx[0];
1018 }
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
int DynaChain::IterStartMaster ( int *  pIter)
virtual

Start iteration master servos over of entire servo chain.

Parameters
pIterPointer to iterator.
Returns
On success, returns the starting servo id.
On end of chain or error, DYNA_ID_NONE is returned.

Definition at line 1036 of file DynaChain.cxx.

References DYNA_ID_NONE, IsMaster(), m_nIIdx, m_pChain, and m_uNumInChain.

Referenced by DynaShellCmdMoveAtSpeedTo::Exec(), DynaShellCmdChainIn::Exec(), DynaShellCmdChainOut::Exec(), DynaShellCmdTrain::Exec(), DynaShellCmdPlay::Exec(), GetLinkedMateId(), DynaShellCmdPlay::PidInit(), DynaShellCmdTrain::RecordTraining(), Stop(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), and DynaShellCmdUnlink::TabCompletion().

1037 {
1038  int i;
1039  int nServoId;
1040 
1041  for(i=0; i<(int)m_uNumInChain; ++i)
1042  {
1043  nServoId = m_nIIdx[i];
1044  if( nServoId == DYNA_ID_NONE )
1045  {
1046  return DYNA_ID_NONE;
1047  }
1048  else if( m_pChain[nServoId]->IsMaster() )
1049  {
1050  *pIter = i + 1;
1051  return nServoId;
1052  }
1053  }
1054 
1055  return DYNA_ID_NONE;
1056 }
int m_nIIdx[DYNA_ID_NUMOF]
indirect index
Definition: DynaChain.h:714
uint_t m_uNumInChain
number of servos in chain
Definition: DynaChain.h:716
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual bool IsMaster(int nServoId) const
Test if the servo is a master.
Definition: DynaChain.h:180
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
int DynaChain::LinkServos ( int  nServoIdMaster,
int  nServoIdSlave,
bool  bIsReversed 
)
virtual

Software link two unlinked servos in a master-slave configuration.

The servos must be of the same Dynamixel model number.

Parameters
nServoIdMasterMaster servo id.
nServoIdSlaveSlave servo id.
bRotReversedThe linked servos do [not] rotate in opposite directions.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 105 of file DynaChain.cxx.

References DYNA_ECODE_LINKED, DYNA_LINK_MASTER, DYNA_LINK_NONE, DYNA_LINK_SLAVE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_EXPR, DYNA_TRY_SERVO_IN_CHAIN, DynaServo::GetModelName(), DynaServo::GetModelNumber(), GetNumberOfMastersInChain(), DynaServo::Link(), m_links, m_pChain, and SetLinkData().

Referenced by DynaShellCmdLink::Exec(), and GetNumberInChain().

108 {
109  DynaServo *pServoM;
110  DynaServo *pServoS;
111  int rc;
112 
113  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdMaster);
114  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdSlave);
115 
116  DYNA_TRY_EXPR(((m_links[nServoIdMaster].m_uLinkType == DYNA_LINK_NONE) &&
117  (m_links[nServoIdSlave].m_uLinkType == DYNA_LINK_NONE)),
119  "Servos %d and/or %d: Already have linkage.",
120  nServoIdMaster, nServoIdSlave);
121 
122  pServoM = m_pChain[nServoIdMaster];
123  pServoS = m_pChain[nServoIdSlave];
124 
125  if( pServoM->GetModelNumber() != pServoS->GetModelNumber() )
126  {
127  rc = -DYNA_ECODE_LINKED;
128  DYNA_LOG_ERROR(rc, "Cannot link unmatched servos: "
129  "servo %d model %s(%d) != servo %d model %s(%d).",
130  nServoIdMaster, pServoM->GetModelName(), pServoM->GetModelNumber(),
131  nServoIdSlave, pServoS->GetModelName(), pServoS->GetModelNumber());
132  return rc;
133  }
134 
135  pServoM->Link(DYNA_LINK_MASTER, pServoS, bIsReversed);
136  pServoS->Link(DYNA_LINK_SLAVE, pServoM, bIsReversed);
137 
138  SetLinkData(nServoIdMaster, DYNA_LINK_MASTER, nServoIdSlave, bIsReversed);
139  SetLinkData(nServoIdSlave, DYNA_LINK_SLAVE, nServoIdMaster, bIsReversed);
140 
142 
143  return DYNA_OK;
144 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
virtual uint_t GetNumberOfMastersInChain()
Get the number of servos currently in chain.
Definition: DynaChain.cxx:182
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
virtual void Link(uint_t uLinkType, DynaServo *pServoMate, bool bRotReversed)
Link this servo to another.
Definition: DynaServo.h:277
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual uint_t GetModelNumber() const
Get servo model number.
Definition: DynaServo.h:125
#define DYNA_ECODE_LINKED
linked servos error
Definition: Dynamixel.h:98
virtual void SetLinkData(int nServoId, uint_t uLinkType, int nServoIdMate, bool bRotReversed)
Set local link data for the given servo.
Definition: DynaChain.cxx:458
virtual const char * GetModelName() const
Get servo model name string.
Definition: DynaServo.h:145
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
int DynaChain::MoveAtSpeed ( int  nServoId,
int  nGoalSpeed 
)
virtual

Move at speed.

Speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify rotation in the clockwise direction, stop, or rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Continuous mode (DYNA_MODE_CONTINUOUS).
Parameters
nServoIdServo Id
nGoalSpeedGoal speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 655 of file DynaChain.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_CHAIN, m_comm, and m_pChain.

Referenced by GetLinkedMateId().

656 {
657  DynaServo *pServo;
658 
660  DYNA_TRY_SERVO_IN_CHAIN(this, nServoId);
661 
662  pServo = m_pChain[nServoId];
663 
664  DYNA_TRY_IS_MASTER(pServo);
665 
666  return pServo->MoveAtSpeed(nGoalSpeed);
667 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::MoveAtSpeedTo ( int  nServoId,
int  nGoalSpeed,
int  nGoalOdPos 
)
virtual

Move at speed to the goal postition.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify rotation in the clockwise direction, stop, or rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

If the servo is in continuous mode, but supports 360 ° positioning data, then a registered external user control function is required.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Servo mode (DYNA_MODE_SERVO). The direction will be ignored.
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
nServoIdServo Id
uGoalSpeedGoal speed (raw).
uGoalOdPosGoal position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 559 of file DynaChain.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_POS_CTL, DYNA_TRY_SERVO_IN_CHAIN, m_comm, and m_pChain.

Referenced by DynaShellCmdMoveAtSpeedTo::doExec(), and GetLinkedMateId().

560 {
561  DynaServo *pServo;
562 
564  DYNA_TRY_SERVO_IN_CHAIN(this, nServoId);
565 
566  pServo = m_pChain[nServoId];
567 
568  DYNA_TRY_IS_MASTER(pServo);
570 
571  return pServo->MoveAtSpeedTo(nGoalSpeed, nGoalOdPos);
572 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::MoveTo ( int  nServoId,
int  nGoalOdPos 
)
virtual

Move to the goal postition.

The move will proceed at the current goal speed. If the servo is in continuous mode, but supports 360 ° positioning data, then a registered external user control function is required.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
nServoIdServo Id
uGoalOdPosGoal positon (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 480 of file DynaChain.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_CHAIN, m_comm, and m_pChain.

Referenced by DynaShellCmdMoveTo::doExec(), and GetLinkedMateId().

481 {
482  DynaServo *pServo;
483 
485  DYNA_TRY_SERVO_IN_CHAIN(this, nServoId);
486 
487  pServo = m_pChain[nServoId];
488 
489  DYNA_TRY_IS_MASTER(pServo);
490 
491  return pServo->MoveTo(nGoalOdPos);
492 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
const DynaServo * DynaChain::operator[] ( int  nServoId)

Subscript operator.

Parameters
nServoIdServo id.
Returns
On success, returns pointer to servo object in chain.
On failure, return NULL.

Definition at line 1085 of file DynaChain.cxx.

References DYNA_ID_MAX, DYNA_ID_MIN, and m_pChain.

Referenced by GetLinkedMateId().

1086 {
1087  if( (nServoId >= DYNA_ID_MIN) && (nServoId <= DYNA_ID_MAX) )
1088  {
1089  return m_pChain[nServoId];
1090  }
1091  else
1092  {
1093  return NULL;
1094  }
1095 }
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
int DynaChain::Release ( )
virtual

Release all servos from any applied torque.

Servos are free to rotate.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 770 of file DynaChain.cxx.

References DYNA_TRY_COMM, m_comm, and SyncWriteTorqueEnable().

Referenced by DynaShellCmdRelease::Exec(), and GetLinkedMateId().

771 {
773 
774  return SyncWriteTorqueEnable(false);
775 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual int SyncWriteTorqueEnable(bool bState)
Synchronous write to all of the servos in the chain to enable/disable applied torque.
Definition: DynaChain.cxx:782
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::RemoveAllServos ( )
virtual

Remove all servos from chain and delete.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 275 of file DynaChain.cxx.

References AuditLinks(), ChainEntryDelete(), DYNA_ID_MIN, DYNA_ID_NUMOF, DYNA_OK, and m_pChain.

Referenced by GetLinkedMateId().

276 {
277  int nServoId;
278 
279  for(nServoId=DYNA_ID_MIN; nServoId<DYNA_ID_NUMOF; ++nServoId)
280  {
281  if( m_pChain[nServoId] != NULL )
282  {
283  ChainEntryDelete(nServoId);
284  }
285  }
286 
287  AuditLinks();
288 
289  return DYNA_OK;
290 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int ChainEntryDelete(int nServoId)
Remove servo from chain and delete.
Definition: DynaChain.cxx:346
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual void AuditLinks()
Audit servo links and repair or delete.
Definition: DynaChain.cxx:388
int DynaChain::RemoveServo ( int  nServoId)
virtual

Remove from chain and delete.

Parameters
nServoIdServo Id to delete.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 265 of file DynaChain.cxx.

References AuditLinks(), ChainEntryDelete(), DYNA_OK, and DYNA_TRY_SERVO_IN_CHAIN.

Referenced by GetLinkedMateId().

266 {
267  DYNA_TRY_SERVO_IN_CHAIN(this, nServoId);
268 
269  ChainEntryDelete(nServoId);
270  AuditLinks();
271 
272  return DYNA_OK;
273 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int ChainEntryDelete(int nServoId)
Remove servo from chain and delete.
Definition: DynaChain.cxx:346
virtual void AuditLinks()
Audit servo links and repair or delete.
Definition: DynaChain.cxx:388
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
void DynaChain::SetLinkData ( int  nServoId,
uint_t  uLinkType,
int  nServoIdMate,
bool  bRotReversed 
)
protectedvirtual

Set local link data for the given servo.

Parameters
nServiIdServo id.
uLinkTypeThis servo's link type.
nServoIdMateMate servo id.
bRotReversedThe linked servos do [not] rotate in opposite directions.

Definition at line 458 of file DynaChain.cxx.

References DynaServoLink_T::m_bRotReversed, m_links, DynaServoLink_T::m_nServoIdMate, and DynaServoLink_T::m_uLinkType.

Referenced by AuditLinks(), and LinkServos().

462 {
463  m_links[nServoId].m_uLinkType = uLinkType;
464  m_links[nServoId].m_nServoIdMate = nServoIdMate;
465  m_links[nServoId].m_bRotReversed = bRotReversed;
466 }
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
int DynaChain::Stop ( )
virtual

Stop all servos.

Current torque settings are kept.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 733 of file DynaChain.cxx.

References DYNA_ID_NONE, DYNA_TRY_COMM, IterNextMaster(), IterStartMaster(), m_comm, and m_pChain.

Referenced by Freeze(), and GetLinkedMateId().

734 {
735  int nServoId; // working servo id
736  int iter; // iterator
737  int rc; // return code
738 
740 
741  for(nServoId=IterStartMaster(&iter);
742  nServoId!=DYNA_ID_NONE;
743  nServoId=IterNextMaster(&iter))
744  {
745  rc = m_pChain[nServoId]->Stop();
746  }
747 
748  return rc;
749 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual int IterStartMaster(int *pIter)
Start iteration master servos over of entire servo chain.
Definition: DynaChain.cxx:1036
virtual int IterNextMaster(int *pIter)
Next iteration of master servos over of entire servo chain.
Definition: DynaChain.cxx:1058
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncMoveAtSpeed ( DynaSpeedTuple_T  tuplesSpeed[],
uint_t  uCount 
)
virtual

Synchronous move servos at the given speeds.

If any servo is a linked master, the linked pair will moved synchronously at the appropriate speeds and directions.

Servo Operational Modes:
Continuous mode (DYNA_MODE_CONTINUOUS).
Parameters
tuplesSpeedArray of servo id, goal speed 2-tuples.
uCountNumber of tuples.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 695 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_MODE_CONTINUOUS, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_CHAIN, DYNA_TRY_SERVO_IN_MODE, m_comm, m_pChain, and SyncWriteGoalSpeed().

Referenced by GetLinkedMateId().

697 {
698  int i;
699  int rc;
700 
702 
703  for(i=0; i<(int)uCount && i<DYNA_ID_NUMOF; ++i)
704  {
705  DYNA_TRY_SERVO_IN_CHAIN(this, tuplesSpeed[i].m_nServoId);
706  DYNA_TRY_IS_MASTER(m_pChain[tuplesSpeed[i].m_nServoId]);
707  DYNA_TRY_SERVO_IN_MODE(m_pChain[tuplesSpeed[i].m_nServoId],
709  }
710 
711  return SyncWriteGoalSpeed(tuplesSpeed, (uint_t)i);
712 }
virtual int SyncWriteGoalSpeed(DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
Synchronous write new goal speed for servos.
Definition: DynaChain.cxx:940
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_SERVO_IN_MODE(pservo, mode)
Test if the servo is in the given mode.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncMoveAtSpeedTo ( DynaSpeedPosTuple_T  tuplesSpeedPos[],
uint_t  uCount 
)
virtual

Synchronous move servos to new goal positions at the given speeds.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions at the appropriate speeds.

Todo:
Optimize. Add support for bg task continuous mode sync write, then control.
Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
tuplesSpeedPosArray of servo id, goal speed, and goal odometer position 3-tuples.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 596 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_POS_CTL, DYNA_TRY_SERVO_IN_CHAIN, DynaServo::HasAgent(), m_comm, DynaPosTuple_T::m_nPos, DynaPosTuple_T::m_nServoId, DynaSpeedTuple_T::m_nServoId, DynaSpeedPosTuple_T::m_nServoId, DynaSpeedTuple_T::m_nSpeed, m_pChain, SyncWriteGoalPos(), and SyncWriteGoalSpeed().

Referenced by DynaShellCmdMoveAtSpeedTo::doExec(), GetLinkedMateId(), and vSyncMoveAtSpeedTo().

598 {
599  DynaSpeedTuple_T tuplesSpeed[DYNA_ID_NUMOF];
600  DynaPosTuple_T tuplesPos[DYNA_ID_NUMOF];
601  DynaServo *pServo;
602  int i, j;
603  int rc;
604 
606 
607  for(i=0, j=0, rc=DYNA_OK;
608  i<(int)uCount && i<DYNA_ID_NUMOF && rc==DYNA_OK;
609  ++i)
610  {
611  DYNA_TRY_SERVO_IN_CHAIN(this, tuplesSpeedPos[i].m_nServoId);
612 
613  pServo = m_pChain[tuplesSpeedPos[i].m_nServoId];
614 
615  DYNA_TRY_IS_MASTER(pServo);
617 
618  //
619  // In continuous mode: Start host controlled positioning.
620  //
621  if( pServo->HasAgent() )
622  {
623  rc = pServo->MoveAtSpeedTo(tuplesSpeedPos[i].m_nSpeed,
624  tuplesSpeedPos[i].m_nPos);
625  }
626 
627  //
628  // Servo controlled move.
629  //
630  else
631  {
632  tuplesSpeed[j].m_nServoId = tuplesSpeedPos[i].m_nServoId;
633  tuplesSpeed[j].m_nSpeed = tuplesSpeedPos[i].m_nSpeed;
634 
635  tuplesPos[j].m_nServoId = tuplesSpeedPos[i].m_nServoId;
636  tuplesPos[j].m_nPos = tuplesSpeedPos[i].m_nPos;
637 
638  ++j;
639  }
640  }
641 
642  if( (j > 0) && (rc == DYNA_OK) )
643  {
644  rc = SyncWriteGoalSpeed(tuplesSpeed, (uint_t)j);
645 
646  if( rc == DYNA_OK )
647  {
648  rc = SyncWriteGoalPos(tuplesPos, (uint_t)j);
649  }
650  }
651 
652  return rc;
653 }
Synchronous Write Speed Tuple Structure.
Definition: DynaTypes.h:314
virtual int SyncWriteGoalSpeed(DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
Synchronous write new goal speed for servos.
Definition: DynaChain.cxx:940
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
virtual bool HasAgent()
Tests if servo has a registered agent.
Definition: DynaServo.h:604
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
int m_nSpeed
speed
Definition: DynaTypes.h:317
virtual int SyncWriteGoalPos(DynaPosTuple_T tuplesPos[], uint_t uCount)
Synchronous write new goal positions for servos.
Definition: DynaChain.cxx:837
int m_nServoId
servo id
Definition: DynaTypes.h:306
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nServoId
servo id
Definition: DynaTypes.h:316
int m_nPos
position
Definition: DynaTypes.h:307
int m_nServoId
servo id
Definition: DynaTypes.h:326
Position Tuple Structure.
Definition: DynaTypes.h:304
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncMoveTo ( DynaPosTuple_T  tuplesPos[],
uint_t  uCount 
)
virtual

Synchronous move servos to new goal positions in tuple list.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions.

The moves will proceed at the current goal speeds.

Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
tuplesPosArray of servo id, goal odometer position tuples.
uCountNumber of tuples.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 513 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_MODE_CONTINUOUS, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_POS_CTL, DYNA_TRY_SERVO_IN_CHAIN, DynaServo::GetServoMode(), m_comm, DynaPosTuple_T::m_nPos, DynaPosTuple_T::m_nServoId, m_pChain, and SyncWriteGoalPos().

Referenced by DynaShellCmdMoveTo::doExec(), GetLinkedMateId(), DynaShellCmdPlay::SetRecordGoals(), and vSyncMoveTo().

514 {
515  DynaServo *pServo;
517  int i;
518  int j;
519  int rc;
520 
522 
523  for(i=0, j=0, rc=DYNA_OK;
524  i<(int)uCount && i<DYNA_ID_NUMOF && rc==DYNA_OK;
525  ++i)
526  {
527  DYNA_TRY_SERVO_IN_CHAIN(this, tuplesPos[i].m_nServoId);
528 
529  pServo = m_pChain[tuplesPos[i].m_nServoId];
530 
531  DYNA_TRY_IS_MASTER(pServo);
533 
534  //
535  // In continuous mode: Start host controlled positioning.
536  //
537  if( pServo->GetServoMode() == DYNA_MODE_CONTINUOUS )
538  {
539  rc = pServo->MoveTo(tuplesPos[i].m_nPos);
540  }
541  //
542  // Let Dynmixel firmware take control of the move.
543  else
544  {
545  tuple[j].m_nServoId = tuplesPos[i].m_nServoId;
546  tuple[j].m_nPos = tuplesPos[i].m_nPos;
547  ++j;
548  }
549  }
550 
551  if( (rc == DYNA_OK) && (j > 0) )
552  {
553  rc = SyncWriteGoalPos(tuplesPos, (uint_t)j);
554  }
555 
556  return rc;
557 }
virtual uint_t GetServoMode() const
Get the servo operational mode.
Definition: DynaServo.h:165
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
virtual int SyncWriteGoalPos(DynaPosTuple_T tuplesPos[], uint_t uCount)
Synchronous write new goal positions for servos.
Definition: DynaChain.cxx:837
int m_nServoId
servo id
Definition: DynaTypes.h:306
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nPos
position
Definition: DynaTypes.h:307
Position Tuple Structure.
Definition: DynaTypes.h:304
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncWriteGoalPos ( DynaPosTuple_T  tuplesPos[],
uint_t  uCount 
)
virtual

Synchronous write new goal positions for servos.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions.

Control Table:
dyna_servo_memmap_goal_pos.
Dynamixel Position Common Values.
Parameters
tuplesPosArray of servo id, goal odometer position tuples.
uCountNumber of tuples.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 837 of file DynaChain.cxx.

References DYNA_ADDR_GOAL_POS_LSB, DYNA_ECODE_BAD_VAL, DYNA_ID_NUMOF, DYNA_LINK_MASTER, DYNA_MODE_SERVO, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DYNA_TRY_RC, DYNA_TRY_SERVO_IN_CHAIN, DynaServo::GetServoId(), DynaServo::GetServoMode(), m_comm, m_links, DynaPosTuple_T::m_nPos, DynaSyncWriteTuple_T::m_nServoId, DynaPosTuple_T::m_nServoId, DynaServoLink_T::m_nServoIdMate, m_pChain, DynaServo::m_spec, DynaServo::m_state, DynaServoState_T::m_uGoalPos, DynaServoSpec_T::m_uRawPosMin, DynaSyncWriteTuple_T::m_uVal, DynaServo::OdometerToEncoder(), and DynaComm::SyncWrite().

Referenced by GetLinkedMateId(), SyncMoveAtSpeedTo(), SyncMoveTo(), and vSyncWriteGoalPos().

838 {
839  DynaSyncWriteTuple_T tuples[DYNA_ID_NUMOF]; // servo_id, enc_pos tuples
840  int nServoIdM; // master servo id
841  int nServoIdS; // slave servo id
842  DynaServo *pServoM; // master servo
843  DynaServo *pServoS; // slave servo
844  int nGoalOdPosM; // master goal odometer position
845  int nGoalOdPosS; // slave goal odometer position
846  int nEncPos; // working encoder position
847  bool bRotReversed; // slave rotation is reverse
848  int i, j; // working indices
849  int rc; // return code
850 
852 
853  //
854  // Loop through tuples.
855  //
856  for(i=0, j=0; (i<(int)uCount) && (j<DYNA_ID_NUMOF-1); ++i)
857  {
858  nServoIdM = tuplesPos[i].m_nServoId;
859  nGoalOdPosM = tuplesPos[i].m_nPos;
860 
861  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdM);
862 
863  pServoM = m_pChain[nServoIdM];
864 
865  DYNA_TRY_IS_MASTER(pServoM);
866 
867  nEncPos = pServoM->OdometerToEncoder(nGoalOdPosM);
868 
869  if( pServoM->GetServoMode() == DYNA_MODE_SERVO )
870  {
871  DYNA_TRY_EXPR(((nEncPos >= pServoM->m_spec.m_uRawPosMin) &&
872  (nEncPos <= pServoM->m_spec.m_uRawPosMax)),
874  "Master servo %d: Goal odometer position %d(encoder=%d): Out of range.",
875  pServoM->GetServoId(), nGoalOdPosM, nEncPos);
876  }
877 
878  tuples[j].m_nServoId = nServoIdM;
879  tuples[j].m_uVal = (uint_t)nEncPos;
880 
881  j++;
882 
883  // master-slave linked servos
884  if( m_links[nServoIdM].m_uLinkType == DYNA_LINK_MASTER )
885  {
886  nServoIdS = m_links[nServoIdM].m_nServoIdMate;
887 
888  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdS);
889 
890  pServoS = m_pChain[nServoIdS];
891 
892  rc = pServoM->CalcMatesGoalPos(nGoalOdPosM, &nGoalOdPosS);
893 
894  DYNA_TRY_RC(rc, "Slave servo %d: Failed.", nServoIdS);
895 
896  nEncPos = pServoS->OdometerToEncoder(nGoalOdPosS);
897 
898  tuples[j].m_nServoId = nServoIdS;
899  tuples[j].m_uVal = (uint_t)nEncPos;
900 
901  j++;
902  }
903  }
904 
905  // sync write
906  rc = m_comm.SyncWrite(DYNA_ADDR_GOAL_POS_LSB, 2, tuples, (uint_t)j);
907 
908  if( rc == DYNA_OK )
909  {
910  for(i=0; i<j; ++i)
911  {
912  m_pChain[tuples[i].m_nServoId]->m_state.m_uGoalPos = tuples[i].m_uVal;
913  }
914  }
915 
916  return rc;
917 }
virtual uint_t GetServoMode() const
Get the servo operational mode.
Definition: DynaServo.h:165
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
uint_t m_uRawPosMin
minimum raw position value (servo mode)
Definition: DynaTypes.h:101
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
int m_nServoId
servo id
Definition: DynaTypes.h:296
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
uint_t m_uVal
write value
Definition: DynaTypes.h:297
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
int m_nServoId
servo id
Definition: DynaTypes.h:306
int m_nPos
position
Definition: DynaTypes.h:307
virtual int SyncWrite(uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0
Synchronous Write 8/16-bit values to a list of Dynamixel servos.
int OdometerToEncoder(int nOdPos)
Convert virtual odometer units to servo encoder units.
Definition: DynaServo.h:367
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
uint_t m_uGoalPos
goal position (encoder ticks)
Definition: DynaTypes.h:200
#define DYNA_ADDR_GOAL_POS_LSB
goal position lsb (RW)
Definition: Dynamixel.h:909
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_RC(rc, fmt,...)
Test if Dynamixel return code is not an error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncWriteGoalSpeed ( DynaSpeedTuple_T  tuplesSpeed[],
uint_t  uCount 
)
virtual

Synchronous write new goal speed for servos.

If a servo is in continuous mode, rotation will occur indefinitely in the direction specified and at the given speed.

If the servo is in servo mode, rotation will occur until the goal position is achieved.

If any servo is a linked master, the linked pair will moved synchronously at the appropriate speeds and directions.

Control Table:
dyna_servo_memmap_goal_speed.
Dynamixel Angular Speed Common Values.
Dynamixel Direction Common Values.
Parameters
tuplesSpeedArray of servo id,speed 2-tuples.
uCountNumber of tuples.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 940 of file DynaChain.cxx.

References DYNA_ADDR_GOAL_SPEED_LSB, DYNA_ECODE_BAD_VAL, DYNA_ID_NUMOF, DYNA_LINK_MASTER, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_CHAIN, DynaServo::GetServoId(), iabs(), m_comm, m_links, DynaServoState_T::m_nGoalSpeed, DynaSyncWriteTuple_T::m_nServoId, DynaSpeedTuple_T::m_nServoId, DynaServoLink_T::m_nServoIdMate, DynaSpeedTuple_T::m_nSpeed, m_pChain, DynaServo::m_spec, DynaServo::m_state, DynaServoSpec_T::m_uRawSpeedMax, DynaSyncWriteTuple_T::m_uVal, and DynaComm::SyncWrite().

Referenced by DynaShellCmdPlay::ControlToGoals(), DynaShellCmdWriteGoalSpeed::doExec(), GetLinkedMateId(), SyncMoveAtSpeed(), SyncMoveAtSpeedTo(), vSyncMoveAtSpeed(), and vSyncWriteGoalSpeed().

941 {
943  int nServoIdM;
944  int nServoIdS;
945  DynaServo *pServoM;
946  DynaServo *pServoS;
947  DynaServo *pServo;
948  int nGoalSpeedM;
949  int nGoalSpeedS;
950  int i, j;
951  int rc;
952 
954 
955  for(i=0, j=0; (i<(int)uCount) && (j<DYNA_ID_NUMOF-1); ++i)
956  {
957  nServoIdM = tuplesSpeed[i].m_nServoId;
958  nGoalSpeedM = tuplesSpeed[i].m_nSpeed;
959 
960  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdM);
961 
962  pServoM = m_pChain[tuplesSpeed[i].m_nServoId];
963 
964  DYNA_TRY_IS_MASTER(pServoM);
965 
966  DYNA_TRY_EXPR( (iabs(nGoalSpeedM) <= pServoM->m_spec.m_uRawSpeedMax),
968  "Master servo %d: Goal speed %d: Out of range.",
969  pServoM->GetServoId(), nGoalSpeedM);
970 
971  tuples[j].m_nServoId = nServoIdM;
972  tuples[j].m_uVal = pServoM->PackGoalSpeed(nGoalSpeedM);
973  j++;
974 
975  // master-slave linked servos
976  if( m_links[nServoIdM].m_uLinkType == DYNA_LINK_MASTER )
977  {
978  nServoIdS = m_links[nServoIdM].m_nServoIdMate;
979  pServoS = m_pChain[nServoIdS];
980 
981  nGoalSpeedS = pServoM->CalcMatesGoalSpeed(nGoalSpeedM);
982 
983  tuples[j].m_nServoId = nServoIdS;
984  tuples[j].m_uVal = pServoS->PackGoalSpeed(nGoalSpeedS);
985  j++;
986  }
987  }
988 
989  rc = m_comm.SyncWrite(DYNA_ADDR_GOAL_SPEED_LSB, 2, tuples, (uint_t)j);
990 
991  if( rc == DYNA_OK )
992  {
993  for(i=0; i<j; ++i)
994  {
995  pServo = m_pChain[tuples[i].m_nServoId];
996  pServo->m_state.m_nGoalSpeed = pServo->UnpackGoalSpeed(tuples[i].m_uVal);
997  }
998  }
999 
1000  return rc;
1001 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
Definition: Dynamixel.h:940
uint_t m_uRawSpeedMax
maximum raw speed magnitude value
Definition: DynaTypes.h:105
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
int m_nServoId
servo id
Definition: DynaTypes.h:296
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
uint_t m_uVal
write value
Definition: DynaTypes.h:297
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
int m_nGoalSpeed
goal speed (raw)
Definition: DynaTypes.h:201
int m_nSpeed
speed
Definition: DynaTypes.h:317
int m_nServoId
servo id
Definition: DynaTypes.h:316
virtual int SyncWrite(uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0
Synchronous Write 8/16-bit values to a list of Dynamixel servos.
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::SyncWriteTorqueEnable ( bool  bState)
virtual

Synchronous write to all of the servos in the chain to enable/disable applied torque.

If the torque state is false (off), no power is applied to the servo, allowing it to be free rotated by any external force.

Control Table:
dyna_servo_memmap_torque_en.
Parameters
bStateTorque enabled (true) or disabled (off) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 782 of file DynaChain.cxx.

References DYNA_ADDR_TORQUE_EN, DYNA_ID_NONE, DYNA_ID_NUMOF, DYNA_OK, DYNA_TORQUE_EN_OFF, DYNA_TORQUE_EN_ON, DYNA_TRY_COMM, IterNext(), IterStart(), DynaServoState_T::m_bTorqueEnabled, m_comm, DynaSyncWriteTuple_T::m_nServoId, m_pChain, DynaServo::m_state, DynaSyncWriteTuple_T::m_uVal, and DynaComm::SyncWrite().

Referenced by EStop(), Freeze(), GetLinkedMateId(), and Release().

783 {
784  uint_t uVal;
785  int nServoId;
786  int iter;
788  uint_t uCount;
789  int rc;
790 
792 
793  uVal = bState? DYNA_TORQUE_EN_ON: DYNA_TORQUE_EN_OFF;
794 
795  for(nServoId=IterStart(&iter), uCount=0;
796  nServoId!=DYNA_ID_NONE;
797  nServoId=IterNext(&iter), ++uCount)
798  {
799  tuples[uCount].m_nServoId = nServoId;
800  tuples[uCount].m_uVal = uVal;
801  }
802 
803  rc = m_comm.SyncWrite(DYNA_ADDR_TORQUE_EN, 1, tuples, uCount);
804 
805  if( rc == DYNA_OK )
806  {
807  for(iter=0; iter<(int)uCount; ++iter)
808  {
809  m_pChain[tuples[iter].m_nServoId]->m_state.m_bTorqueEnabled = bState;
810  }
811  }
812 
813  return rc;
814 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TORQUE_EN_OFF
disable power drive to the motor
Definition: Dynamixel.h:676
int m_nServoId
servo id
Definition: DynaTypes.h:296
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
bool_t m_bTorqueEnabled
torque [not] enabled
Definition: DynaTypes.h:197
uint_t m_uVal
write value
Definition: DynaTypes.h:297
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual int IterStart(int *pIter)
Start iteration over of entire servo chain.
Definition: DynaChain.cxx:1008
virtual int SyncWrite(uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0
Synchronous Write 8/16-bit values to a list of Dynamixel servos.
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
#define DYNA_TORQUE_EN_ON
enable power drive to the motor
Definition: Dynamixel.h:677
virtual int IterNext(int *pIter)
Next iteration over of entire servo chain.
Definition: DynaChain.cxx:1020
#define DYNA_ADDR_TORQUE_EN
torque enable (RW)
Definition: Dynamixel.h:672
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::UnlinkServos ( int  nServoIdMaster)
virtual

Unlink two software linked servos.

Parameters
nServoIdMasterMaster servo id.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 146 of file DynaChain.cxx.

References ClearLinkData(), DYNA_ECODE_LINKED, DYNA_LINK_NONE, DYNA_OK, DYNA_TRY_EXPR, DYNA_TRY_SERVO_IN_CHAIN, GetNumberOfMastersInChain(), m_links, DynaServoLink_T::m_nServoIdMate, m_pChain, and DynaServo::Unlink().

Referenced by DynaShellCmdUnlink::Exec(), and GetNumberInChain().

147 {
148  int nServoIdSlave;
149  DynaServo *pServoM;
150  DynaServo *pServoS;
151  int rc;
152 
153  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdMaster);
154 
155  pServoM = m_pChain[nServoIdMaster];
156 
157  nServoIdSlave = m_links[nServoIdMaster].m_nServoIdMate;
158 
159  DYNA_TRY_SERVO_IN_CHAIN(this, nServoIdSlave);
160 
161  pServoS = m_pChain[nServoIdSlave];
162 
164  ((m_links[nServoIdMaster].m_uLinkType != DYNA_LINK_NONE) &&
165  (m_links[nServoIdSlave].m_uLinkType != DYNA_LINK_NONE) &&
166  (m_links[nServoIdSlave].m_nServoIdMate == nServoIdMaster)),
168  "Servos %d and/or %d: Not linked.",
169  nServoIdMaster, nServoIdSlave);
170 
171  pServoM->Unlink();
172  pServoS->Unlink();
173 
174  ClearLinkData(nServoIdMaster);
175  ClearLinkData(nServoIdSlave);
176 
178 
179  return DYNA_OK;
180 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
virtual uint_t GetNumberOfMastersInChain()
Get the number of servos currently in chain.
Definition: DynaChain.cxx:182
DynaServoLink_T m_links[DYNA_ID_NUMOF]
servo linked info
Definition: DynaChain.h:715
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual void ClearLinkData(int nServoId)
Clear local link data for the given servo.
Definition: DynaChain.cxx:468
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
virtual void Unlink()
Unlink this servo.
Definition: DynaServo.h:287
#define DYNA_ECODE_LINKED
linked servos error
Definition: Dynamixel.h:98
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
int DynaChain::vSyncMoveAtSpeed ( uint_t  uCount,
  ... 
)
virtual

Synchronous move servos at the given speeds.

If any servo is a linked master, the linked pair will moved synchronously at the appropriate speeds and directions.

Servo Operational Modes:
Continuous mode (DYNA_MODE_CONTINUOUS).
Parameters
uCountNumber of tuples.
...A variable argument list of uCount 2-tuples of type (int,int) specifying the servo id and goal speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 669 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_MODE_CONTINUOUS, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_CHAIN, DYNA_TRY_SERVO_IN_MODE, m_comm, DynaSpeedTuple_T::m_nServoId, DynaSpeedTuple_T::m_nSpeed, m_pChain, and SyncWriteGoalSpeed().

Referenced by GetLinkedMateId().

670 {
671  DynaSpeedTuple_T tuplesSpeed[DYNA_ID_NUMOF];
672  va_list ap;
673  int i;
674 
676 
677  va_start(ap, uCount);
678 
679  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
680  {
681  tuplesSpeed[i].m_nServoId = va_arg(ap, int);
682  tuplesSpeed[i].m_nSpeed = va_arg(ap, int);
683 
684  DYNA_TRY_SERVO_IN_CHAIN(this, tuplesSpeed[i].m_nServoId);
685  DYNA_TRY_IS_MASTER(m_pChain[tuplesSpeed[i].m_nServoId]);
686  DYNA_TRY_SERVO_IN_MODE(m_pChain[tuplesSpeed[i].m_nServoId],
688  }
689 
690  va_end(ap);
691 
692  return SyncWriteGoalSpeed(tuplesSpeed, (uint_t)i);
693 }
Synchronous Write Speed Tuple Structure.
Definition: DynaTypes.h:314
virtual int SyncWriteGoalSpeed(DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
Synchronous write new goal speed for servos.
Definition: DynaChain.cxx:940
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
DynaServo * m_pChain[DYNA_ID_NUMOF]
chain of servos
Definition: DynaChain.h:713
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
int m_nSpeed
speed
Definition: DynaTypes.h:317
int m_nServoId
servo id
Definition: DynaTypes.h:316
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
Test if the servo id is valid and present in chain exception macro.
#define DYNA_TRY_SERVO_IN_MODE(pservo, mode)
Test if the servo is in the given mode.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::vSyncMoveAtSpeedTo ( uint_t  uCount,
  ... 
)
virtual

Synchronous move servos to new goal positions at the given speeds.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions at the appropriate speeds.

Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
uCountNumber of tuples.
...A variable argument list of uCount 3-tuples of type (int,int,int) specifying the servo id, goal speed, and the end goal odometer position.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 574 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_TRY_COMM, m_comm, DynaSpeedPosTuple_T::m_nPos, DynaSpeedPosTuple_T::m_nServoId, DynaSpeedPosTuple_T::m_nSpeed, and SyncMoveAtSpeedTo().

Referenced by GetLinkedMateId().

575 {
576  DynaSpeedPosTuple_T tuplesSpeedPos[DYNA_ID_NUMOF];
577  va_list ap;
578  int i;
579 
581 
582  va_start(ap, uCount);
583 
584  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
585  {
586  tuplesSpeedPos[i].m_nServoId = va_arg(ap, int);
587  tuplesSpeedPos[i].m_nSpeed = va_arg(ap, int);
588  tuplesSpeedPos[i].m_nPos = va_arg(ap, int);
589  }
590 
591  va_end(ap);
592 
593  return SyncMoveAtSpeedTo(tuplesSpeedPos, (uint_t)i);
594 }
Synchronous Write Speed-Position Tuple Structure.
Definition: DynaTypes.h:324
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
int m_nSpeed
speed
Definition: DynaTypes.h:327
int m_nPos
position
Definition: DynaTypes.h:328
int m_nServoId
servo id
Definition: DynaTypes.h:326
virtual int SyncMoveAtSpeedTo(DynaSpeedPosTuple_T tuplesSpeedPos[], uint_t uCount)
Synchronous move servos to new goal positions at the given speeds.
Definition: DynaChain.cxx:596
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::vSyncMoveTo ( uint_t  uCount,
  ... 
)
virtual

Synchronous move servos to new goal positions.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions.

The moves will proceed at the current goal speeds.

Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
uCountNumber of tuples.
...A variable argument list of uCount 2-tuples of type (int,int) specifying the servo id and the goal end position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 494 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DynaPosTuple_T::m_nPos, DynaPosTuple_T::m_nServoId, and SyncMoveTo().

Referenced by GetLinkedMateId().

495 {
496  DynaPosTuple_T tuplesPos[DYNA_ID_NUMOF];
497  va_list ap;
498  int i;
499 
500  va_start(ap, uCount);
501 
502  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
503  {
504  tuplesPos[i].m_nServoId = va_arg(ap, int);
505  tuplesPos[i].m_nPos = va_arg(ap, int);
506  }
507 
508  va_end(ap);
509 
510  return SyncMoveTo(tuplesPos, (uint_t)i);
511 }
virtual int SyncMoveTo(DynaPosTuple_T tuplesPos[], uint_t uCount)
Synchronous move servos to new goal positions in tuple list.
Definition: DynaChain.cxx:513
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
int m_nServoId
servo id
Definition: DynaTypes.h:306
int m_nPos
position
Definition: DynaTypes.h:307
Position Tuple Structure.
Definition: DynaTypes.h:304
int DynaChain::vSyncWriteGoalPos ( uint_t  uCount,
  ... 
)
virtual

Synchronous write new goal positions for servos.

If any servo is a linked master, the linked pair will moved synchronously to the appropriate end positions.

Control Table:
dyna_servo_memmap_goal_pos.
Dynamixel Position Common Values.
Parameters
uCountNumber of tuples.
...A variable argument list of uCount 2-tuples of type (int,int) specifying the servo id and the goal end position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 816 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_TRY_COMM, m_comm, DynaPosTuple_T::m_nPos, DynaPosTuple_T::m_nServoId, and SyncWriteGoalPos().

Referenced by GetLinkedMateId().

817 {
818  DynaPosTuple_T tuplesPos[DYNA_ID_NUMOF];
819  va_list ap;
820  int i;
821 
823 
824  va_start(ap, uCount);
825 
826  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
827  {
828  tuplesPos[i].m_nServoId = va_arg(ap, int);
829  tuplesPos[i].m_nPos = va_arg(ap, int);
830  }
831 
832  va_end(ap);
833 
834  return SyncWriteGoalPos(tuplesPos, (uint_t)i);
835 }
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
virtual int SyncWriteGoalPos(DynaPosTuple_T tuplesPos[], uint_t uCount)
Synchronous write new goal positions for servos.
Definition: DynaChain.cxx:837
int m_nServoId
servo id
Definition: DynaTypes.h:306
int m_nPos
position
Definition: DynaTypes.h:307
Position Tuple Structure.
Definition: DynaTypes.h:304
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaChain::vSyncWriteGoalSpeed ( uint_t  uCount,
  ... 
)
virtual

Synchronous write new goal speed for for servos.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify rotation in the clockwise direction, stop, or rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

If any servo is a linked master, the linked pair will moved synchronously at the appropriate speeds and directions.

Parameters
uCountNumber of tuples.
...A variable argument list of uCount 2-tuples of type (int,int) specifying the servo id and the goal speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 919 of file DynaChain.cxx.

References DYNA_ID_NUMOF, DYNA_TRY_COMM, m_comm, DynaSpeedTuple_T::m_nServoId, DynaSpeedTuple_T::m_nSpeed, and SyncWriteGoalSpeed().

Referenced by GetLinkedMateId().

920 {
921  DynaSpeedTuple_T tuplesSpeed[DYNA_ID_NUMOF];
922  va_list ap;
923  int i;
924 
926 
927  va_start(ap, uCount);
928 
929  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
930  {
931  tuplesSpeed[i].m_nServoId = va_arg(ap, int);
932  tuplesSpeed[i].m_nSpeed = va_arg(ap, int);
933  }
934 
935  va_end(ap);
936 
937  return SyncWriteGoalSpeed(tuplesSpeed, (uint_t)i);
938 }
Synchronous Write Speed Tuple Structure.
Definition: DynaTypes.h:314
virtual int SyncWriteGoalSpeed(DynaSpeedTuple_T tuplesSpeed[], uint_t uCount)
Synchronous write new goal speed for servos.
Definition: DynaChain.cxx:940
DynaComm & m_comm
bus communication instance
Definition: DynaChain.h:712
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
int m_nSpeed
speed
Definition: DynaTypes.h:317
int m_nServoId
servo id
Definition: DynaTypes.h:316
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.

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