Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdMoveAtSpeedTo Class Reference

Determine if servos are moving. More...

Inheritance diagram for DynaShellCmdMoveAtSpeedTo:
DynaShellCmd

Public Member Functions

void Exec (DynaShell &shell, int argc, char *argv[])
 Execute 'write-like' command on servos. More...
 
- Public Member Functions inherited from DynaShellCmd
 DynaShellCmd (int nArgCntMin=0, int nArgCntMax=0)
 Default constructor.
 
virtual ~DynaShellCmd ()
 Default destructor.
 
const char * GetCmdName ()
 Get dynamixel shell command name. More...
 
const char * GetCmdHelpBrief ()
 Get shell command name brief description. More...
 
virtual void PrintHelp (int indent=0, int width=80)
 Print command help with the description aligned at the given indentation. More...
 
int GetPublishedLevel () const
 
const char * GetPublishedName () const
 
int SetPublishedInfo (int nLevel, const char *sParent=NULL)
 
virtual char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Default command tab completion generator. More...
 
virtual bool ChkArgCnt (DynaShell &shell, int argc)
 Check that the argument count is within the class (min,max). More...
 
bool ChkArgCnt0 (DynaShell &shell, int argc)
 Check that the argument count is zero. More...
 
bool ChkArgCntEQ (DynaShell &shell, int argc, int eq)
 Check that the argument count is equal to the required. More...
 
bool ChkArgCntGE (DynaShell &shell, int argc, int min)
 Check argument count against minimum required. More...
 
bool ChkArgCntLE (DynaShell &shell, int argc, int max)
 Check argument count against maximum allowed. More...
 
bool ChkComm (DynaShell &shell)
 Check that Dynamixel communication exists and is open. More...
 
bool ChkChain (DynaShell &shell)
 Check that the servo chain exists. More...
 
bool ChkChainNotEmpty (DynaShell &shell)
 Check that the servo chain exists and is not empty. More...
 
bool ChkChainHasServo (DynaShell &shell, int nServoId)
 Check that the given servo is present in the chain. More...
 
bool ChkChainIsMasterServo (DynaShell &shell, int nServoId)
 Check that the given servo is a master. More...
 
bool ToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument to integer. More...
 
bool ToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument to unsigned integer. More...
 
bool ToDouble (DynaShell &shell, const char *sArg, double *pVal)
 Convert command argument to double. More...
 
bool ToBool (DynaShell &shell, const char *sArg, bool *pVal)
 Convert command argument to boolean. More...
 

Protected Member Functions

virtual void doExec (DynaShell &shell, DynaSpeedPosTuple_T tup[], uint_t uCount)
 Move servos to goal positions. More...
 
- Protected Member Functions inherited from DynaShellCmd
virtual void PrintSynopses (int indent, int width)
 Print synsopses. More...
 
virtual void PrintBlock (int col, int indent, int width, const char *sText)
 Print a block of indented text of width. More...
 
virtual void PrintDelim (int width, const char cDelim)
 
char * eow (const char *s)
 Find end of word. More...
 

Additional Inherited Members

- Protected Attributes inherited from DynaShellCmd
const char * m_sCmdName
 command name
 
const char * m_sCmdHelpBrief
 command help brief
 
const char * m_sCmdHelpArgs
 command help arguments
 
const char * m_sCmdHelpDesc
 command help description
 
const int m_nArgCntMin
 minimum argument count
 
const int m_nArgCntMax
 maximum argument count (0 if not max)
 
int m_nPubLevel
 command's published level (depth)
 
char * m_sPubName
 command's published name
 

Detailed Description

Determine if servos are moving.

Definition at line 177 of file dynashell_cmd_servo.cxx.

Member Function Documentation

virtual void DynaShellCmdMoveAtSpeedTo::doExec ( DynaShell shell,
DynaSpeedPosTuple_T  tup[],
uint_t  uCount 
)
inlineprotectedvirtual

Move servos to goal positions.

Parameters
shellDynamixel shell.
tupArray of (servo id, goal position) 2-tuples.
uCountNumber of tuples.

Definition at line 290 of file dynashell_cmd_servo.cxx.

References DYNA_OK, DynaShell::Error(), DynaShell::m_pDynaChain, DynaChain::MoveAtSpeedTo(), and DynaChain::SyncMoveAtSpeedTo().

293  {
294  int rc;
295 
296  if( uCount == 1 )
297  {
298  rc = shell.m_pDynaChain->MoveAtSpeedTo(tup[0].m_nServoId,
299  tup[0].m_nSpeed,
300  tup[0].m_nPos);
301 
302  if( rc != DYNA_OK )
303  {
304  shell.Error(rc, "Servo %d: move at speed %d to %d failed.",
305  tup[0].m_nServoId, tup[0].m_nSpeed, tup[0].m_nPos);
306  }
307  }
308  else // > 1
309  {
310  rc = shell.m_pDynaChain->SyncMoveAtSpeedTo(tup, uCount);
311 
312  if( rc != DYNA_OK )
313  {
314  shell.Error(rc, "Synchronous move at speed of %u servos failed.",
315  uCount);
316  }
317  }
318  }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int MoveAtSpeedTo(int nServoId, int nGoalSpeed, int nGoalOdPos)
Move at speed to the goal postition.
Definition: DynaChain.cxx:559
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
virtual int SyncMoveAtSpeedTo(DynaSpeedPosTuple_T tuplesSpeedPos[], uint_t uCount)
Synchronous move servos to new goal positions at the given speeds.
Definition: DynaChain.cxx:596
void DynaShellCmdMoveAtSpeedTo::Exec ( DynaShell shell,
int  argc,
char *  argv[] 
)
inlinevirtual

Execute 'write-like' command on servos.

Parameters
shellDynamixel shell.
argcCommand argument count.
argvArray of arguments.

Implements DynaShellCmd.

Definition at line 214 of file dynashell_cmd_servo.cxx.

References DYNA_ID_NONE, DYNA_ID_NUMOF, DynaShell::Error(), DynaChain::IterNextMaster(), DynaChain::IterStartMaster(), DynaSpeedPosTuple_T::m_nPos, DynaSpeedPosTuple_T::m_nServoId, DynaSpeedPosTuple_T::m_nSpeed, DynaShell::m_pDynaChain, and TRY.

215  {
216  uint_t uNumPairs;
218  int nServoId;
219  int nSpeed;
220  int nPos;
221  int iter;
222  int cnt;
223 
224  TRY( ChkArgCnt(shell, argc) );
225 
226  if( (argc % 3) != 0 )
227  {
228  shell.Error("Unmatched servo_id,speed,pos triplets.");
229  return;
230  }
231 
232  uNumPairs = (uint_t)(argc / 3);
233 
234  if( uNumPairs > DYNA_ID_NUMOF )
235  {
236  shell.Error("%u: Too many servo_id,speed,pos triplets.", uNumPairs);
237  return;
238  }
239 
240  TRY( ChkComm(shell) );
241  TRY( ChkChainNotEmpty(shell) );
242 
243  // full chain of servos
244  if( !strcmp(argv[0], "chain") )
245  {
246  TRY( ChkArgCntEQ(shell, argc, 3) );
247  TRY( ToInt(shell, argv[1], &nSpeed) );
248  TRY( ToInt(shell, argv[2], &nPos) );
249 
250  for(nServoId = shell.m_pDynaChain->IterStartMaster(&iter), cnt=0;
251  nServoId != DYNA_ID_NONE;
252  nServoId = shell.m_pDynaChain->IterNextMaster(&iter), ++cnt)
253  {
254  tup[cnt].m_nServoId = nServoId;
255  tup[cnt].m_nSpeed = nSpeed;
256  tup[cnt].m_nPos = nPos;
257  }
258 
259  uNumPairs = (uint_t)cnt;
260  }
261 
262  // list of servos
263  else
264  {
265  for(iter=0, cnt=0; iter<argc; iter+=3, ++cnt)
266  {
267  TRY( ToInt(shell, argv[iter], &nServoId) );
268  TRY( ToInt(shell, argv[iter+1], &nSpeed) );
269  TRY( ToInt(shell, argv[iter+2], &nPos) );
270  TRY( ChkChainHasServo(shell, nServoId) );
271  TRY( ChkChainIsMasterServo(shell, nServoId) );
272 
273  tup[cnt].m_nServoId = nServoId;
274  tup[cnt].m_nSpeed = nSpeed;
275  tup[cnt].m_nPos = nPos;
276  }
277  }
278 
279  doExec(shell, tup, uNumPairs);
280  }
Synchronous Write Speed-Position Tuple Structure.
Definition: DynaTypes.h:324
bool ChkChainNotEmpty(DynaShell &shell)
Check that the servo chain exists and is not empty.
bool ChkArgCntEQ(DynaShell &shell, int argc, int eq)
Check that the argument count is equal to the required.
virtual void doExec(DynaShell &shell, DynaSpeedPosTuple_T tup[], uint_t uCount)
Move servos to goal positions.
bool ChkChainHasServo(DynaShell &shell, int nServoId)
Check that the given servo is present in the chain.
bool ChkChainIsMasterServo(DynaShell &shell, int nServoId)
Check that the given servo is a master.
virtual int IterStartMaster(int *pIter)
Start iteration master servos over of entire servo chain.
Definition: DynaChain.cxx:1036
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
virtual int IterNextMaster(int *pIter)
Next iteration of master servos over of entire servo chain.
Definition: DynaChain.cxx:1058
int m_nSpeed
speed
Definition: DynaTypes.h:327
bool ToInt(DynaShell &shell, const char *sArg, int *pVal)
Convert command argument to integer.
int m_nPos
position
Definition: DynaTypes.h:328
virtual bool ChkArgCnt(DynaShell &shell, int argc)
Check that the argument count is within the class (min,max).
#define TRY(boolexpr,...)
Try boolean expression.
Definition: dynashell_cmd.h:89
int m_nServoId
servo id
Definition: DynaTypes.h:326
bool ChkComm(DynaShell &shell)
Check that Dynamixel communication exists and is open.
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808

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