Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdWriteTorqueEnable Class Reference

Determine if servos are moving. More...

Inheritance diagram for DynaShellCmdWriteTorqueEnable:
DynaShellCmdChainOut DynaShellCmd

Protected Member Functions

virtual void doExec (DynaShell &shell, ExecTup_T tup[], uint_t uCount)
 Enable/disable servos torques. More...
 
virtual bool ArgToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument into enable state. More...
 
- Protected Member Functions inherited from DynaShellCmdChainOut
virtual bool ArgToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument into unsigned integer. 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

- Public Member Functions inherited from DynaShellCmdChainOut
 DynaShellCmdChainOut (bool bMasterOpOnly=false)
 Default constructor.
 
virtual ~DynaShellCmdChainOut ()
 Default destructor.
 
virtual void Exec (DynaShell &shell, int argc, char *argv[])
 Execute 'write-like' command on servos. More...
 
virtual char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Command tab completion generator. 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 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 Attributes inherited from DynaShellCmdChainOut
bool m_bMasterOpOnly
 is [not] a master-only supported operation
 
int m_nTabIter
 tab completion: servo id iterator
 
int m_nTabServoId
 tab completion: current servo id
 
bool m_bTabIncChain
 tab completion: [do not] include chain keyword
 
- 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 833 of file dynashell_cmd_servo.cxx.

Member Function Documentation

virtual bool DynaShellCmdWriteTorqueEnable::ArgToInt ( DynaShell shell,
const char *  sArg,
int *  pVal 
)
inlineprotectedvirtual

Convert command argument into enable state.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, false otherwise.

Reimplemented from DynaShellCmdChainOut.

Definition at line 899 of file dynashell_cmd_servo.cxx.

References DynaShell::Error().

900  {
901  if( !strcmp(sArg, "e") || !strcmp(sArg, "enable") ||
902  !strcmp(sArg, "on") || !strcmp(sArg, "true") ||
903  !strcmp(sArg, "1") )
904  {
905  *pVal = 1;
906  return true;
907  }
908  else if( !strcmp(sArg, "d") || !strcmp(sArg, "disable") ||
909  !strcmp(sArg, "off") || !strcmp(sArg, "false") ||
910  !strcmp(sArg, "0") )
911  {
912  *pVal = 0;
913  return true;
914  }
915  else
916  {
917  shell.Error("Argument value \"%s\": Invalid state.", sArg);
918  return false;
919  }
920  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
virtual void DynaShellCmdWriteTorqueEnable::doExec ( DynaShell shell,
ExecTup_T  tup[],
uint_t  uCount 
)
inlineprotectedvirtual

Enable/disable servos torques.

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

Implements DynaShellCmdChainOut.

Definition at line 867 of file dynashell_cmd_servo.cxx.

References DYNA_OK, DynaShell::Error(), DynaChain::GetServo(), DynaServo::GetServoId(), ExecTup_T::m_nVal, and DynaShell::m_pDynaChain.

868  {
869  uint_t i;
870  DynaServo *pServo;
871  bool state;
872  int rc;
873 
874  for(i=0, rc=DYNA_OK; i<uCount && i==DYNA_OK; ++i)
875  {
876  pServo = shell.m_pDynaChain->GetServo(tup[i].m_nServoId);
877  state = tup[i].m_nVal? true: false;
878 
879  rc = pServo->WriteTorqueEnable(state);
880 
881  if( rc != DYNA_OK )
882  {
883  shell.Error(rc,
884  "Servo %d: Failed to set torque enable state.",
885  pServo->GetServoId());
886  }
887  }
888  }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual DynaServo * GetServo(int nServoId)
Definition: DynaChain.h:129
int m_nVal
value
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
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: